Class: GitReleaseNotes::GitAdapter

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

Instance Method Summary collapse

Constructor Details

#initialize(dir = Dir.pwd) ⇒ GitAdapter

Returns a new instance of GitAdapter.



5
6
7
# File 'lib/git_release_notes/git_adapter.rb', line 5

def initialize(dir=Dir.pwd)
  @dir = dir
end

Instance Method Details

#logs_messages_between_sha(commit) ⇒ Object



16
17
18
19
20
21
# File 'lib/git_release_notes/git_adapter.rb', line 16

def logs_messages_between_sha(commit)
  logs = client.log.between(commit, 'HEAD')
  logs.map do |c|
    c.message
  end
end

#messages_for_pattern(commit, regexp) ⇒ Object



9
10
11
12
13
14
# File 'lib/git_release_notes/git_adapter.rb', line 9

def messages_for_pattern(commit, regexp)
  logs = logs_messages_between_sha(commit);
  logs
    .select { |l| l[regexp] }
    .map { |l| { key: l[regexp], git_message: l } }
end