Last active
March 8, 2020 11:40
-
-
Save tomaszprasolek/b3bbe95457eec1120393db918671c983 to your computer and use it in GitHub Desktop.
Script add # symbol to Azure DevOps task number in the end of commit messages in working branch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
currentBranchName=$(git rev-parse --abbrev-ref HEAD) | |
add_hash() { | |
echo "" | |
git filter-repo -f --refs develop..$currentBranchName --message-callback ' | |
lastWord = message.split()[-1] | |
def RepresentsInt(s): | |
try: | |
int(s) | |
return True | |
except ValueError: | |
return False | |
if RepresentsInt(lastWord): | |
return message.replace(lastWord, b"#" + lastWord) | |
else: | |
return message' | |
} | |
echo "" | |
echo "You want to add # character to task numbers to last $(git rev-list --count master..$currentBranchName) commits." | |
# https://stackoverflow.com/questions/226703/how-do-i-prompt-for-yes-no-cancel-input-in-a-linux-shell-script | |
while true; do | |
read -p "Do you want to continue [y/n]? " yn | |
case $yn in | |
[Yy]* ) add_hash $1; break;; | |
[Nn]* ) exit;; | |
* ) echo "Please answer yes [y] or no [n].";; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment