Repository navigation
Resolve the fetched task base by ref #1394
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
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,16 +51,24 @@ def test_branch_refuses_detached_head(repo: Path) -> None: | |
|
|
||
|
|
||
| @pytest.mark.parametrize("branch", [None, "feature/ci+release"]) | ||
| def test_start_creates_branch_worktree_and_task_file(repo: Path, branch: str | None) -> None: | ||
| if branch: | ||
| git(repo, "push", "-q", "origin", f"HEAD:refs/heads/{branch}") | ||
| 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: | ||
| 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 = worktree._git | ||
| def interleave(path, *args, **kwargs): | ||
| result = invoke(path, *args, **kwargs) | ||
| if args[0] == "fetch": | ||
|
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: Interleave hook catches every
|
||
| git(path, "fetch", "-q", "origin", f"refs/heads/{side}") | ||
| return result | ||
|
|
||
| monkeypatch.setattr(worktree, "_git", interleave) | ||
| wt = worktree.start(repo, "my-task", "main") | ||
| assert wt == repo / ".worktrees" / "my-task" | ||
| assert (wt / "feature.txt").exists(), "fetched origin/main before branching" | ||
|
|
||
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: Fetch still overwrites the shared FETCH_HEAD
startno longer reads FETCH_HEAD, but its fetch still writes it. A user or another tool in the same checkout that runsgit fetch X && git merge FETCH_HEADcan therefore have its FETCH_HEAD replaced by loopzero's base fetch, which is the same race in the other direction.candidate.py:358already passes--no-write-fetch-head. Smallest fix: add--no-write-fetch-headto this fetch so both fetch sites behave the same way. Not blocking.