From 7b0dcfc3df645424357d7690041e504017ec86b0 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 1 May 2016 17:31:38 +0200 Subject: [PATCH] Travis: apidoc: improve merge commit's message - This should really add the reference to the PR/commit that triggered the apidoc changes. - Link to job instead of build. - Add URL to commit range. Closes https://github.com/awesomeWM/awesome/pull/865. --- build-utils/travis-apidoc.sh | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/build-utils/travis-apidoc.sh b/build-utils/travis-apidoc.sh index 3c021948..2e884b70 100755 --- a/build-utils/travis-apidoc.sh +++ b/build-utils/travis-apidoc.sh @@ -64,12 +64,16 @@ if git diff --cached --exit-code --quiet; then exit fi +LAST_COMMIT_MSG="$(cd "$REPO_DIR" && git log -1 --pretty=format:%s)" +LAST_COMMIT="$(cd "$REPO_DIR" && git rev-parse --short HEAD)" + # Commit the relevant changes. COMMIT_MSG="Update docs for $AWESOME_VERSION via Travis Last commit message: -$(cd "$REPO_DIR" && git log -1 --pretty=format:%s) +$LAST_COMMIT_MSG +Commits: https://github.com/awesomeWM/awesome/compare/${TRAVIS_COMMIT_RANGE} Build URL: https://travis-ci.org/awesomeWM/awesome/builds/${TRAVIS_BUILD_ID}" git commit -m "[relevant] $COMMIT_MSG" @@ -89,10 +93,26 @@ git tag -d _old git checkout "$BRANCH" OLD_REV="$(git rev-parse --short HEAD)" -MERGE_COMMIT_MSG="$COMMIT_MSG" if [ "$TRAVIS_PULL_REQUEST" != false ]; then - COMMIT_MSG="$COMMIT_MSG + MERGE_COMMIT_MSG="$COMMIT_MSG Pull request: https://github.com/awesomeWM/awesome/pull/${TRAVIS_PULL_REQUEST}" +else + PR_OR_ISSUE="$(echo "$COMMIT_MSG" | head -n 1 | grep -o '#[0-9]\+')" + if [ -n "$PR_OR_ISSUE" ]; then + MERGE_COMMIT_MSG="$COMMIT_MSG +Ref: https://github.com/awesomeWM/awesome/pull/${PR_OR_ISSUE}" + else + PR_OR_ISSUE_URL="$(echo "$COMMIT_MSG" \ + | grep -Eo 'https://github.com/awesomeWM/awesome/(issues|pull)/[0-9]+')" + if [ -n "$PR_OR_ISSUE_URL" ]; then + MERGE_COMMIT_MSG="$COMMIT_MSG +Ref: $PR_OR_ISSUE_URL" + else + MERGE_COMMIT_MSG="$COMMIT_MSG +Commit: https://github.com/awesomeWM/awesome/commit/${LAST_COMMIT} +Tree: https://github.com/awesomeWM/awesome/commits/${LAST_COMMIT}" + fi + fi fi git merge --no-ff -m "$MERGE_COMMIT_MSG" merged-update NEW_REV="$(git rev-parse --short HEAD)" @@ -112,7 +132,7 @@ echo "Compare links:\n$COMPARE_LINKS" # Post a comment to the PR. if [ "$TRAVIS_PULL_REQUEST" != false ]; then curl -H "Authorization: token $GH_APIDOC_TOKEN" \ - -d "{\"body\": \"Documentation has been updated for this PR:\n$COMPARE_LINKS\"}" \ + -d "{\"body\": \"Documentation has been updated for this PR.\n\n$COMPARE_LINKS\"}" \ "https://api.github.com/repos/awesomeWM/awesome/issues/${TRAVIS_PULL_REQUEST}/comments" fi