Skip to contentSkip to conversation

gitlab: minor fixes for checkpatch CI job

PATCH In review Daniel P. Berrangé 2 participants 4 messages Oct 19, 2020 – Oct 21, 2020 Checkpatch

lore
Share & tools
lore
#0 lore raw

cover gitlab: minor fixes for checkpatch CI job

This fixes a bogus error when pushing a branch whose content has no delta against upstream git master.

Daniel P. Berrangé (2):
gitlab: skip checkpatch.pl checks if no commit delta on branch
scripts: fix error from checkpatch.pl when no commits are found

 .gitlab-ci.d/check-patch.py | 8 ++++++++
 scripts/checkpatch.pl       | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/2 gitlab: skip checkpatch.pl checks if no commit delta on branch

If the current branch is synced to the current upstream git master, there are no commits that need checking. This causes checkpatch.pl to print an error that it found no commits. We need to avoid calling checkpatch.pl in this case.

---
 .gitlab-ci.d/check-patch.py | 8 ++++++++
 1 file changed, 8 insertions(+)
.gitlab-ci.d/check-patch.py +8 -0
index 5a14a25b13..0ff30ee077 100755
@@ -33,8 +33,16 @@ ancestor = subprocess.check_output(["git", "merge-base",
 
 ancestor = ancestor.strip()
 
+log = subprocess.check_output(["git", "log", "--format=%H %s",
+                               ancestor + "..."],
+                              universal_newlines=True)
+
 subprocess.check_call(["git", "remote", "rm", "check-patch"])
 
+if log == "":
+    print("\nNo commits since %s, skipping checks\n" % ancestor)
+    sys.exit(0)
+
 errors = False
 
 print("\nChecking all commits since %s...\n" % ancestor)
Signature · 1 line
2.26.2
#2 lore raw

PATCH 2/2 scripts: fix error from checkpatch.pl when no commits are found

In reply to Daniel P. Berrangé

The error message was supposed to mention the input revision list start point, not the branch flag.

---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/checkpatch.pl +1 -1
index 6ed34970f9..88c858f67c 100755
@@ -392,7 +392,7 @@ if ($chk_branch) {
 
 	close $HASH;
 
-	die "$P: no revisions returned for revlist '$chk_branch'\n"
+	die "$P: no revisions returned for revlist '$ARGV[0]'\n"
 	    unless @patches;
 
 	my $i = 1;
Signature · 1 line
2.26.2
#3 lore raw
In reply to Daniel P. Berrangé
Quoted 2 lines · Daniel P. Berrangé

This fixes a bogus error when pushing a branch whose content has no delta against upstream git master.

Queued to testing/next, thanks.

Quoted 8 lines

Daniel P. Berrangé (2):
gitlab: skip checkpatch.pl checks if no commit delta on branch
scripts: fix error from checkpatch.pl when no commits are found

 .gitlab-ci.d/check-patch.py | 8 ++++++++
 scripts/checkpatch.pl       | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)
Signature · 1 line
Alex Bennée