summaryrefslogtreecommitdiff
path: root/.gitlab-ci
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2020-06-28 14:01:19 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2020-06-29 13:14:40 +0100
commit6bdca276a2318fa1fd2f9f9df7a475c52bb44a33 (patch)
tree2655d0112ed0226ef0b74ac9e93831d9a8649354 /.gitlab-ci
parentc4b2112f16537db94b4a2e1f99183023d5dc323a (diff)
downloadgtk+-6bdca276a2318fa1fd2f9f9df7a475c52bb44a33.tar.gz
ci: Create new origin for forks
We don't need to create a new remote and fetch its master if we're checking a merge request done on the upstream repository.
Diffstat (limited to '.gitlab-ci')
-rwxr-xr-x.gitlab-ci/run-style-check-diff.sh13
1 files changed, 10 insertions, 3 deletions
diff --git a/.gitlab-ci/run-style-check-diff.sh b/.gitlab-ci/run-style-check-diff.sh
index 35a1bb4a39..42ef5d9fee 100755
--- a/.gitlab-ci/run-style-check-diff.sh
+++ b/.gitlab-ci/run-style-check-diff.sh
@@ -4,8 +4,15 @@ set -e
# We need to add a new remote for the upstream master, since this script could
# be running in a personal fork of the repository which has out of date branches.
-git remote add upstream https://gitlab.gnome.org/GNOME/gtk.git
-git fetch upstream
+if [ "${CI_PROJECT_NAMESPACE}" != "GNOME" ]; then
+ echo "Retrieving the current upstream repository from ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}..."
+ git remote add upstream https://gitlab.gnome.org/GNOME/gtk.git
+ git fetch upstream
+ ORIGIN="upstream"
+else
+ echo "Reusing the existing repository on ${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}"
+ ORIGIN="origin"
+fi
# Work out the newest common ancestor between the detached HEAD that this CI job
# has checked out, and the upstream target branch (which will typically be
@@ -13,7 +20,7 @@ git fetch upstream
#
# `${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}` is only defined if we’re running in
# a merge request pipeline; fall back to `${CI_DEFAULT_BRANCH}` otherwise.
-newest_common_ancestor_sha=$(diff --old-line-format='' --new-line-format='' <(git rev-list --first-parent "upstream/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-${CI_DEFAULT_BRANCH}}") <(git rev-list --first-parent HEAD) | head -1)
+newest_common_ancestor_sha=$(diff --old-line-format='' --new-line-format='' <(git rev-list --first-parent "${ORIGIN}/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-${CI_DEFAULT_BRANCH}}") <(git rev-list --first-parent HEAD) | head -1)
git diff -U0 --no-color "${newest_common_ancestor_sha}" | .gitlab-ci/clang-format-diff.py -binary "clang-format" -p1
exit_status=$?