Class: Pronto::Gitlab

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

Instance Method Summary collapse

Constructor Details

#initialize(repo) ⇒ Gitlab

Returns a new instance of Gitlab.



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

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

Instance Method Details

#commit_comments(sha) ⇒ Object



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

def commit_comments(sha)
  @comment_cache[sha.to_s] ||= begin
    client.commit_comments(slug, sha, per_page: 500).map do |comment|
      Comment.new(sha, comment.note, comment.path, comment.line)
    end
  end
end

#create_commit_comment(comment) ⇒ Object



17
18
19
20
21
22
# File 'lib/pronto/gitlab.rb', line 17

def create_commit_comment(comment)
  @config.logger.log("Creating commit comment on #{comment.sha}")
  client.create_commit_comment(slug, comment.sha, comment.body,
                               path: comment.path, line: comment.position,
                               line_type: 'new')
end