Created
April 21, 2011 06:22
-
-
Save brantfaircloth/933843 to your computer and use it in GitHub Desktop.
Textmate save also commits to git
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
#!/usr/bin/env ruby | |
# Note: original hint from Florian Pilz @ http://stackoverflow.com/questions/4307192/is-it-possible-to-hook-a-git-commit-to-the-save-on-textmate. Slightly updated with git path (homebrew) and change to git_answer. | |
filename = ENV["TM_FILEPATH"].split("/").last | |
require ENV['TM_SUPPORT_PATH'] + '/lib/ui' | |
message = TextMate::UI.request_string(:title => "Committing changes of #{filename}", :prompt => "Please enter the commit message for your changes.") | |
`/usr/local/bin/git add #{ENV["TM_FILEPATH"]} 2>&1` | |
commit = `/usr/local/bin/git commit -m "#{message}" 2>&1` | |
git_answer = commit | |
unless git_answer.grep(/fatal/).empty? | |
puts "Please initialize git repository first!" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment