Skip to content

Commit

Permalink
git_utils: fix push_refspecs result check (#381)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmrowla authored Aug 11, 2023
1 parent b2fa9dd commit 7663159
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gto/git_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def git_push_tag(
msg=f"The command `git push {remote_name} {tag_name}` failed. "
f"Make sure your local repository is in sync with the remote."
) from e
for _ref, status in result:
for _ref, status in result.items():
if status == SyncStatus.DIVERGED:
raise GTOException(
msg=f"The command `git push {remote_name} {tag_name}` failed. "
Expand Down
8 changes: 7 additions & 1 deletion tests/test_git_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest
from pytest_test_utils import TmpDir
from scmrepo.exceptions import SCMError
from scmrepo.git import Git
from scmrepo.git import Git, SyncStatus

from gto.exceptions import GTOException
from gto.git_utils import git_add_and_commit_all_changes, git_push_tag
Expand All @@ -19,6 +19,9 @@ def _mocked_scm() -> MagicMock:

def test_git_push_tag(mocked_scm):
tag_name = "test_tag"
mocked_scm.push_refspecs = MagicMock(
return_value={f"refs/tag/{tag_name}": SyncStatus.SUCCESS}
)
git_push_tag(mocked_scm, tag_name=tag_name)
mocked_scm.push_refspecs.assert_called_once_with(
"origin", "refs/tags/test_tag:refs/tags/test_tag"
Expand All @@ -27,6 +30,9 @@ def test_git_push_tag(mocked_scm):

def test_git_push_tag_with_delete(mocked_scm):
tag_name = "test_tag"
mocked_scm.push_refspecs = MagicMock(
return_value={f"refs/tag/{tag_name}": SyncStatus.SUCCESS}
)
git_push_tag(mocked_scm, tag_name=tag_name, delete=True)
mocked_scm.push_refspecs.assert_called_once_with("origin", ":refs/tags/test_tag")

Expand Down

0 comments on commit 7663159

Please sign in to comment.