module Git
  class ReleaseNotes
    require 'enumerator'
    include CLI
    include Commands

    def annotate!
      tags = get_tags.reverse
      
      start_tag = ask "Start at which tag?", tags[0], tags
      end_tag = ask "End at which tag?", tags[1], tags
      puts
      end_index = tags.index(end_tag) + 1 # include end tag
      start_index = tags.index(start_tag)      
      
      start_index.upto(end_index-1) do |i|
        start = tags[i]
        finish = tags[i+1]
        log = `git log --no-merges --pretty=format:"%h  %s" #{'refs/tags/' + finish + '..' if finish}refs/tags/#{start}`.strip
        next if log.empty?
        puts "#{start}"
        puts "=" * start.length
        puts log
        puts
      end
    end
  end
end
module Git
  class ReleaseNotes
    require 'enumerator'
    include CLI
    include Commands

    def annotate!
      tags = get_tags.reverse
      
      start_tag = ask "Start at which tag?", tags[0], tags
      end_tag = ask "End at which tag?", tags[1] || tags[0], tags
      puts
      end_index = tags.index(end_tag) + 1 # include end tag
      start_index = tags.index(start_tag)      
      
      start_index.upto(end_index-1) do |i|
        start = tags[i]
        finish = tags[i+1]
        log = `git log --no-merges --pretty=format:"%h  %s" #{'refs/tags/' + finish + '..' if finish}refs/tags/#{start}`.strip
        next if log.empty?
        puts "#{start}"
        puts "=" * start.length
        puts log
        puts
      end
    end
  end
end
Fix release notes if only one tag
Fix release notes if only one tag
