diff options
| -rw-r--r-- | meta/lib/oe/patch.py | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py index 2bf501e9e6..c25d3c7a0f 100644 --- a/meta/lib/oe/patch.py +++ b/meta/lib/oe/patch.py | |||
| @@ -383,14 +383,15 @@ class GitApplyTree(PatchTree): | |||
| 383 | reporoot = (runcmd("git rev-parse --show-toplevel".split(), self.dir) or '').strip() | 383 | reporoot = (runcmd("git rev-parse --show-toplevel".split(), self.dir) or '').strip() |
| 384 | if not reporoot: | 384 | if not reporoot: |
| 385 | raise Exception("Cannot get repository root for directory %s" % self.dir) | 385 | raise Exception("Cannot get repository root for directory %s" % self.dir) |
| 386 | commithook = os.path.join(reporoot, '.git', 'hooks', 'commit-msg') | 386 | hooks_dir = os.path.join(reporoot, '.git', 'hooks') |
| 387 | commithook_backup = commithook + '.devtool-orig' | 387 | hooks_dir_backup = hooks_dir + '.devtool-orig' |
| 388 | applyhook = os.path.join(reporoot, '.git', 'hooks', 'applypatch-msg') | 388 | if os.path.lexists(hooks_dir_backup): |
| 389 | applyhook_backup = applyhook + '.devtool-orig' | 389 | raise Exception("Git hooks backup directory already exists: %s" % hooks_dir_backup) |
| 390 | if os.path.exists(commithook): | 390 | if os.path.lexists(hooks_dir): |
| 391 | shutil.move(commithook, commithook_backup) | 391 | shutil.move(hooks_dir, hooks_dir_backup) |
| 392 | if os.path.exists(applyhook): | 392 | os.mkdir(hooks_dir) |
| 393 | shutil.move(applyhook, applyhook_backup) | 393 | commithook = os.path.join(hooks_dir, 'commit-msg') |
| 394 | applyhook = os.path.join(hooks_dir, 'applypatch-msg') | ||
| 394 | with open(commithook, 'w') as f: | 395 | with open(commithook, 'w') as f: |
| 395 | # NOTE: the formatting here is significant; if you change it you'll also need to | 396 | # NOTE: the formatting here is significant; if you change it you'll also need to |
| 396 | # change other places which read it back | 397 | # change other places which read it back |
| @@ -439,12 +440,9 @@ class GitApplyTree(PatchTree): | |||
| 439 | os.remove(tmpfile) | 440 | os.remove(tmpfile) |
| 440 | return output | 441 | return output |
| 441 | finally: | 442 | finally: |
| 442 | os.remove(commithook) | 443 | shutil.rmtree(hooks_dir) |
| 443 | os.remove(applyhook) | 444 | if os.path.lexists(hooks_dir_backup): |
| 444 | if os.path.exists(commithook_backup): | 445 | shutil.move(hooks_dir_backup, hooks_dir) |
| 445 | shutil.move(commithook_backup, commithook) | ||
| 446 | if os.path.exists(applyhook_backup): | ||
| 447 | shutil.move(applyhook_backup, applyhook) | ||
| 448 | 446 | ||
| 449 | 447 | ||
| 450 | class QuiltTree(PatchSet): | 448 | class QuiltTree(PatchSet): |
