Created
February 14, 2024 23:50
-
-
Save tforster/9e66ccbb8302b9e0219f0c20dfa71a29 to your computer and use it in GitHub Desktop.
Revisions
-
tforster revised this gist
Feb 14, 2024 . 1 changed file with 31 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1 +1,31 @@ #!/usr/bin/env bash ######################################################################################################################### # branch.sh is used, with arguments, to create a new branch from main that uses a slugified ADO ticket number and title # ######################################################################################################################### # Exit immediately if a command exits with a non-zero status set -o errexit # Treat unset variables as an error when substituting set -o nounset # Fails entire pipeline if any command fails set -euo pipefail # Simple function to echo out the help message. function help() { echo ' Commands: branch "{number} {title}" Create a new Git branch with the ADO ticket number and title. Double quotes not required but recommended. api help: Display this help message ' exit 0 } # Help keep us branching from main gitBranch=$(git rev-parse --abbrev-ref HEAD) if [[ "$gitBranch" != "main" ]]; then echo "Please create feature branches from main." exit 1 fi # Parse the arguments as input into the git branch command git checkout -b $(echo "$@" | iconv -t ascii//TRANSLIT | sed -r 's/[~\^]+//g' | sed -r 's/[^a-zA-Z0-9]+/-/g' | sed -r 's/^-+\|-+$//g' | sed -r 's/-$//g' | tr A-Z a-z) -
tforster created this gist
Feb 14, 2024 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@