class Deodorant::Repo
Public Class Methods
default_git_client()
click to toggle source
# File lib/deodorant/repo.rb, line 6 def self.default_git_client Git.open(Dir.pwd) end
new(github_url: nil, gerrit_url: nil, git_client: nil)
click to toggle source
# File lib/deodorant/repo.rb, line 10 def initialize(github_url: nil, gerrit_url: nil, git_client: nil) @git_client = git_client || Repo.default_git_client @github_url = github_url || @git_client.remote('github').url @gerrit_url = gerrit_url || @git_client.remote('gerrit').url end
Public Instance Methods
pr_to_gerrit(pr_number:)
click to toggle source
# File lib/deodorant/repo.rb, line 22 def pr_to_gerrit(pr_number:) current_branch = @git_client.current_branch begin github = Github.new pr = github.pull_request(number: pr_number) pr_title = pr[:title] pr_body = pr[:body] head_sha = pr[:head][:sha] base_sha = pr[:base][:sha] gerrit = Gerrit.new change_id = gerrit.squash_and_push(base_sha: base_sha, head_sha: head_sha, commit_message: "#{pr_title}\n\n#{pr_body}") github.append_change_id_to_pr(pr_number: pr_number, change_id: change_id) ensure @git_client.checkout current_branch end end
setup()
click to toggle source
# File lib/deodorant/repo.rb, line 16 def setup remotes = @git_client.remotes.map(&:name) %w[hybrid gerrit github].each {|r| send("add_#{r}_remote") unless remotes.include?(r)} @git_client.config('branch.master.remote', 'hybrid') end
Private Instance Methods
add_gerrit_remote()
click to toggle source
# File lib/deodorant/repo.rb, line 50 def add_gerrit_remote @git_client.add_remote('gerrit', @gerrit_url) end
add_github_remote()
click to toggle source
# File lib/deodorant/repo.rb, line 46 def add_github_remote @git_client.add_remote('github', @github_url) end
add_hybrid_remote()
click to toggle source
# File lib/deodorant/repo.rb, line 41 def add_hybrid_remote @git_client.add_remote('hybrid', @gerrit_url) @git_client.config('remote.hybrid.pushurl', @github_url) end