gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kkoli...@apache.org
Subject svn commit: r1740222 - /gump/live/python/gump/core/update/git.py
Date Thu, 21 Apr 2016 01:36:44 GMT
Author: kkolinko
Date: Thu Apr 21 01:36:44 2016
New Revision: 1740222

URL: http://svn.apache.org/viewvc?rev=1740222&view=rev
Log:
Use 'git fetch' with an explicit refspec to update remote branch, instead of 'git pull'.
The local branch is updated by 'git reset --hard' that is executed later.

'git reset --hard' reverts any uncommitted changes and makes sure that local branch is always
identical to remote one.

Modified:
    gump/live/python/gump/core/update/git.py

Modified: gump/live/python/gump/core/update/git.py
URL: http://svn.apache.org/viewvc/gump/live/python/gump/core/update/git.py?rev=1740222&r1=1740221&r2=1740222&view=diff
==============================================================================
--- gump/live/python/gump/core/update/git.py (original)
+++ gump/live/python/gump/core/update/git.py Thu Apr 21 01:36:44 2016
@@ -60,15 +60,23 @@ class GitUpdater(ScmUpdater):
 
     def getUpdateCommand(self, module):
         """
-            Build the appropriate GIT command for pull
+            Build the appropriate GIT fetch command that pulls changes
+            from remote repository.
+            This command updates origin/branchName. The local branch is
+            updated by 'git reset --hard' that is executed later.
         """
         log_repository_and_url(module, 'git')
+
+        refspec = '+refs/heads/' + module.getScm().getBranch() +
+                  ':refs/remotes/origin/' + module.getScm().getBranch()
+
         cmd = Cmd('git', 'update_' + module.getName(), 
                   module.getSourceControlStagingDirectory())
-        cmd.addParameter('pull')
+        cmd.addParameter('fetch')
         maybe_make_quiet(module, cmd)
-        cmd.addParameter(module.getScm().getRootUrl())
-        cmd.addParameter(module.getScm().getBranch())
+        cmd.addParameter('--no-tags')
+        cmd.addParameter('origin')
+        cmd.addParameter(refspec)
         return cmd
 
     def workspaceMatchesModule(self, module):
@@ -98,26 +106,25 @@ class GitUpdater(ScmUpdater):
 
     def getPostProcessCommands(self, module, isUpdate):
         """
-        Run git submodule update --init and git reset --hard if this
+        Run git reset --hard and git submodule update --init if this
         has been an update.
         If it has been a clone command just before, its recursive flag
         will already have taken care of everything.
         """
         if isUpdate:
+            rst = Cmd('git', 'reset_hard_' + module.getName(), 
+                      module.getSourceControlStagingDirectory())
+            rst.addParameter('reset')
+            rst.addParameter('--hard')
+            maybe_make_quiet(module, rst)
+            rst.addParameter('origin/' + module.getScm().getBranch())
+
             subs = Cmd('git', 'submodule_update_' + module.getName(), 
                       module.getSourceControlStagingDirectory())
             subs.addParameter('submodule')
+            maybe_make_quiet(module, subs)
             subs.addParameter('update')
             subs.addParameter('--init')
             subs.addParameter('--recursive')
-            maybe_make_quiet(module, subs)
-
-            # git reset --hard so changed .gitattributes are applied
-            rst = Cmd('git', 'reset_hard_' + module.getName(), 
-                      module.getSourceControlStagingDirectory())
-            rst.addParameter('reset')
-            rst.addParameter('--hard')
-            rst.addParameter('origin/' + module.getScm().getBranch())
-            maybe_make_quiet(module, rst)
             return [rst, subs]
         return []



Mime
View raw message