devtool: standard: throws appropriate error if source is in detached HEAD
PATCH v2 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
---
Changes in v2:
- update error message to avoid confusion with a potentially non existing "main" branch
--- scripts/lib/devtool/standard.py | 2 ++ 1 file changed, 2 insertions(+)
scripts/lib/devtool/standard.py +2 -0
@@ -1888,6 +1888,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 a branch, e.g., "devtool"') startbranch = branchname if branchname.startswith(override_branch_prefix): override_branches.append(branchname)
Signature · 1 line
2.44.0
Quoted 21 lines
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Julien Stephan
Sent: den 10 april 2024 09:07
To: [email protected]
Cc: Julien Stephan <[email protected]>
Subject: [OE-core] [PATCH v2] 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
Quoted 8 lines
Signed-off-by Julien Stephan <[email protected]>---
Changes in v2:
- update error message to avoid confusion with a potentially non existing "main" branch
As you noted in an earlier mail, the same error message is used some lines later. Please change that one too.
Quoted 20 lines
--- scripts/lib/devtool/standard.py | 2 ++ 1 file changed, 2 insertions(+)scripts/lib/devtool/standard.py +0
-0@@ -1888,6 +1888,8 @@ def _update_recipe(recipename, workspace, rd, mode,appendlayerdir,
wildcard_ver
for line instdout.splitlines():
branchname = line[2:]
ifline.startswith('* '):scripts/lib/devtool/standard.py +2
-1+ if 'HEAD' in line: + raise DevtoolError('Detached HEAD - please check out a branch, e.g., "devtool"') startbranch = branchname if branchname.startswith(override_branch_prefix): override_branches.append(branchname) --
Quoted 1 line
2.44.0
//Peter
Quoted 26 lines · Peter Kjellerstedt
Quoted 26 lines
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Julien Stephan
Sent: den 10 april 2024 09:07
To: [email protected]
Cc: Julien Stephan <[email protected]>
Subject: [OE-core] [PATCH v2] 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]>---
Quoted 8 lines
Quoted 4 lines
Changes in v2:
- update error message to avoid confusion with a potentially non existing "main" branch
As you noted in an earlier mail, the same error message is used some lines later. Please change that one too.
Hi Peter,
Not sure we need to change the other error message, because in that case it really means the *main* branch.
This error message happens if we have overrides branches and if the currently checked out branch starts with "devtool-override" (and we have several other branches).
In that case, devtool cannot determine the main branch (read it as the "base" branch on which the devtool-overrides-* branches are rebased). Most of the time it will be the "devtool" branch, but there is no guarantee, the user can checkout a working branch for example.
Furthermore, there is also another log message few lines after :
logger.info('Handling main branch (%s)...' % mainbranch)
So IMHO the log messages look fine here. Maybe we can rewrite them using "base" branch such as (but not sure it will be more clear) :
raise DevtoolError('Unable to determine base branch - please check
out the base branch in source tree first')
and
logger.info('Handling base branch (%s)...' % mainbranch)
(do you also want to rename the mainbranch variable?)
Anyway, such changes have nothing to do with the Detached HEAD check, so I will not add this within the same commit.
I can do another patch to respell main to base (or something else more meaningful?) if you think it would be beneficial for clarity (or you can do it if you prefer).
Let me know
Cheers
Julien
Quoted 24 lines
Quoted 20 lines
--- scripts/lib/devtool/standard.py | 2 ++ 1 file changed, 2 insertions(+)scripts/lib/devtool/standard.py +0
-0@@ -1888,6 +1888,8 @@ def _update_recipe(recipename, workspace, rd, mode,appendlayerdir,
wildcard_ver
for line instdout.splitlines():
branchname = line[2:]
ifline.startswith('* '):scripts/lib/devtool/standard.py +2
-1+ if 'HEAD' in line: + raise DevtoolError('Detached HEAD - please check out a branch, e.g., "devtool"') startbranch = branchname if branchname.startswith(override_branch_prefix): override_branches.append(branchname) --Quoted 1 line
2.44.0
//Peter
Quoted 39 lines
-----Original Message-----
From: Julien Stephan <[email protected]>
Sent: den 11 april 2024 16:20
To: Peter Kjellerstedt <[email protected]>
Cc: [email protected]
Subject: Re: [OE-core] [PATCH v2] devtool: standard: throws appropriate error if source is in detached HEADQuoted 31 lines · Peter Kjellerstedt
Quoted 30 lines
-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Julien Stephan
Sent: den 10 april 2024 09:07
To: [email protected]
Cc: Julien Stephan <[email protected]>
Subject: [OE-core] [PATCH v2] 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]>---
Changes in v2:
- update error message to avoid confusion with a potentially non existing "main" branch
Quoted 7 lines
Quoted 3 lines
As you noted in an earlier mail, the same error message is used some lines later. Please change that one too.
Hi Peter,
Not sure we need to change the other error message, because in that case it really means the *main* branch.
Actually, all that code predates the recent idea of renaming master to main so the use of "main branch" here refers to a "base" branch.
Quoted 14 lines
This error message happens if we have overrides branches and if the currently checked out branch starts with "devtool-override" (and we have several other branches).
In that case, devtool cannot determine the main branch (read it as the "base" branch on which the devtool-overrides-* branches are rebased). Most of the time it will be the "devtool" branch, but there is no guarantee, the user can checkout a working branch for example.Furthermore, there is also another log message few lines after :
logger.info('Handling main branch (%s)...' % mainbranch)So IMHO the log messages look fine here. Maybe we can rewrite them using "base" branch such as (but not sure it will be more clear) :
Quoted 8 lines
raise DevtoolError('Unable to determine base branch - please check
out the base branch in source tree first')and
logger.info('Handling base branch (%s)...' % mainbranch)(do you also want to rename the mainbranch variable?)
If we change this, it should definitely be changed as well.
Quoted 3 lines
Anyway, such changes have nothing to do with the Detached HEAD check, so I will not add this within the same commit.
I agree. If it had just been a matter of aligning the two error messages, then I think it would have been fine to do it, but not if it involves more significant changes.
Quoted 2 lines
I can do another patch to respell main to base (or something else more meaningful?) if you think it would be beneficial for clarity
I think using "base branch" rather than "main branch" would be a lot less confusing.
Quoted 1 line
(or you can do it if you prefer).
Please do send a patch for it.
Quoted 4 lines
Let me know
Cheers
Julien
//Peter
Quoted 21 lines
Quoted 21 lines
Quoted 18 lines
--- scripts/lib/devtool/standard.py | 2 ++ 1 file changed, 2 insertions(+)scripts/lib/devtool/standard.py +2
-1@@ -1888,6 +1888,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 a branch, e.g., "devtool"') startbranch = branchname if branchname.startswith(override_branch_prefix): override_branches.append(branchname) --Quoted 1 line
2.44.0
//Peter