Message ID | 20220208035000.400632-1-bkylerussell@gmail.com |
---|---|
State | New |
Headers | show |
Series | [1/2] devtool: get hooks directory path from git rev-parse | expand |
Hi, <bkylerussell@gmail.com> escreveu no dia terça, 8/02/2022 à(s) 03:50: > 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: your@mail > --- > meta/lib/oe/patch.py | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py > index 950fe723dc..976a966083 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()) > This assumes that the git will run inside the self.dir but this is not guaranteed so adding self.dir to the runcmd is safer. > 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) > -- > 2.25.1 > > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#161473): > https://lists.openembedded.org/g/openembedded-core/message/161473 > Mute This Topic: https://lists.openembedded.org/mt/88989924/5052612 > Group Owner: openembedded-core+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ > quaresma.jose@gmail.com] > -=-=-=-=-=-=-=-=-=-=-=- > >
Ok, I see. I didn't realize I dropped that from the original line. Thanks for the catch. On Tue, Feb 8, 2022 at 5:30 AM Jose Quaresma <quaresma.jose@gmail.com> wrote: > Hi, > > <bkylerussell@gmail.com> escreveu no dia terça, 8/02/2022 à(s) 03:50: > >> 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: your@mail > > >> --- >> meta/lib/oe/patch.py | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py >> index 950fe723dc..976a966083 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()) >> > > This assumes that the git will run inside the self.dir but this is not > guaranteed so adding self.dir to the runcmd is safer. > > >> 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) >> -- >> 2.25.1 >> >> >> -=-=-=-=-=-=-=-=-=-=-=- >> Links: You receive all messages sent to this group. >> View/Reply Online (#161473): >> https://lists.openembedded.org/g/openembedded-core/message/161473 >> Mute This Topic: https://lists.openembedded.org/mt/88989924/5052612 >> Group Owner: openembedded-core+owner@lists.openembedded.org >> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ >> quaresma.jose@gmail.com] >> -=-=-=-=-=-=-=-=-=-=-=- >> >> > > -- > Best regards, > > José Quaresma >
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py index 950fe723dc..976a966083 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()) 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)