Class: Pronto::Bitbucket

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

Instance Method Summary collapse

Constructor Details

#initialize(repo) ⇒ Bitbucket

Returns a new instance of Bitbucket.



3
4
5
6
7
8
# File 'lib/pronto/bitbucket.rb', line 3

def initialize(repo)
  @repo = repo
  @config = Config.new
  @comment_cache = {}
  @pull_id_cache = {}
end

Instance Method Details

#commit_comments(sha) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/pronto/bitbucket.rb', line 18

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) ⇒ Object



26
27
28
29
30
# File 'lib/pronto/bitbucket.rb', line 26

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) ⇒ Object



32
33
34
35
36
# File 'lib/pronto/bitbucket.rb', line 32

def create_pull_comment(comment)
  @config.logger.log("Creating pull request comment on #{pull_id}")
  client.create_pull_comment(slug, pull_id, comment.body,
                             comment.path, comment.position)
end

#pull_comments(sha) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/pronto/bitbucket.rb', line 10

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