diff mbox series

[b4,RFC,3/3] ez: prep -n: validate fork-point is a branch

Message ID 20230206-b4-prep-fork-point-as-base-branch-v1-3-2732e0c32f5d@tessares.net (mailing list archive)
State New
Headers show
Series "b4 prep --new --fork-point" is not clear to me | expand

Commit Message

Matthieu Baerts Feb. 6, 2023, 6:23 p.m. UTC
This --fork-point option is used to set the new base branch.

Make then sure it is one and not a fixed SHA.

Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 b4/ez.py | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/b4/ez.py b/b4/ez.py
index 9200d03..8d90296 100644
--- a/b4/ez.py
+++ b/b4/ez.py
@@ -330,6 +330,12 @@  def start_new_series(cmdargs: argparse.Namespace) -> None:
         else:
             basebranch = cmdargs.fork_point
 
+            gitargs = ['show-ref', '--quiet', basebranch]
+            ecode, out = b4.git_run_command(None, gitargs)
+            if ecode > 0:
+                logger.critical('CRITICAL: fork-point %s is not a branch', basebranch)
+                sys.exit(1)
+
         slug = re.sub(r'\W+', '-', cmdargs.new_series_name).strip('-').lower()
         branchname = 'b4/%s' % slug
         args = ['checkout', '-b', branchname, cmdargs.fork_point]