aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouis Chauvet <louis.chauvet@bootlin.com>2024-04-09 11:15:56 +0200
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2024-04-09 13:05:15 -0400
commit3b691d28df6954e8fac742365a08c496f36a3738 (patch)
treee70a7035f36a4ef995a235542c372bc395b7d62d
parentcfcbbe6f23943166f11687ecf37252dc20728639 (diff)
downloadb4-3b691d28df6954e8fac742365a08c496f36a3738.tar.gz
ez: Add a check before returning a commit
B4 prep utility only works when a branch is checked out. To avoid misterious errors at runtime, add a check and a runtime error with an explicit message when the current branch can't be found. Cc: thomas.petazzoni@bootlin.com Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com> Link: https://msgid.link/20240409-check_if_branch_exists-v1-1-136504ad81c2@bootlin.com Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r--src/b4/ez.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/b4/ez.py b/src/b4/ez.py
index eeea020..a2ed1aa 100644
--- a/src/b4/ez.py
+++ b/src/b4/ez.py
@@ -732,6 +732,10 @@ def find_cover_commit(usebranch: Optional[str] = None) -> Optional[str]:
logger.debug('Looking for the cover letter commit with magic marker "%s"', MAGIC_MARKER)
if not usebranch:
usebranch = b4.git_get_current_branch()
+ if usebranch is None:
+ logger.critical("The current repository is not tracking a branch. To use b4, please checkout a branch.")
+ logger.critical("Maybe a rebase is running?")
+ raise RuntimeError("Not currently on a branch, please checkout a b4-tracked branch")
gitargs = ['log', '--grep', MAGIC_MARKER, '-F', '--pretty=oneline', '--max-count=1', '--since=1.year',
usebranch]
lines = b4.git_get_command_lines(None, gitargs)