From 67128fe6c01b5447eb84168a2b87adc99451a8d8 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 2 Oct 2019 18:34:54 +0200 Subject: [PATCH] checkpatch,gitlab-ci: let checkpatch script compare against latest upstream master When opening a merge request from a fork of NetworkManager, then the pipeline runs with the a checkout of the fork. That means, checkpatch would compare the branch against "master" (or "nm-x-y" stable branches) of the fork, instead of upstream. That doesn't seem too useful. Instead, also add upstream NetworkManager as git remote, fetch the branches, and use the branches from there as base for checkpatch. https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/255 (cherry picked from commit 3019648b4bc1856b84b904bb4cf02500fe35cb76) (cherry picked from commit 9a3770231165c2a9b3541f9273c22f7f4d9c155b) --- .gitlab-ci.yml | 2 +- contrib/scripts/checkpatch-feature-branch.sh | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 44aa2ed00c..bb38d67548 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -73,7 +73,7 @@ checkpatch: stage: test script: - date '+%Y%m%d-%H%M%S'; dnf install -y git - - date '+%Y%m%d-%H%M%S'; contrib/scripts/checkpatch-feature-branch.sh 2>&1 | tee checkpatch-out.txt + - date '+%Y%m%d-%H%M%S'; NM_CHECKPATCH_FETCH_UPSTREAM=1 contrib/scripts/checkpatch-feature-branch.sh 2>&1 | tee checkpatch-out.txt allow_failure: true artifacts: when: on_failure diff --git a/contrib/scripts/checkpatch-feature-branch.sh b/contrib/scripts/checkpatch-feature-branch.sh index 0f37728d9f..72e5903dae 100755 --- a/contrib/scripts/checkpatch-feature-branch.sh +++ b/contrib/scripts/checkpatch-feature-branch.sh @@ -15,6 +15,12 @@ if printf '%s' "$HEAD" | grep -q '\.\.'; then else BASE_REF="refs/remotes/origin/" + if [ "$NM_CHECKPATCH_FETCH_UPSTREAM" == 1 ]; then + git remote add nm-upstream https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git + git fetch nm-upstream || die "failure to fetch from https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git" + BASE_REF="refs/remotes/nm-upstream/" + fi + # the argument is only a single ref (or the default "HEAD"). # Find all commits that branch off one of the stable branches or master # and lead to $HEAD. These are the commits of the feature branch.