Optimize updating git repo logic
authorLingchaox Xin <lingchaox.xin@intel.com>
Tue, 17 Sep 2013 05:33:49 +0000 (13:33 +0800)
committerGerrit Code Review <gerrit2@otctools.jf.intel.com>
Tue, 17 Sep 2013 08:52:58 +0000 (01:52 -0700)
Change-Id: I3ed80bba2536a008bd225ffabb0b90094209a40a

common/git.py

index fe99db7..24b2041 100644 (file)
@@ -86,12 +86,14 @@ def _update_gitproject(localdir, gitpath=None):
     print '\nUpdating local git: %s' % localdir
     try:
         localgit = Git(localdir)
-        if not localgit.bare:
-            localgit.pull(repo=gitpath, all_repos=True)
         if gitpath and localgit.get_remote_repos().get('origin')[0] != gitpath:
             os.system('git --git-dir=%s remote set-url origin %s' % ([localdir,
                 os.path.join(localdir, '.git')][localgit.bare], gitpath))
-        localgit.fetch(all_remotes=True)
+        if localgit.bare:
+            localgit.fetch(all_remotes=True)
+        else:
+            localgit.fetch(tags=True)
+            localgit.pull()
     except GitRepositoryError, gre:
         print('git execption: ', gre)
         shutil.rmtree(localdir)