From eaff9bcc7268adc7168483c0772f8fa6b3ab473b Mon Sep 17 00:00:00 2001 From: Michal Suchanek Date: Feb 01 2022 17:17:01 +0000 Subject: git_sort/lib: Only allow patches intended for mainline. Signed-off-by: Michal Suchanek --- diff --git a/scripts/git_sort/lib.py b/scripts/git_sort/lib.py index bf3a834..7bde279 100644 --- a/scripts/git_sort/lib.py +++ b/scripts/git_sort/lib.py @@ -267,11 +267,25 @@ class InputEntry(object): raise exc.KSError("Could not find patch \"%s\"" % (name,)) with Patch(open(name, mode="rb")) as patch: + mainline_tags = patch.get("Patch-mainline") commit_tags = patch.get("Git-commit") repo_tags = patch.get("Git-repo") + if len(repo_tags) > 1: + raise exc.KSError("Multiple Patch-mainline tags found. Patch \"%s\" is " + "tagged improperly." % (name,)) + if not commit_tags: self.dest_head = git_sort.oot + mainline = mainline_tags[0] + if not re.match("^(Submitted|Not yet)", mainline, re.IGNORECASE): + raise exc.KSError( + "There is a problem with patch \"%s\". " + "The Patch-mainline tag \"%s\" is not supported in sorted " + "section. Please add the patches without a commit id that " + "are neither 'Submitted' nor 'Not yet' submitted to the " + "manually maintained section below sorted section." % ( + name, mainline,)) return class BadTag(Exception): diff --git a/scripts/git_sort/tests/support.py b/scripts/git_sort/tests/support.py index 31e4c5e..7a2fb59 100644 --- a/scripts/git_sort/tests/support.py +++ b/scripts/git_sort/tests/support.py @@ -75,7 +75,7 @@ def format_patch(commit, mainline=None, repo=None, references=None, f.write("Git-repo: %s\n" % (repo,)) f.write("Git-commit: %s\n" % (str(commit.id),)) else: - f.write("Patch-mainline: No\n") + f.write("Patch-mainline: Not yet, to be submitted by partner developer\n") if references is not None: f.write("References: %s\n" % (references,)) f.write("Subject: %s" % (commit.message,))