Skip to content

Commit 2a993ca

Browse files
committed
cmd/git(fix[set_head]): Make set_head doctest git-version-agnostic
why: git 2.54 changed `git remote set-head` output: when origin/HEAD already points at the branch it prints "'origin/HEAD' is unchanged and points to 'master'" instead of "origin/HEAD set to master". The doctest asserted the older literal string, so it failed under the git on CI. The failure is independent of the pytest 9.1 fixture changes -- it was latent until the plugin could import and the suite actually ran. what: - Assert version-stable invariants instead of the literal message: `'master' in set_head(auto=True)` and that `set_head('master')` returns a str
1 parent 5584a3e commit 2a993ca

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

src/libvcs/cmd/git.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4094,17 +4094,19 @@ def set_head(
40944094
40954095
Examples
40964096
--------
4097-
>>> GitRemoteCmd(
4097+
>>> remote = GitRemoteCmd(
40984098
... path=example_git_repo.path,
40994099
... remote_name='origin'
4100-
... ).set_head(auto=True)
4101-
'origin/HEAD set to master'
4100+
... )
41024101
4103-
>>> GitRemoteCmd(
4104-
... path=example_git_repo.path,
4105-
... remote_name='origin'
4106-
... ).set_head('master')
4107-
''
4102+
The exact message wording varies across git versions (git 2.54+ reports
4103+
"is unchanged" when HEAD already points at the branch), so assert on the
4104+
stable parts rather than the literal string:
4105+
4106+
>>> 'master' in remote.set_head(auto=True)
4107+
True
4108+
>>> isinstance(remote.set_head('master'), str)
4109+
True
41084110
"""
41094111
local_flags: list[str] = [self.remote_name]
41104112

0 commit comments

Comments
 (0)