devtool: standard: throws appropriate error if source is in detached HEAD
PATCH 1/1 devtool: standard: throws appropriate error if source is in detached HEAD
If source is in detached HEAD, we get the following error when using detvool finish command:
[...]
File "<...>/poky/scripts/lib/devtool/standard.py", line 1938, in _update_recipe
bb.process.run('git checkout %s' % startbranch, cwd=srctree)
File "<...>/poky/bitbake/lib/bb/process.py", line 189, in run
raise ExecutionError(cmd, pipe.returncode, stdout, stderr) bb.process.ExecutionError: Execution of 'git checkout (HEAD detached at 9bbf87e)' failed with exit code 2:
/bin/sh: -c: line 1: syntax error near unexpected token `('
/bin/sh: -c: line 1: `git checkout (HEAD detached at 9bbf87e)'
Check this and throws an appropriate error in this case
--- scripts/lib/devtool/standard.py | 2 ++ 1 file changed, 2 insertions(+)
scripts/lib/devtool/standard.py +2 -0
@@ -1885,6 +1885,8 @@ def _update_recipe(recipename, workspace, rd, mode, appendlayerdir, wildcard_ver for line in stdout.splitlines(): branchname = line[2:] if line.startswith('* '): + if 'HEAD' in line: + raise DevtoolError('Detached HEAD - please check out the main branch in source tree first') startbranch = branchname if branchname.startswith(override_branch_prefix): override_branches.append(branchname)
Signature · 1 line
2.44.0
Quoted 32 lines
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Julien Stephan
Sent: den 9 april 2024 09:19
To: [email protected]
Cc: Julien Stephan <[email protected]>
Subject: [OE-core] [PATCH] devtool: standard: throws appropriate error if source is in detached HEADIf source is in detached HEAD, we get the following error when using detvool finish command:
[...] File "<...>/poky/scripts/lib/devtool/standard.py", line 1938, in _update_recipe bb.process.run('git checkout %s' % startbranch, cwd=srctree) File "<...>/poky/bitbake/lib/bb/process.py", line 189, in run raise ExecutionError(cmd, pipe.returncode, stdout, stderr)bb.process.ExecutionError: Execution of 'git checkout (HEAD detached at 9bbf87e)' failed with exit code 2:
/bin/sh: -c: line 1: syntax error near unexpected token `('
/bin/sh: -c: line 1: `git checkout (HEAD detached at 9bbf87e)'Check this and throws an appropriate error in this case
Signed-off-by Julien Stephan <[email protected]>--- scripts/lib/devtool/standard.py | 2 ++ 1 file changed, 2 insertions(+)scripts/lib/devtool/standard.py +0
-0
scripts/lib/devtool/standard.py def _update_recipe(recipename, workspace, rd, mode, appendlayerdir, wildcard_ver · line 1889
Quoted 5 lines
scripts/lib/devtool/standard.py +2
-0@@ -1885,6 +1885,8 @@ def _update_recipe(recipename, workspace, rd, mode, appendlayerdir, wildcard_ver for line in stdout.splitlines(): branchname = line[2:] if line.startswith('* '): + if 'HEAD' in line: + raise DevtoolError('Detached HEAD - please check out the main branch in source tree first')
Using "main branch" here might lead to confusion since it is unclear if the error is referring to an actual "main" branch, which not all repositories have, or to whatever branch is primarily used. Additionally, when using devtool, the branch is typically "devtool".
I would change it to:
raise DevtoolError('Detached HEAD - please check out a branch, e.g., "devtool"')
Quoted 5 lines
scripts/lib/devtool/standard.py +0
-1startbranch = branchname if branchname.startswith(override_branch_prefix): override_branches.append(branchname) --2.44.0
//Peter
Quoted 27 lines · Peter Kjellerstedt
Quoted 27 lines
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Julien Stephan
Sent: den 9 april 2024 09:19
To: [email protected]
Cc: Julien Stephan <[email protected]>
Subject: [OE-core] [PATCH] devtool: standard: throws appropriate error if source is in detached HEADIf source is in detached HEAD, we get the following error when using detvool finish command:
[...] File "<...>/poky/scripts/lib/devtool/standard.py", line 1938, in _update_recipe bb.process.run('git checkout %s' % startbranch, cwd=srctree) File "<...>/poky/bitbake/lib/bb/process.py", line 189, in run raise ExecutionError(cmd, pipe.returncode, stdout, stderr)bb.process.ExecutionError: Execution of 'git checkout (HEAD detached at 9bbf87e)' failed with exit code 2:
/bin/sh: -c: line 1: syntax error near unexpected token `('
/bin/sh: -c: line 1: `git checkout (HEAD detached at 9bbf87e)'Check this and throws an appropriate error in this case
Signed-off-by Julien Stephan <[email protected]>--- scripts/lib/devtool/standard.py | 2 ++ 1 file changed, 2 insertions(+)
Quoted 15 lines
scripts/lib/devtool/standard.py def _update_recipe(recipename, workspace, rd, mode, appendlayerdir, wildcard_ver · line 1889
Quoted 11 lines
scripts/lib/devtool/standard.py +2
-0@@ -1885,6 +1885,8 @@ def _update_recipe(recipename, workspace, rd, mode, appendlayerdir, wildcard_ver for line in stdout.splitlines(): branchname = line[2:] if line.startswith('* '): + if 'HEAD' in line: + raise DevtoolError('Detached HEAD - please check out the main branch in source tree first')Using "main branch" here might lead to confusion since it is unclear if the error is referring to an actual "main" branch, which not all repositories have, or to whatever branch is primarily used.
Hi Peter,
I used the same error message as the one already existing a few lines below. To be honest I read it as "the primary branch" not "the branch named main" but I understand it can be confusing.
Quoted 5 lines
Additionally, when using devtool, the branch is typically "devtool".
I would change it to:
raise
DevtoolError('Detached HEAD - please check out a branch, e.g., "devtool"')
makes sense, let me send a v2.
Thank you!
Quoted 9 lines
Quoted 6 lines
scripts/lib/devtool/standard.py +0
-1startbranch = branchname if branchname.startswith(override_branch_prefix): override_branches.append(branchname) --2.44.0
//Peter