nsis installer: List emulators in alphabetical order
[qemu/ar7.git] / .gitlab-ci.d / check-dco.py
blob632c8bcce87e630733ad2bbac693d532ac05b107
1 #!/usr/bin/env python3
3 # check-dco.py: validate all commits are signed off
5 # Copyright (C) 2020 Red Hat, Inc.
7 # SPDX-License-Identifier: GPL-2.0-or-later
9 import os
10 import os.path
11 import sys
12 import subprocess
14 namespace = "qemu-project"
15 if len(sys.argv) >= 2:
16 namespace = sys.argv[1]
18 cwd = os.getcwd()
19 reponame = os.path.basename(cwd)
20 repourl = "https://gitlab.com/%s/%s.git" % (namespace, reponame)
22 subprocess.check_call(["git", "remote", "add", "check-dco", repourl])
23 subprocess.check_call(["git", "fetch", "check-dco", "master"],
24 stdout=subprocess.DEVNULL,
25 stderr=subprocess.DEVNULL)
27 ancestor = subprocess.check_output(["git", "merge-base",
28 "check-dco/master", "HEAD"],
29 universal_newlines=True)
31 ancestor = ancestor.strip()
33 subprocess.check_call(["git", "remote", "rm", "check-dco"])
35 errors = False
37 print("\nChecking for 'Signed-off-by: NAME <EMAIL>' " +
38 "on all commits since %s...\n" % ancestor)
40 log = subprocess.check_output(["git", "log", "--format=%H %s",
41 ancestor + "..."],
42 universal_newlines=True)
44 if log == "":
45 commits = []
46 else:
47 commits = [[c[0:40], c[41:]] for c in log.strip().split("\n")]
49 for sha, subject in commits:
51 msg = subprocess.check_output(["git", "show", "-s", sha],
52 universal_newlines=True)
53 lines = msg.strip().split("\n")
55 print("🔍 %s %s" % (sha, subject))
56 sob = False
57 for line in lines:
58 if "Signed-off-by:" in line:
59 sob = True
60 if "localhost" in line:
61 print(" ❌ FAIL: bad email in %s" % line)
62 errors = True
64 if not sob:
65 print(" ❌ FAIL missing Signed-off-by tag")
66 errors = True
68 if errors:
69 print("""
71 ❌ ERROR: One or more commits are missing a valid Signed-off-By tag.
74 This project requires all contributors to assert that their contributions
75 are provided in compliance with the terms of the Developer's Certificate
76 of Origin 1.1 (DCO):
78 https://developercertificate.org/
80 To indicate acceptance of the DCO every commit must have a tag
82 Signed-off-by: REAL NAME <EMAIL>
84 This can be achieved by passing the "-s" flag to the "git commit" command.
86 To bulk update all commits on current branch "git rebase" can be used:
88 git rebase -i master -x 'git commit --amend --no-edit -s'
90 """)
92 sys.exit(1)
94 sys.exit(0)