Call Git cmd_main directly

This commit is contained in:
Joe Tretter
2026-06-24 13:16:35 -05:00
parent a9d7b0cfc0
commit 0554c736e4
26 changed files with 1141 additions and 661 deletions

View File

@@ -64,7 +64,7 @@ This file records the upstream Ruby setup and validation intent beside the Andro
| `revert` | Creates commits `First commit`, `Bad commit`, `Second commit`. | Same commit messages. | Equivalent. |
| `restore` | Creates `file1`, `file2`, then creates and removes `file3` so it is recoverable from reflog/history. | Native setup creates matching history and removes `file3`; model starts without `file3`. | Equivalent. |
| `conflict` | Copies fixture with `master` and `mybranch` conflict in non-empty `poem.txt`. | Native setup creates the conflicting poem history, leaving `master` with `Categorized shoes by color` and `mybranch` with the correct `Sat on a wall` line. | Equivalent setup. |
| `submodule` | Initializes empty repo. | Same. | Equivalent; network submodule operation is modeled. |
| `submodule` | Initializes empty repo. | Initializes repo and prepares a local sibling repository as an offline submodule source. | Intentional Android adaptation: avoids network access and packaged Git currently lacks the `git submodule` porcelain, so validation requires tracked submodule metadata instead of accepting command text. |
## Validation Summary
@@ -87,7 +87,7 @@ This file records the upstream Ruby setup and validation intent beside the Andro
| `restructure` | HTML files are deleted at root and added under `src/`. | All three `src/*.html` files exist and no live root HTML files remain. | Equivalent. |
| `log` | Prompt answer matches latest commit hash prefix. | Answer matches the modeled commit hash. | Equivalent within Android's deterministic commit model. |
| `tag` | First tag is `new_tag`. | `new_tag` exists. | Equivalent. |
| `push_tags` | Remote tag list contains `tag_to_be_pushed`. | `tag_to_be_pushed` is in `pushedTags`. | Equivalent state projection. |
| `push_tags` | Remote tag list contains `tag_to_be_pushed`. | Inspects remote refs with Git and requires remote tag `tag_to_be_pushed` to point at the local tag object. | Equivalent state projection; no command text is accepted as proof. |
| `commit_amend` | One commit and amended commit contains two files. | One commit and `forgotten_file.rb` is tracked. | Equivalent. |
| `commit_in_future` | Commit authored date is in the future. | At least one commit has an author timestamp later than the current system clock. | Equivalent. |
| `reset` | `to_commit_second.rb` exists but is unstaged; `to_commit_first.rb` remains staged. | Same staged/unstaged split with one commit. | Equivalent. |
@@ -97,7 +97,7 @@ This file records the upstream Ruby setup and validation intent beside the Andro
| `remote_url` | User answers URL matching `https://github.com/githug/not_a_repo/?`. | Answer is exact URL without trailing slash. | Slightly stricter; can be relaxed if trailing slash should be accepted. |
| `pull` | Latest commit hash is `1797a7c`. | Remote file is present, `origin/master` fetched, and commits advanced. | Equivalent local synthetic remote outcome. |
| `remote_add` | `git remote -v` contains `https://github.com/githug/githug`. | `origin` remote equals that URL. | Equivalent and slightly stricter on remote name. |
| `push` | Local `master` and `origin/master` have four identical commits. | `origin/master` was pushed, four files are present, and commit count is at least four. | Equivalent user outcome; Android tracks pushed ref instead of comparing remote commit IDs. |
| `push` | Local `master` and `origin/master` have four identical commits. | Inspects remote refs with Git and requires `origin/master` to match local `master`, plus all four expected files and commits. | Equivalent user outcome; no command text is accepted as proof. |
| `diff` | Answer is changed line number `26`. | Answer is `26`. | Equivalent. |
| `blame` | Answer equals author of known password commit (`Spider Man`). | Answer is `Spider Man`. | Equivalent with deterministic Android fixture. |
| `branch` | Branch `test_code` exists. | `test_code` exists and current branch remains `master`. | Slightly stricter to prevent solving by checkout side effects. |
@@ -106,12 +106,12 @@ This file records the upstream Ruby setup and validation intent beside the Andro
| `checkout_tag_over_branch` | Same as `checkout_tag`; must choose tag, not branch. | HEAD is at tag `v1.2`. | Equivalent in Android tag model. |
| `branch_at` | `test_branch` exists and excludes "Updating file1 again". | `test_branch` points at commit index 2. | Equivalent. |
| `delete_branch` | `delete_me` branch no longer exists. | Same. | Equivalent. |
| `push_branch` | Remote has pushed `test_branch` but not all branches. | `origin/test_branch` pushed and master/other not pushed. | Equivalent. |
| `push_branch` | Remote has pushed `test_branch` but not all branches. | Inspects remote refs with Git and requires `origin/test_branch` to match local `test_branch` while `origin/other_branch` does not match local `other_branch`. | Equivalent; no command text is accepted as proof. |
| `merge` | `file1` and `file2` exist. | Current branch is `master`, a merge action occurred, and `file2` is tracked. | Deliberately stricter than upstream to avoid `git switch feature` falsely solving on Android. |
| `fetch` | Local branch count is one and `.git/FETCH_HEAD` has two entries. | `branches.size == 1`, `fetchHeadCount == 2`, and no recorded `pull` action. | Mostly parity; Android adds the `pull` guard because real Git can leave two `FETCH_HEAD` lines after `git pull`, while the exercise wording explicitly says fetch without merging. |
| `fetch` | Local branch count is one and `.git/FETCH_HEAD` has two entries. | Requires only local `master`, at least two `FETCH_HEAD` entries, fetched `origin/new_branch`, and no tracked `file1` merge result. | Equivalent state outcome; no command text is accepted as proof. |
| `rebase` | `feature` commit messages are `add feature`, `add content`, `init commit`, and old hash changed. | Current branch is `feature` and modeled commit messages match. | Equivalent, except Android does not compare the old hash. |
| `rebase_onto` | `readme-update` has four commits, excludes "Wrong changes", and preserves authors. | Current branch is `readme-update` and rebase-onto action occurred. | Known gap: Android validation is looser than upstream content/commit checks. |
| `repack` | `git count-objects -v` includes packed/pruned object evidence. | `repack` action recorded. | Equivalent action-level validation; Android does not model object database packing stats. |
| `repack` | `git count-objects -v` includes packed/pruned object evidence. | Inspects `.git/objects/pack` and requires a generated pack file. | Equivalent repository-state validation; no command text is accepted as proof. |
| `cherry-pick` | Top commits are "Filled in README..." then "Added fancy branded output". | Same commit message order plus `README.md` tracked. | Equivalent. |
| `grep` | Answer is TODO count `4`. | Answer is `4`. | Equivalent. |
| `rename_commit` | Parent commit message is corrected to `First commit`. | No `coommit` remains and `First commit` exists; the in-app rebase editor uses the subject text on a `reword` line as the replacement message. | Equivalent outcome with a single mobile editor step. |
@@ -124,7 +124,7 @@ This file records the upstream Ruby setup and validation intent beside the Andro
| `revert` | More than three commits and a revert of "Bad commit" exists. | A commit message starts with `Revert`. | Slightly looser; sufficient for current fixture. |
| `restore` | `file3` exists. | `file3` is tracked. | Equivalent. |
| `conflict` | On `master`, merge commit has two parents, conflict markers removed, both poem lines preserved. | Requires the latest commit on `master` to be a two-parent merge commit, conflict markers removed, and the correct `Sat on a wall` poem line preserved. | Equivalent. |
| `submodule` | `githug-include-me` directory exists, has README, and is a gitlink/submodule. | `submodules` contains `githug-include-me` URL. | Equivalent state projection. |
| `submodule` | `githug-include-me` directory exists, has README, and is a gitlink/submodule. | Parses `.gitmodules` with Git config and requires tracked `.gitmodules` metadata for `githug-include-me`. | State-based Android approximation with an offline local source repository; no command text is accepted as proof. |
## Focused Source-To-Android Checks
@@ -134,7 +134,7 @@ This file records the upstream Ruby setup and validation intent beside the Andro
| --- | --- |
| Counts local branches with `repo.branches.size`. | Uses `repo.branches.size`. |
| Counts `.git/FETCH_HEAD` lines after fetch; success requires `num_remote == 2`. | `GitRuntime` now reads `.git/FETCH_HEAD` into `RepoState.fetchHeadCount`; success requires `fetchHeadCount == 2`. |
| Success requires exactly one local branch and two fetched heads. | Success requires exactly one local branch and two fetched heads. Android also rejects a recorded `pull` action to preserve the exercise instruction "without merging" under native Git behavior. |
| Success requires exactly one local branch and two fetched heads. | Success requires exactly one local branch, fetched `origin/new_branch`, two fetched heads, and no merged `file1` worktree result. |
### `status`
@@ -158,6 +158,7 @@ These are the remaining known non-parity items that need additional model suppor
- `stage_lines`: model partial staged vs unstaged hunks.
- `merge_squash`: verify the exact squashed file/content effects.
- `rebase_onto`: verify final commit count/content and removal of "Wrong changes".
- `submodule`: packaged Git currently lacks the `git submodule` porcelain, so Android validates tracked `.gitmodules` metadata but not a real gitlink checkout.
- `clone`, `clone_to_folder`: current Android behavior intentionally avoids real network-dependent validation.
The upstream `contribute` call to action is intentionally not implemented as a level because it asks learners to contribute to the original GitHug repository rather than teaching or validating a Git operation.