Created
February 11, 2013 16:19
-
-
Save brenes/4755484 to your computer and use it in GitHub Desktop.
Todo.txt addon to commit the added files on a git repo. It searches for a ticket number in the issue line (#TICKET_NUMBER) and opens the default editor with a commit message preloaded with the ticket number
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 characters
| #!/usr/bin/env bash | |
| action=$1 | |
| shift | |
| function usage(){ | |
| echo " Commits changes for the mentioned issue" | |
| echo " commit ITEM#" | |
| echo " Searches for an issue number in the todo line and opens the default editor with the issue number just to write your commit" | |
| echo "" | |
| exit | |
| } | |
| [ "$action" = "usage" ] && usage | |
| if ! [[ "$1" =~ ^[0-9]+$ ]]; then | |
| echo "Error! Usage:" | |
| usage | |
| fi | |
| ISSUE=$(sed "$1!d" "$TODO_FILE"|grep -E -o "([a-z]*)#[^ ]+") | |
| if [ "$ISSUE" = "" ]; then | |
| LINE=$(sed "$1!d" "$TODO_FILE") | |
| if [ "$LINE" = "" ]; then | |
| echo "Error, no item #$1 found!" | |
| else | |
| echo "Error, no issue seen in item #$1!" | |
| echo "$LINE" | |
| fi | |
| exit 1 | |
| fi | |
| ISSUE=${ISSUE:1} | |
| git commit -m "${ISSUE}" -e |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment