Skip to content

Instantly share code, notes, and snippets.

@curtisharvey
Created March 28, 2011 07:43
Show Gist options
  • Save curtisharvey/890122 to your computer and use it in GitHub Desktop.
Save curtisharvey/890122 to your computer and use it in GitHub Desktop.
commit modified files using lines removed from TODO.md as commit message
# commit modified files using lines removed from TODO.md as commit message
git ci -am "$(git diff "TODO.md" | awk '/^-\* / {printf substr($0, 4)"; "}')"
# make it easier by adding an alias to .gitconfig
[alias]
todone = "!git ci -am \"$(git diff \"TODO.md\" | awk '/^-\* / printf substr($0, 4)\"; \"}')"
# make it smarter by looking for the TODO.md file or accepting it as an argument
[alias]
todone = "!f () {\
R=\"$(git rev-parse --git-dir 2> /dev/null)/..\";\
if [[ \"$1\" && -f \"$1\" ]]; then T=\"$1\";\
elif [[ -f \"TODO.md\" ]]; then T=\"TODO.md\";\
elif [[ -f \"${R}/TODO.md\" ]]; then T=\"${R}/TODO.md\";\
else echo \"TODO file not found, specify as first argument or use default name of TODO.md\"; exit;\
fi;\
m=\"$(git diff \"$T\" | awk '/^-\\* / {printf substr($0, 4)\"; \"}')\";\
if [[ \"x$m\" != \"x\" ]]; then git ci -am \"$m\";\
else echo \"[NOTICE] No lines removed from '$T'\";\
fi;\
}; f"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment