devtool: get hooks directory path from git rev-parse
PATCH 1/2 devtool: get hooks directory path from git rev-parse
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.
--- meta/lib/oe/patch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/lib/oe/patch.py +1 -1
@@ -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)
Signature · 1 line
2.25.1
PATCH 2/2 devtool: don't exec patch commit task funcs for git submodules
When applying a patch directly to a submodule, devtool doesn't need to generate commits for updated submodule revisions, which may differ each time a patch is applied to a devtool workspace. (submodule revision commits would be effectively useless unless the patch is pushed to a remote repo from devtool, at which time a commit should be generated by the user anyway.)
Additionally, attempting to commit new submodule revisions in the parent repo may error with "no changes added to commit" if the patched module is nested within multiple submodules below the parent repo. (Devtool doesn't and shouldn't recusively create commits on each submodule.)
--- scripts/lib/devtool/standard.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/lib/devtool/standard.py +2 -1
@@ -569,7 +569,8 @@ def _extract_source(srctree, keep_temp, devbranch, sync, config, basepath, works f.write('DEVTOOL_DEVBRANCH = "%s"\n' % devbranch) if not is_kernel_yocto: f.write('PATCHTOOL = "git"\n') - f.write('PATCH_COMMIT_FUNCTIONS = "1"\n') + if not 'gitsm' in d.getVar('SRC_URI'): + f.write('PATCH_COMMIT_FUNCTIONS = "1"\n') if extra_overrides: f.write('DEVTOOL_EXTRA_OVERRIDES = "%s"\n' % ':'.join(extra_overrides)) f.write('inherit devtool-source\n')
Signature · 1 line
2.25.1
Hi,
<[email protected]> escreveu no dia terça, 8/02/2022 à(s) 03:50:
Quoted 9 lines
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
Quoted 9 lines
--- meta/lib/oe/patch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)meta/lib/oe/patch.py +0
-0
meta/lib/oe/patch.py class GitApplyTree(PatchTree): · line 516
Quoted 8 lines
meta/lib/oe/patch.py +1
-1@@ -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.
Quoted 19 lines
hooks_dir_backup=hooks_dir+ '.devtool-orig'
ifos.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: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Signature · 3 lines
Best regards, José Quaresma
Ok, I see. I didn't realize I dropped that from the original line. Thanks for the catch.
Quoted 64 lines · Jose Quaresma
Hi,
<[email protected]> escreveu no dia terça, 8/02/2022 à(s) 03:50:
Quoted 9 lines
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
Quoted 9 lines
--- meta/lib/oe/patch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)meta/lib/oe/patch.py +0
-0meta/lib/oe/patch.py class GitApplyTree(PatchTree): · line 516
Quoted 8 lines
meta/lib/oe/patch.py +1
-1@@ -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.
Quoted 8 lines
hooks_dir_backup=hooks_dir+ '.devtool-orig'
ifos.path.lexists(hooks_dir_backup):
raise Exception("Git hooks backup directory already exists:
%s" %hooks_dir_backup)
--
2.25.1Quoted 11 lines
-=-=-=-=-=-=-=-=-=-=-=-
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: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=---
Best regards,José Quaresma