[Asterisk-code-review] digium git: Be specific when pushing a branch (repotools[master])

Joshua Colp asteriskteam at digium.com
Fri Aug 7 10:36:50 CDT 2015


Joshua Colp has submitted this change and it was merged.

Change subject: digium_git: Be specific when pushing a branch
......................................................................


digium_git: Be specific when pushing a branch

When push changes for a branch, we need to specifically tell Git which
remote head we are updating based on our current local branch. This
patch updates the DigiumGitRepo class to track the current local branch
name, such that it can explicitly update the remote reference when
pushing.

Change-Id: I2b14956a8802b901159743c18d03cfd5e92b7cb5
---
M digium_git.py
1 file changed, 8 insertions(+), 1 deletion(-)

Approvals:
  Joshua Colp: Looks good to me, approved; Verified



diff --git a/digium_git.py b/digium_git.py
index 871284a..d2b277e 100644
--- a/digium_git.py
+++ b/digium_git.py
@@ -129,6 +129,7 @@
         """
 
         self.show_progress = show_progress
+        self.current_branch = None
         progress = None
 
         if os.path.isdir(local_path):
@@ -174,6 +175,7 @@
             local_branch = self.repo.create_head(local_name, remote_ref)
             local_branch.set_tracking_branch(remote_ref)
 
+        self.current_branch = local_name
         local_branch.checkout()
 
 
@@ -191,6 +193,7 @@
             self.repo.head.reference = local_branch
 
         assert not self.repo.head.is_detached
+        self.current_branch = name
         self.repo.head.reset(index=True, working_tree=True)
 
 
@@ -329,8 +332,12 @@
         """
         progress = None
         origin = self.repo.remotes.origin
+
         if self.show_progress:
             progress = GitProgressBar()
-        origin.push(progress=progress)
 
+        assert self.current_current_branch is not None
+        origin.push(refspec='refs/heads/{0}:refs/heads/{1}'.format(self.current_branch,
+                                                                   self.current_branch),
+                    progress=progress)
 

-- 
To view, visit https://gerrit.asterisk.org/970
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I2b14956a8802b901159743c18d03cfd5e92b7cb5
Gerrit-PatchSet: 1
Gerrit-Project: repotools
Gerrit-Branch: master
Gerrit-Owner: Matt Jordan <mjordan at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>



More information about the asterisk-code-review mailing list