From 8ec050ad09ba9795bf5065af983975d806c39cf3 Mon Sep 17 00:00:00 2001 From: Frantisek Hrbata Date: Wed, 16 Dec 2020 12:11:35 +0100 Subject: [PATCH] git-mr-update: check that MR in in-reply-to header matches RM ref Signed-off-by: Frantisek Hrbata --- git-mr-update | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/git-mr-update b/git-mr-update index 9b8a06d..0bedda1 100755 --- a/git-mr-update +++ b/git-mr-update @@ -171,6 +171,8 @@ elif ref_type == "mbox": continue revs.append(line) + mr_re = re.compile("<([0-9a-f]{40})") + for rev in revs: rv, out, err = mrlib.run(["git", "show", "--format=%b", rev]) lines = out.split("\n") @@ -183,6 +185,13 @@ elif ref_type == "mbox": if not lines[1].lower().startswith("in-reply-to: "): sys.exit("Expecting 2nd line '{}' to be 'In-Reply-To' header.".format(lines[1])) + match = mr_re.match(lines[1].split()[1]) + if not match: + sys.exit("Cannot find MR in '{}'.".format(lines[1])) + + if match[1] != ref_mr: + sys.exit("MR '{}' in In-Reply-To header does not match '{}'.".format(match[1], ref_mr)) + if lines[2]: sys.exit("Expecting 3rd line '{}' to be empty.".format(lines[2])) -- 1.7.10.4