Skip to content

Commit

Permalink
#11: code now passes the test.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmnavarrol committed Mar 10, 2024
1 parent 3ae9a46 commit 9eb0f67
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/multigit/gitrepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,20 @@ def status(self, repoconf):
):
if repostatus['gitref_type'] == 'branch':
if repo.head.ref.name != repostatus['branch']:
repostatus['status'] = 'PENDING_UPDATE'
repostatus['from'] = repo.head.ref.name
repostatus['to'] = repostatus['branch']
repostatus['status'] = 'PENDING_UPDATE'
repostatus['from'] = repo.head.ref.name
repostatus['to'] = repostatus['branch']
else:
# default branch requested
pass

# find its remote name (i.e. 'origin/master')
remote_head = next(ref for ref in repo.remotes.origin.refs if '/HEAD' in ref.name).ref.name
# ...and convert to a proper local name (i.e. 'master')
default_branch = remote_head.split('/', 1)[-1]
if default_branch != repo.head.ref.name:
repostatus['status'] = 'PENDING_UPDATE'
repostatus['from'] = repo.head.ref.name
repostatus['to'] = default_branch

# Let's check its current commit vs the remote one
if repostatus['status'] == 'UNPROCESSED':
if (
Expand Down
4 changes: 4 additions & 0 deletions src/tests/gitrepo/test_remote_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ def test_different_branches_same_commit(self):

# Run multigit on default branch and see what happens
result = self.gitrepo.update(repoconf)
print(str(result))
current_branch_name = repo.head.ref.name
# Branch should return to its original value
self.assertEqual(current_branch_name, original_branch_name)

# Cleansing: delete remote branch
repo.git.push('origin', ':test_commit')

0 comments on commit 9eb0f67

Please sign in to comment.