diff options
Diffstat (limited to '.gitlab-ci/run-style-check-diff.sh')
-rwxr-xr-x | .gitlab-ci/run-style-check-diff.sh | 13 |
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=$? |