Automatic comment on missing sig.

Add a comment to a PR if a commit message is missing the signature.

Signed-off-by: Christoph <auer.chrisi@gmx.net>
This commit is contained in:
Christoph 2016-07-04 21:32:29 +02:00
parent 16550f802c
commit 78d42476eb
2 changed files with 35 additions and 0 deletions

View file

@ -3,6 +3,9 @@ sudo: required
language: cpp language: cpp
env: env:
global:
# GitHub auth token (GH_AUTH_TOKEN)
- secure: "QBbD9VXAx3Mn0vFmHZtm6/sq+twMyR7ilQh7TQm8gBy2TrjhHKDKQ4wRQ5sa2MUFUbzrUOvPlPGq1WuY1mAUt8UE6jZDJNyyDWb6iIlcEmNRsd39XAhYHvJ+uI9JsD+U3OctZ+7Bo4fno0RLv1D5lzh5bpohmjgWxx9TiSZItbsRU+m0XM0Tahx335aXF8NFoVjheGXCOcLAXDt6OmaKPmlrXreuta5nOoRKeOg5vHlt/KNU1pYb8MFvWJc14DKxq3jNqrYlo9vHFv5tVhR1aqvVFWTD/4Z88OSxx3POzyVWdMso0lFov9uxs8qHoqLsGhDMElggyz/jnqZIHpwQMaYIGQ0LLYDv21jGgOuCOWKYlfjDY+tuESXmVPzerTlYBWLZDPrpE8BnXVYo8B/sF4WN6oCuBRjawlqYhqTH+tDDORc9Uc9pamhcuh6OsLMx3PHoyg8joN3t8yUnwhySXyfQ36hqlZ+Y4bBDRZBH/SB/EPmedyLGwdhzQFsUnOBotYeOym7LUdnGraGcj1iTPLdo5TMlBYlAiB12J5mHTNuzUKXh+PBV4REg4Mm2xYX+Pue5Qo1JcOWJteIX4BdPv526DXB3yaNWS1pZgGvYqtBwQlCeOfwOYupS0PksvmV7aX7c4qJSyW3dmEd03cxmebD0b2SbqyPxGFuUajJ7B60="
matrix: matrix:
- BUILD_VERSION="" - BUILD_VERSION=""
- BUILD_VERSION="disable_autoupdate" - BUILD_VERSION="disable_autoupdate"

View file

@ -13,6 +13,7 @@ checkCommitMessage() {
if [[ $TRAVIS_COMMIT_MSG != *"Signed-off-by: "* ]];then if [[ $TRAVIS_COMMIT_MSG != *"Signed-off-by: "* ]];then
error_msg "The commit message does not contain the signature!" error_msg "The commit message does not contain the signature!"
error_msg "More information: https://github.com/telegramdesktop/tdesktop/blob/master/.github/CONTRIBUTING.md#sign-your-work" error_msg "More information: https://github.com/telegramdesktop/tdesktop/blob/master/.github/CONTRIBUTING.md#sign-your-work"
addMissingSignatureInfos
exit 1 exit 1
else else
success_msg "Commit message contains signature" success_msg "Commit message contains signature"
@ -20,6 +21,37 @@ checkCommitMessage() {
fi fi
} }
addMissingSignatureInfos() {
if [[ $BUILD_VERSION == "" ]]; then
local TEXT="Hi,\n\
thanks for the pull request!\n\
\n\
Please read our [contributing policy](https://github.com/telegramdesktop/tdesktop/blob/master/.github/CONTRIBUTING.md). You'll need to make a pull request with the \\\"Signed-off-by:\\\" signature being the last line of your commit message, like it is described in [sign your work](https://github.com/telegramdesktop/tdesktop/blob/master/.github/CONTRIBUTING.md#sign-your-work) section. That will grant your work into the public domain.\n\
\n\
(See [travis build](https://travis-ci.org/telegramdesktop/tdesktop/jobs/${TRAVIS_JOB_ID}))"
addCommentToGitHub "${TEXT}"
addLabelToGitHub "missing signature"
info_msg "Added missing signature info on github"
fi
}
addCommentToGitHub() {
local BODY=$1
sendGitHubRequest "POST" "{\"body\": \"${BODY}\"}" "repos/${TRAVIS_REPO_SLUG}/issues/${TRAVIS_PULL_REQUEST}/comments"
}
addLabelToGitHub() {
local LABEL=$1
sendGitHubRequest "PATCH" "{\"labels\": [\"${LABEL}\"]}" "repos/${TRAVIS_REPO_SLUG}/issues/${TRAVIS_PULL_REQUEST}"
}
sendGitHubRequest() {
local METHOD=$1
local BODY=$2
local URI=$3
curl -H "Authorization: token ${GH_AUTH_TOKEN}" --request "${METHOD}" --data "${BODY}" --silent "https://api.github.com/${URI}" > /dev/null
}
source ./.travis/common.sh source ./.travis/common.sh
run run