[polari/ci-test: 1/3] ci: Check for issue/MR URLs in commit messages
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/ci-test: 1/3] ci: Check for issue/MR URLs in commit messages
- Date: Thu, 14 Feb 2019 22:58:12 +0000 (UTC)
commit 0f44eb288e38b5df4a94b762d0494ffdd6b387c4
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Feb 14 21:12:59 2019 +0100
ci: Check for issue/MR URLs in commit messages
Commit messages should include the full URL to an issue or merge
request to keep associated information easily available in future
log digging.
Jonas came up with a script to enforce that policy for mutter and
gnome-shell. It's an excellent idea, so adopt it here as well.
https://gitlab.gnome.org/GNOME/polari/merge_requests/89
.gitlab-ci.yml | 21 +++++++++++++++++++++
.gitlab-ci/check-commit-log.sh | 31 +++++++++++++++++++++++++++++++
2 files changed, 52 insertions(+)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index bfa05ab..64874c0 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,4 +1,5 @@
stages:
+ - commit_check
- source_check
- build
- review
@@ -7,11 +8,28 @@ variables:
BUNDLE: "polari-git.flatpak"
LINT_LOG: "eslint-report.txt"
+.only_default: &only_default
+ only:
+ - branches
+ - tags
+ - merge_requests
+
+check_commit_log:
+ image: registry.gitlab.gnome.org/gnome/gjs:fedora.static-analysis
+ stage: commit_check
+ before_script:
+ - dnf install -y git
+ script:
+ - ./.gitlab-ci/check-commit-log.sh
+ only:
+ - merge_requests
+
eslint:
image: registry.gitlab.gnome.org/gnome/gjs:fedora.static-analysis
stage: source_check
script:
- sh lint/generate-report.sh -o $LINT_LOG || { cat $LINT_LOG; false; }
+ <<: *only_default
artifacts:
paths:
- ${LINT_LOG}
@@ -46,6 +64,7 @@ flatpak:
- flatpak build-bundle repo ${BUNDLE} --runtime-repo=${RUNTIME_REPO} ${DBUS_ID} ${BRANCH}
after_script:
- tar -czf cache.tar.gz .flatpak-builder/cache
+ <<: *only_default
artifacts:
paths:
@@ -64,6 +83,7 @@ review:
- flatpak
script:
- echo "Generating flatpak deployment"
+ <<: *only_default
artifacts:
paths:
- ${BUNDLE}
@@ -81,6 +101,7 @@ stop_review:
stage: review
script:
- echo "Stopping flatpak deployment"
+ <<: *only_default
when: manual
environment:
name: review/$CI_COMMIT_REF_NAME
diff --git a/.gitlab-ci/check-commit-log.sh b/.gitlab-ci/check-commit-log.sh
new file mode 100755
index 0000000..cc3bcee
--- /dev/null
+++ b/.gitlab-ci/check-commit-log.sh
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+
+if [ -z "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" ]; then
+ echo Cannot review non-merge request
+ exit 1
+fi
+
+git fetch $CI_MERGE_REQUEST_PROJECT_URL.git $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
+
+branch_point=$(git merge-base HEAD FETCH_HEAD)
+
+commits=$(git log --format='format:%H' $branch_point..$CI_COMMIT_SHA)
+
+if [ -z "$commits" ]; then
+ echo Commit range empty
+ exit 1
+fi
+
+function commit_message_has_url() {
+ commit=$1
+ commit_message=$(git show -s --format='format:%b' $commit)
+ echo "$commit_message" | grep -qe
"\($CI_MERGE_REQUEST_PROJECT_URL/\(issues\|merge_requests\)/[0-9]\+\|https://bugzilla.gnome.org/show_bug.cgi?id=[0-9]\+\)"
+ return $?
+}
+
+for commit in $commits; do
+ if ! commit_message_has_url $commit; then
+ echo "Missing merge request or issue URL on commit $(echo $commit | cut -c -8)"
+ exit 1
+ fi
+done
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]