diff options
author | Zeno Albisser <zeno.albisser@digia.com> | 2013-07-26 18:53:55 +0200 |
---|---|---|
committer | Andras Becsi <andras.becsi@digia.com> | 2013-07-28 21:59:54 +0200 |
commit | dcfabadeb3ea2fd439b013ef24c41c81780d802a (patch) | |
tree | 1e4a9f3a4d708aa3ecebfdd07b2582ca545959ed /init-repository.py | |
parent | 53906c4e3b5c4ee7093a582c7923bba5a377c3a3 (diff) |
Make init-repository.py properly reset all submodules.
With this patch init-repository.py will also abort uncommited
git am/merge/rebase sessions and it will do a git reset --hard
on every submodule.
We are no longer executing a 'git submodule update --recursive'
in the patch-chromium.sh script, since init-repository.py
takes care of checking out the proper revisions.
Change-Id: I6cc50944d888ffce5e3d282500dffe3daffecdf4
Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'init-repository.py')
-rwxr-xr-x | init-repository.py | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/init-repository.py b/init-repository.py index 529c56910..050fc4a21 100755 --- a/init-repository.py +++ b/init-repository.py @@ -90,8 +90,32 @@ class Submodule: line = line.lstrip(' -') self.shasum = line.split(' ')[0] + def findGitDir(self): + try: + return subprocess.check_output(['git', 'rev-parse', '--git-dir']).strip() + except subprocess.CalledProcessError, e: + sys.exit("git dir could not be determined! - Initialization failed!" + e.output) + + def reset(self): + currentDir = os.getcwd() + os.chdir(self.path) + gitdir = self.findGitDir() + if os.path.isdir(os.path.join(gitdir, 'rebase-merge')): + if os.path.isfile(os.path.join(gitdir, 'MERGE_HEAD')): + print 'merge in progress... aborting merge.' + subprocess.call(['git', 'merge', '--abort']) + else: + print 'rebase in progress... aborting merge.' + subprocess.call(['git', 'rebase', '--abort']) + if os.path.isdir(os.path.join(gitdir, 'rebase-apply')): + print 'am in progress... aborting am.' + subprocess.call(['git', 'am', '--abort']) + subprocess.call(['git', 'reset', '--hard']) + os.chdir(currentDir) + def initialize(self): if self.matchesOS(): + self.reset() print '-- initializing ' + self.path + ' --' subprocess.call(['git', 'submodule', 'init', self.path]) subprocess.call(['git', 'submodule', 'update', self.path]) @@ -100,7 +124,9 @@ class Submodule: os.chdir(self.path) # Make sure we have checked out the right shasum. # In case there were other patches applied before. - subprocess.call(['git', 'checkout', self.shasum]) + val = subprocess.call(['git', 'checkout', self.shasum]) + if val != 0: + sys.exit("!!! initialization failed !!!") initSubmodules() os.chdir(currentDir) else: |