Class: Ninny::Repository::Gitlab

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGitlab

Returns a new instance of Gitlab.



6
7
8
9
10
# File 'lib/ninny/repository/gitlab.rb', line 6

def initialize
  @gitlab = ::Gitlab.client(endpoint: Ninny.project_config.gitlab_endpoint,
                            private_token: Ninny.user_config.gitlab_private_token)
  @project_id = Ninny.project_config.gitlab_project_id
end

Instance Attribute Details

#gitlabObject (readonly)

Returns the value of attribute gitlab.



4
5
6
# File 'lib/ninny/repository/gitlab.rb', line 4

def gitlab
  @gitlab
end

#project_idObject (readonly)

Returns the value of attribute project_id.



5
6
7
# File 'lib/ninny/repository/gitlab.rb', line 5

def project_id
  @project_id
end

Instance Method Details

#create_merge_request_note(id, body) ⇒ Object



30
31
32
# File 'lib/ninny/repository/gitlab.rb', line 30

def create_merge_request_note(id, body)
  gitlab.create_merge_request_note(project_id, id, body)
end

#current_pull_requestObject



12
13
14
15
16
# File 'lib/ninny/repository/gitlab.rb', line 12

def current_pull_request
  to_pr(gitlab.merge_requests(project_id, { source_branch: Ninny.git.current_branch.name,
                                            target_branch: Ninny.project_config.deploy_branch })
              .last)
end

#open_pull_requestsObject



22
23
24
# File 'lib/ninny/repository/gitlab.rb', line 22

def open_pull_requests
  gitlab.merge_requests(project_id, { state: 'opened' }).map{ |mr| to_pr(mr) }
end

#pull_request(id) ⇒ Object



26
27
28
# File 'lib/ninny/repository/gitlab.rb', line 26

def pull_request(id)
  to_pr(gitlab.merge_request(project_id, id))
end

#pull_request_labelObject



18
19
20
# File 'lib/ninny/repository/gitlab.rb', line 18

def pull_request_label
  'Merge Request'
end