From e9340c792c6bce940a167caf217901257e130b13 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 6 Apr 2022 13:06:56 +0200 Subject: [PATCH] contrib: fail "find-backports" script if we have no "refs/notes/bugs" notes "find-backports" script parses the commit messages to figure out which patches to backport. We use "refs/notes/bugs" notes to extend the meta data after the commit was merged. If you don't setup the notes, the output is likely incomplete or wrong. Yes, this is annoying. It requires you to setup the notes as described in "CONTRIBUTING.md". Also because the "release.sh" script runs "find-backports", so that means you cannot do releases without setting up the notes (unless you manually disable running "find-backports"). But you really shouldn't make a release based on incomplete information. --- contrib/scripts/find-backports | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/contrib/scripts/find-backports b/contrib/scripts/find-backports index c9ec1c0d64..ac1bac69bf 100755 --- a/contrib/scripts/find-backports +++ b/contrib/scripts/find-backports @@ -43,6 +43,15 @@ def _keys_to_dict(itr): return d +@memoize +def git_ref_exists_plain(ref): + try: + subprocess.check_output(["git", "show-ref", "-q", "--verify", str(ref)]) + except subprocess.CalledProcessError: + return False + return True + + @memoize def git_ref_exists(ref): try: @@ -245,6 +254,11 @@ if __name__ == "__main__": if not ref_head: die('Ref "%s" does not exist' % (ref_head0)) + if not git_ref_exists_plain("refs/notes/bugs"): + die( + "Notes refs/notes/bugs not found. Read CONTRIBUTING.md file for how to setup the notes" + ) + ref_upstreams = [] if len(sys.argv) <= 2: head_name = git_get_head_name(ref_head0)