Skip to content

Commit 60af69f

Browse files
committed
git_utils: Fix '--force' option
1 parent 62f5aa4 commit 60af69f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/mbed_tools/project/_internal/git_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def checkout(repo: git.Repo, ref: str, force: bool = False) -> None:
5555
VersionControlError: Check out failed.
5656
"""
5757
try:
58-
repo.git.checkout(f"--force {ref}" if force else str(ref))
58+
repo.git.checkout(ref, "--force" if force else "")
5959
except git.exc.GitCommandError as err:
6060
raise VersionControlError(f"Failed to check out revision '{ref}'. Error from VCS: {err}")
6161

tests/project/_internal/test_git_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class TestCheckout:
8686
def test_git_lib_called_with_correct_command(self, mock_repo):
8787
git_utils.checkout(mock_repo, "master", force=True)
8888

89-
mock_repo.git.checkout.assert_called_once_with("--force master")
89+
mock_repo.git.checkout.assert_called_once_with("master", "--force")
9090

9191
def test_raises_version_control_error_when_git_checkout_fails(self, mock_repo):
9292
mock_repo.git.checkout.side_effect = git_utils.git.exc.GitCommandError("git checkout", 255)

0 commit comments

Comments
 (0)