-
-
Save mmorey/8125388 to your computer and use it in GitHub Desktop.
Revisions
-
mmorey revised this gist
Dec 25, 2013 . 1 changed file with 8 additions and 3 deletions.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 @@ -8,6 +8,9 @@ # You will have to install the git gem for this to work: # gem install git # # You will need to make the script executable # chmod +x post-commit # # Name this file 'post-commit' and drop it in the directory '.git/hooks' in # any repository that you want to log. Make sure the file is executable. You # can also add this to your git templates, which will put it in every new @@ -18,12 +21,14 @@ require "git" log_file = ENV['HOME'] + "/commit_log.txt" repo = Git.open(Dir.pwd) repo_name = Dir.pwd[%r{[\.\-\w]+$}] # top directory date = repo.log.first.date.strftime("%Y-%m-%d-%H-%M-%S") # format date message = repo.log.first.message.lines.first.strip # just first line branch = repo.log.first.name File.open(log_file, "a") do |log| log.puts "#{date} [#{repo_name}:#{branch}] #{message}" puts "#{date} [#{repo_name}:#{branch}] #{message}" end puts "Updated #{log_file}" -
lmullen created this gist
Jul 27, 2013 .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,29 @@ #!/usr/bin/env ruby # Write git commit messages to a log file # # Lincoln A. Mullen | lincoln@lincolnmullen.com | http://lincolnmullen.com # MIT License <http://lmullen.mit-license.org/> # # You will have to install the git gem for this to work: # gem install git # # Name this file 'post-commit' and drop it in the directory '.git/hooks' in # any repository that you want to log. Make sure the file is executable. You # can also add this to your git templates, which will put it in every new # repository or to existing repositories by re-running git init. # # A commit message in the log should look this this: # 2013-07-26-11-25-55 [repository:branch] First line of commit message require "git" log_file = "/home/lmullen/todo/time-use.txt" repo = Git.open(Dir.pwd) repo_name = Dir.pwd[%r{[\.\-\w]+$}] # top directory date = repo.log.first.date.strftime("%Y-%m-%d-%H-%M-%S") # format date message = repo.log.first.message.lines.first.strip # just first line branch = repo.log.first.name File.open(log_file, "a") do |log| log.puts "#{date} [#{repo_name}:#{branch}] #{message}" end