Mobrovac has submitted this change and it was merged. Change subject: Add check for recent deployment commits to tagging script ......................................................................
Add check for recent deployment commits to tagging script Checks for existence of a configured deploy repository. If one exists, checks it for a "recent" commit (one made within the past two hours) and warns the user if there is none, suggesting a 'git pull' and giving a chance to bail out. Updated error messages to provide add'l info. Changed some 'echo' commands to 'printf'. Bug: T131504 Change-Id: Ibd8fec0783901e46ea22d2b182acb9ff705994d7 --- M scripts/tag-deploy.sh 1 file changed, 24 insertions(+), 3 deletions(-) Approvals: Mobrovac: Looks good to me, approved jenkins-bot: Verified diff --git a/scripts/tag-deploy.sh b/scripts/tag-deploy.sh index 82df99f..a8926bf 100755 --- a/scripts/tag-deploy.sh +++ b/scripts/tag-deploy.sh @@ -1,18 +1,39 @@ #!/usr/bin/env bash set -euo pipefail +# Check for GPG signing key if [[ -z "$( git config user.signingkey )" ]]; then - echo "$0: GPG signing key required." >&2 + printf "\n$0: GPG signing key required. See https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work\n" >&2 + exit 2 +fi + +# Check for deploy directory +if [[ -z "$( git config deploy.dir )" ]]; then + printf "\n$0: No deploy repository found. Set a deploy repo with:\n\n git config deploy.dir <FULL PATH TO DEPLOY REPO DIR>\n\n" >&2 exit 2 fi repo_dir="$( cd $( dirname $0 )/.. && pwd )" -deploy_dir="$( git config deploy.dir )" +cd "$( git config deploy.dir )" -cd "$deploy_dir" +# Check for deploy directory commit in past 2 hours +if [[ -z "$( git log --since="2 hours ago" )" ]]; then + printf "\nWARNING: The most recent deploy commit is:\n\n" + printf "$( git log -1 )\n\n" + printf "This isn't very recent. You may need to pull the most recent changes.\n\n" + read -p "Continue anyway? (y/N) " -n 1 -r + if [[ ! $REPLY =~ ^[Yy]$ ]]; then + echo + exit 1 + fi +fi + +# Build the deployment tag deploy_commit_date="$( git show -s --format=%ci | awk '{print $1;}' )" deploy_commit_id="$( git rev-parse --short HEAD )" tag="deploy/$deploy_commit_date/$deploy_commit_id" +# Tag the latest code repo commit with it & push tags cd "$repo_dir" git tag -s "$tag" -m "deployed" && git push --tags +printf "Applied new tag: $tag" -- To view, visit https://gerrit.wikimedia.org/r/280931 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ibd8fec0783901e46ea22d2b182acb9ff705994d7 Gerrit-PatchSet: 8 Gerrit-Project: mediawiki/services/mobileapps Gerrit-Branch: master Gerrit-Owner: Mholloway <[email protected]> Gerrit-Reviewer: BearND <[email protected]> Gerrit-Reviewer: Dbrant <[email protected]> Gerrit-Reviewer: Fjalapeno <[email protected]> Gerrit-Reviewer: GWicke <[email protected]> Gerrit-Reviewer: Mholloway <[email protected]> Gerrit-Reviewer: Mhurd <[email protected]> Gerrit-Reviewer: Mobrovac <[email protected]> Gerrit-Reviewer: Niedzielski <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
