Created
November 30, 2022 13:58
-
-
Save nkcmr/df54faabc6d32e1982c509458b19079d to your computer and use it in GitHub Desktop.
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 | |
# should rename it just "git-newbranch" and put it in your path somewhere. | |
# once that is done it should be invokable as "git newbranch JIRA-123" | |
set -euo pipefail | |
JIRA_NUMBER="${1:-}" | |
if ! [[ "$JIRA_NUMBER" =~ ^[A-Z]{2,}-[0-9]+$ ]] ; then | |
echo "$(basename $0): error: invalid Jira number" | |
exit 1 | |
fi | |
USERNAME="${GIT_NEWBRANCH_USER:-$USER}" | |
git checkout -b "$USERNAME/$JIRA_NUMBER/$(date +%s)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment