From: Frantisek Hrbata Date: Wed, 16 Dec 2020 11:11:35 +0000 (+0100) Subject: git-mr-update: check that MR in in-reply-to header matches RM ref X-Git-Tag: v0.2~42 X-Git-Url: http://www.hrbata.com/gitweb/?a=commitdiff_plain;h=8ec050ad09ba9795bf5065af983975d806c39cf3;p=gimrr.git git-mr-update: check that MR in in-reply-to header matches RM ref Signed-off-by: Frantisek Hrbata --- 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]))