Class: V1gittools::ChangeLogTool

Inherits:
BaseTool
  • Object
show all
Defined in:
lib/v1gittools/change_log_tool.rb

Instance Attribute Summary

Attributes inherited from BaseTool

#args, #config, #git, #github, #repo_config, #v1

Instance Method Summary collapse

Methods inherited from BaseTool

#check_proper_init, #initialize

Constructor Details

This class inherits a constructor from V1gittools::BaseTool

Instance Method Details

#generate_changelog(start_snapshot, end_snapshot) ⇒ Object



4
5
6
7
8
9
10
11
12
13
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
# File 'lib/v1gittools/change_log_tool.rb', line 4

def generate_changelog (start_snapshot, end_snapshot)
  @git.log(999999).between(start_snapshot,end_snapshot).each do |commit|
    if match = commit.message.match(/Merge pull request (#\d+) from ((.*?)\n\n([^\n]*).*)/m)
      pr_id, full_message, branch_name, pr_title = match.captures

      # puts "pr_id = #{pr_id}"
      # puts "branch_name = #{branch_name}"
      # puts "pr_title = #{pr_title}"
      # puts "full_message = #{full_message}"
      prefixes = @config[:v1config][:type_prefixes].keys.join('|')
      stories = full_message.scan(/\b([#{prefixes}]-\d{4,6})\b/m)
      v1_stories = {}

      stories.each do |story_array|
        story = story_array[0]

        v1_stories[story] = @v1.getAsset(story)
      end

      v1_stories.each do |story_id, v1_story|
        if v1_story.nil?
          v1_title = 'Cannot Find Story in V1!'
          v1_url = ''

          puts "WARNING: Cannot Find Story [#{story_id}] in V1!"
        else
          v1_title = v1_story.getProp('Name')
          v1_url = "https://#{config[:v1config][:hostname]}/#{config[:v1config][:instance]}/story.mvc/Summary?oidToken=#{v1_story.getProp(:_sObjectType__id)}:#{v1_story.getProp(:_iObjectId__id)}"
        end

        if @args[:title] == 'git'
          title = pr_title
        else
          title = v1_title
        end
        puts "[#{story_id}] - #{title} (#{v1_url}) - PR #{pr_id} "
      end

      if v1_stories.empty?
        puts "[No Story ID] - #{pr_title} - PR #{pr_id}"
      end
    end
  end
end