summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/oe/patch.py26
1 files changed, 12 insertions, 14 deletions
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
index 2255ce437b..4e77168dab 100644
--- a/meta/lib/oe/patch.py
+++ b/meta/lib/oe/patch.py
@@ -411,14 +411,15 @@ class GitApplyTree(PatchTree):
411 reporoot = (runcmd("git rev-parse --show-toplevel".split(), self.dir) or '').strip() 411 reporoot = (runcmd("git rev-parse --show-toplevel".split(), self.dir) or '').strip()
412 if not reporoot: 412 if not reporoot:
413 raise Exception("Cannot get repository root for directory %s" % self.dir) 413 raise Exception("Cannot get repository root for directory %s" % self.dir)
414 commithook = os.path.join(reporoot, '.git', 'hooks', 'commit-msg') 414 hooks_dir = os.path.join(reporoot, '.git', 'hooks')
415 commithook_backup = commithook + '.devtool-orig' 415 hooks_dir_backup = hooks_dir + '.devtool-orig'
416 applyhook = os.path.join(reporoot, '.git', 'hooks', 'applypatch-msg') 416 if os.path.lexists(hooks_dir_backup):
417 applyhook_backup = applyhook + '.devtool-orig' 417 raise Exception("Git hooks backup directory already exists: %s" % hooks_dir_backup)
418 if os.path.exists(commithook): 418 if os.path.lexists(hooks_dir):
419 shutil.move(commithook, commithook_backup) 419 shutil.move(hooks_dir, hooks_dir_backup)
420 if os.path.exists(applyhook): 420 os.mkdir(hooks_dir)
421 shutil.move(applyhook, applyhook_backup) 421 commithook = os.path.join(hooks_dir, 'commit-msg')
422 applyhook = os.path.join(hooks_dir, 'applypatch-msg')
422 with open(commithook, 'w') as f: 423 with open(commithook, 'w') as f:
423 # NOTE: the formatting here is significant; if you change it you'll also need to 424 # NOTE: the formatting here is significant; if you change it you'll also need to
424 # change other places which read it back 425 # change other places which read it back
@@ -467,12 +468,9 @@ class GitApplyTree(PatchTree):
467 os.remove(tmpfile) 468 os.remove(tmpfile)
468 return output 469 return output
469 finally: 470 finally:
470 os.remove(commithook) 471 shutil.rmtree(hooks_dir)
471 os.remove(applyhook) 472 if os.path.lexists(hooks_dir_backup):
472 if os.path.exists(commithook_backup): 473 shutil.move(hooks_dir_backup, hooks_dir)
473 shutil.move(commithook_backup, commithook)
474 if os.path.exists(applyhook_backup):
475 shutil.move(applyhook_backup, applyhook)
476 474
477 475
478class QuiltTree(PatchSet): 476class QuiltTree(PatchSet):