class Pronto::Bitbucket
Public Instance Methods
approve_pull_request()
click to toggle source
# File lib/pronto/bitbucket.rb, line 35 def approve_pull_request client.approve_pull_request(slug, pull_id) end
commit_comments(sha)
click to toggle source
# File lib/pronto/bitbucket.rb, line 11 def commit_comments(sha) @comment_cache[sha.to_s] ||= begin client.commit_comments(slug, sha).map do |comment| Comment.new(sha, comment.content, comment.filename, comment.line_to) end end end
create_commit_comment(comment)
click to toggle source
# File lib/pronto/bitbucket.rb, line 19 def create_commit_comment(comment) @config.logger.log("Creating commit comment on #{comment.sha}") client.create_commit_comment(slug, comment.sha, comment.body, comment.path, comment.position) end
create_pull_comment(comment)
click to toggle source
# File lib/pronto/bitbucket.rb, line 25 def create_pull_comment(comment) if comment.path && comment.position @config.logger.log("Creating pull request comment on #{pull_id}") client.create_pull_comment(slug, pull_id, comment.body, comment.path, comment.position) else create_commit_comment(comment) end end
pull_comments(sha)
click to toggle source
# File lib/pronto/bitbucket.rb, line 3 def pull_comments(sha) @comment_cache["#{pull_id}/#{sha}"] ||= begin client.pull_comments(slug, pull_id).map do |comment| Comment.new(sha, comment.content, comment.filename, comment.line_to) end end end
unapprove_pull_request()
click to toggle source
# File lib/pronto/bitbucket.rb, line 39 def unapprove_pull_request client.unapprove_pull_request(slug, pull_id) end
Private Instance Methods
client()
click to toggle source
# File lib/pronto/bitbucket.rb, line 55 def client @client ||= BitbucketClient.new(@config.bitbucket_username, @config.bitbucket_password) end
pull()
click to toggle source
# File lib/pronto/bitbucket.rb, line 64 def pull @pull ||= if env_pull_id pull_requests.find { |pr| pr.id.to_i == env_pull_id } elsif @repo.branch pull_requests.find do |pr| pr.source['branch']['name'] == @repo.branch end end end
pull_id()
click to toggle source
# File lib/pronto/bitbucket.rb, line 60 def pull_id pull ? pull.id.to_i : env_pull_id end
pull_requests()
click to toggle source
# File lib/pronto/bitbucket.rb, line 74 def pull_requests @pull_requests ||= client.pull_requests(slug) end
slug()
click to toggle source
# File lib/pronto/bitbucket.rb, line 44 def slug return @config.bitbucket_slug if @config.bitbucket_slug @slug ||= begin @repo.remote_urls.map do |url| hostname = Regexp.escape(@config.bitbucket_hostname) match = %r{.*#{hostname}(:|\/)(?<slug>.*?)(?:\.git)?\z}.match(url) match[:slug] if match end.compact.first end end