Update bare repository failed .
authorLiu jue <juex.liu@intel.com>
Tue, 8 Jul 2014 08:33:59 +0000 (16:33 +0800)
committerLin Yang <lin.a.yang@intel.com>
Wed, 9 Jul 2014 06:31:25 +0000 (14:31 +0800)
1. If the remote origin url is incorrect , re-clone.
2. If the remote origin url does not exsits re-clone.

Change-Id: I35e6ff2081a96e5da84a3db7b8d6e05dd24f5676

common/git.py

index b7f1392..c53936c 100644 (file)
@@ -99,9 +99,12 @@ def _update_gitproject(localdir, gitpath=None):
     print '\nUpdating local git: %s' % localdir
     try:
         localgit = Git(localdir)
-        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))
+
+        if gitpath and ((not localgit.get_remote_repos()) \
+                or localgit.get_remote_repos().get('origin')[0] != gitpath):
+            shutil.rmtree(localdir)
+            return False
+
         if localgit.bare:
             localgit.fetch(all_remotes=True)
         else: