Class: Git::Wiki
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #annotate! ⇒ Object
-
#initialize(options = {}) ⇒ Wiki
constructor
A new instance of Wiki.
Methods included from Commands
#assert_is_git_repo, #get_branch, #get_tags, #is_git_repo?, #next_version, #valid_version_regexp
Methods included from CLI
#ask, #error, #stars, #warn, #wrap
Constructor Details
#initialize(options = {}) ⇒ Wiki
Returns a new instance of Wiki.
10 11 12 |
# File 'lib/git/wiki.rb', line 10 def initialize( = {}) @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/git/wiki.rb', line 9 def @options end |
Instance Method Details
#annotate! ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/git/wiki.rb', line 14 def annotate! assert_is_git_repo initialize_pivotal = .reverse error "No version tags available." if .empty? if [:all] start_index = 0 end_index = .length - 1 else start_tag = [:from] || ask("Start at which tag?", [0], ) start_index = .index(start_tag) end_tag = [:to] || ask("End at which tag?", [start_index + 1] || [start_index], ) end_index = .index(end_tag) # include end tag end start = [start_index] finish = [end_index] range = '' range << "refs/tags/#{finish}.." if finish # log until end tag if there is an end tag range << "refs/tags/#{start}" log = `git log --no-merges --pretty=format:"%h %s" #{range}`.strip.split("\n") project_name = `pwd`.chomp.split('/').last # stories = { 12345 => { 'abc123' => "foo", 'def343' => "bar" } } stories = Hash.new{|hash, key| hash[key] = {}} log.each do |log_line| # (commit, pair, pivotal, subject) = log_line.split(/\s+/, 4) #[(.+?)]\s*[(\d+)](.+) (match, commit, pair, pivotal, subject) = *log_line.match(/(.+?)\s*\[([a-zA-Z\/]{2,})\]\s*\[\#?([\d\/]+)\](.*)/) if match if commit.gsub!(/\s*Revert.*/, '') subject = subject + ' [REVERT]' end pivotal.split('/').each do |p| stories[p.to_i][commit] = { :pair => pair, :message => subject.gsub("\"", '').strip } end else stories[0][log_line] = {:pair => '', :message => log_line} end end deploy_log = `git log --no-merges --pretty=format:"%h %s" #{range} config Capfile`.strip.split("\n") project_name = `pwd`.chomp.split('/').last deploy_log.each do |log_line| # (commit, pair, pivotal, subject) = log_line.split(/\s+/, 4) #[(.+?)]\s*[(\d+)](.+) (match, commit, pair, pivotal, subject) = *log_line.match(/(.+?)\s*\[([a-zA-Z\/]{2,})\]\s*\[\#?([\d\/]+)\](.*)/) if match commit.gsub!(/\s*Revert.*/, '') pivotal.split('/').each do |p| stories[p.to_i][commit].merge!({:red => true}) end else stories[0][log_line].merge!({:red => true}) end end table_start Struct.new("UnknownStory", :id, :name, :story_type, :url) stories.each do |story_id, commits| story = @pivotal.stories.find(story_id) || Struct::UnknownStory.new(story_id, 'No Pivotal Story Available', 'Unknown', nil) row = "|-\n| " row += story.url ? "[#{story.url} #{story.id}]" : "#{story.id}" row += "\n| #{story.name}\n| #{story.story_type.capitalize}\n|\n{|\n" commits.each do |commit, details| row += "|-#{'style="background-color:#ffcccc;"' if details[:red]}\n| [http://github.com/primedia/#{project_name}/commit/#{commit} #{commit}]\n| #{details[:pair]}\n| #{details[:message]}\n" end row += "|}" puts row end table_end puts end |