Created
          May 4, 2013 20:38 
        
      - 
      
 - 
        
Save dleavitt/5518657 to your computer and use it in GitHub Desktop.  
    Rake task for generating a change log based on git tags
  
        
  
    
      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
    
  
  
    
  | desc "Outputs a change log based on git tags" | |
| task :changelog do | |
| tags = Dir['.git/refs/tags/*'].each.with_object({}) do |path, hsh| | |
| hsh[File.basename(path)] = File.read(path).chomp | |
| end | |
| tag_outputs = [] | |
| tags.reduce(nil) do |(_, commit1), (name, commit2)| | |
| tag_date = `git log -1 --format="%ci" #{commit2}`.chomp | |
| lines = [ "## #{name} - #{tag_date}\n" ] | |
| if commit1 | |
| lines << `git log #{commit1}...#{commit2} --pretty=" * (%h) %s [%an]"` | |
| end | |
| tag_outputs << lines.join("\n") | |
| [name, commit2] | |
| end | |
| puts tag_outputs.reverse.join("\n") | |
| end | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment