[v2,1/2] devtool: get hooks directory path from git rev-parse

Message ID 20220208122500.429218-1-bkylerussell@gmail.com
State New
Headers show
Series [v2,1/2] devtool: get hooks directory path from git rev-parse | expand

Commit Message

Kyle Russell Feb. 8, 2022, 12:24 p.m. UTC
Ask git rev-parse to provide the path to the repo's hooks directory.

This allows devtool to support git submodules, where only the
superproject contains a .git directory.

git submodules contain .git files pointing to their parent repo,
which confuses devtool when it tries to modify the commit hooks by
a manually constructed path.

Signed-off-by: Kyle Russell <bkylerussell@gmail.com>
---
 meta/lib/oe/patch.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch

diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
index 950fe723dc..076018271e 100644
--- a/meta/lib/oe/patch.py
+++ b/meta/lib/oe/patch.py
@@ -510,7 +510,7 @@  class GitApplyTree(PatchTree):
         reporoot = (runcmd("git rev-parse --show-toplevel".split(), self.dir) or '').strip()
         if not reporoot:
             raise Exception("Cannot get repository root for directory %s" % self.dir)
-        hooks_dir = os.path.join(reporoot, '.git', 'hooks')
+        hooks_dir = runcmd("git rev-parse --git-path hooks".split(), self.dir)
         hooks_dir_backup = hooks_dir + '.devtool-orig'
         if os.path.lexists(hooks_dir_backup):
             raise Exception("Git hooks backup directory already exists: %s" % hooks_dir_backup)