Class: Deodorant::Gerrit

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

Instance Method Summary collapse

Constructor Details

#initialize(gerry: nil, git_client: nil) ⇒ Gerrit

Returns a new instance of Gerrit.



6
7
8
9
10
11
12
13
# File 'lib/deodorant/gerrit.rb', line 6

def initialize(gerry: nil, git_client: nil)
  @git_client = git_client || Repo.default_git_client
  @gerry = gerry || Gerry.new(
    URI.parse(@git_client.remote('gerrit').url).host,
    Config.gerrit_username,
    Config.gerrit_password
  )
end

Instance Method Details

#parse_change_id(commit_message:) ⇒ Object



27
28
29
# File 'lib/deodorant/gerrit.rb', line 27

def parse_change_id(commit_message:)
  change_id = %r{Change-Id: (\d*\w*)$}.match(commit_message).captures.first
end

#squash_and_push(base_sha:, head_sha:, commit_message:) ⇒ Object

def push_comments(comms:) end



18
19
20
21
22
23
24
25
# File 'lib/deodorant/gerrit.rb', line 18

def squash_and_push(base_sha:, head_sha:, commit_message:)
  @git_client.checkout head_sha
  @git_client.reset base_sha
  @git_client.add(all: true)
  @git_client.commit(commit_message)
  @git_client.push('gerrit', 'HEAD:refs/for/master')
  parse_change_id(commit_message: @git_client.log.first.message)
end