Class: Releaser::ChangeLog

Inherits:
Object
  • Object
show all
Defined in:
lib/releaser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo, tag, commits) ⇒ ChangeLog

Returns a new instance of ChangeLog.



9
10
11
# File 'lib/releaser.rb', line 9

def initialize(repo, tag, commits)
  @repo, @tag, @commits = repo, tag, commits
end

Instance Attribute Details

#commitsObject

Returns the value of attribute commits.



7
8
9
# File 'lib/releaser.rb', line 7

def commits
  @commits
end

#repoObject

Returns the value of attribute repo.



7
8
9
# File 'lib/releaser.rb', line 7

def repo
  @repo
end

#tagObject

Returns the value of attribute tag.



7
8
9
# File 'lib/releaser.rb', line 7

def tag
  @tag
end

Instance Method Details

#formatObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/releaser.rb', line 25

def format
  lines = ["Release #{name}: #{tag.time}"]
  lines << "\nTickets Resolved:"
  tickets.each do |t|
    lines << " * #{t} - #{jira_url}/browse/#{t}"
  end

  lines << "\nCommits:"
  commits.each do |c|
    author = c.author[:name]
    message = c.message.split("\n")[0]
    lines << " * [#{author}] #{message} (#{c.oid[0..8]})"
  end
  lines.join("\n")
end

#jira_prefixObject



17
18
19
# File 'lib/releaser.rb', line 17

def jira_prefix
  repo.repo.config['releaser.jira.prefix']
end

#jira_urlObject



21
22
23
# File 'lib/releaser.rb', line 21

def jira_url
  repo.repo.config['releaser.jira.url']
end

#nameObject



13
14
15
# File 'lib/releaser.rb', line 13

def name
  tag.name
end

#ticketsObject



41
42
43
44
45
# File 'lib/releaser.rb', line 41

def tickets
  @tickets ||= Set.new(commits.flat_map { |c|
    c.message.match(/#{jira_prefix}-\d+/) { |m| m && m[0] }
  }.compact)
end