Repository navigation
Resolve the task base in one Git fetch #1963
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f021e20
8f436cf
faf90bd
3684a7d
ba6d734
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,27 +51,29 @@ def test_branch_reads_valid_names_and_rejects_detached_head(repo: Path, slug: st | |
| worktree.branch(repo) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("branch", [None, "feature/ci+release", "symbolic"]) | ||
| @pytest.mark.parametrize("branch", [None, "feature/ci+release", "symbolic", "legacy"]) | ||
| def test_start_creates_branch_worktree_and_task_file(repo: Path, branch: str | None, monkeypatch) -> None: | ||
| side = branch or "side" | ||
| git(repo, "push", "-q", "origin", f"HEAD:refs/heads/{side}") | ||
| upstream = commit_on_origin(repo, "feature.txt") | ||
| if branch == "symbolic": | ||
| git(repo, "symbolic-ref", "refs/remotes/origin/main", "refs/heads/main") | ||
| elif branch: | ||
| elif branch and branch != "legacy": | ||
| checkout = repo.parent / "single-branch" | ||
| origin = (repo.parent / "origin.git").as_uri() | ||
| git(repo, "clone", "-q", "--single-branch", "--branch", branch, origin, str(checkout)) | ||
| assert not git(checkout, "for-each-ref", "refs/heads/main", "refs/remotes/origin/main").strip() | ||
| repo = checkout | ||
| invoke, local_head = worktree._git, worktree.head(repo) | ||
| def interleave(path, *args, **kwargs): | ||
| result = invoke(path, *args, **kwargs) | ||
| if args[0] == "fetch": | ||
| git(path, "fetch", "-q", "origin", f"refs/heads/{side}") | ||
| invoke, local_head = worktree.run, worktree.head(repo) | ||
| def interleave(argv, **kwargs): | ||
| if branch == "legacy" and argv[:3] == ("git", "fetch", "--porcelain"): | ||
| return invoke(("git", "fetch", "--loopzero-unsupported"), **kwargs) | ||
| result = invoke(argv, **kwargs) | ||
| if argv[1] == "fetch" and result.exit_code == 0: | ||
| git(kwargs["cwd"], "fetch", "-q", "origin", f"refs/heads/{side}") | ||
| return result | ||
|
|
||
| monkeypatch.setattr(worktree, "_git", interleave) | ||
| monkeypatch.setattr(worktree, "run", interleave) | ||
| wt = worktree.start(repo, "my-task", "main") | ||
| assert wt == repo / ".worktrees" / "my-task" | ||
| assert (wt / "feature.txt").exists(), "fetched origin/main before branching" | ||
|
|
@@ -200,7 +202,8 @@ def test_start_explains_missing_origin(repo: Path, change: tuple[str, ...]) -> N | |
| def test_start_reports_git_failure_with_command(repo: Path) -> None: | ||
| with pytest.raises(worktree.GitError) as info: | ||
| worktree.start(repo, "nobase", "does-not-exist") | ||
| assert info.value.command[:2] == ("git", "ls-remote") | ||
| assert info.value.command[0] == "git" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Failure-command assertion was loosened to accept either path
|
||
| assert info.value.command[1] in {"fetch", "ls-remote"} | ||
| assert info.value.tail | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: No tests for the initialized-submodule and invalid-ref-name fallbacks
The acceptance criteria say three cases must keep using the existing ls-remote + exact-SHA fetch path: initialized submodules, invalid base ref names and symbolic tracking refs. The parametrized test covers symbolic tracking refs and the legacy-Git 129 fallback, but nothing exercises
modules.exists()(the point of commit 3684a7d) or acheck-ref-formatfailure. A later refactor could drop either guard without any test failing. Smallest fix: add asubmodulecase that creates$(git rev-parse --git-path modules)beforestart, and assert through the existingrunmonkeypatch that nogit fetch --porcelaincall was made and thatls-remoteran. Optionally, add a case that passes a base namecheck-ref-formatrejects and assert the command reported in theGitErrorisls-remote.