Sha256: 41686468a724ca962b4582ca6b9aa40f8a240c985f02c2c7d85ddcdd000d68a6
Contents?: true
Size: 1.43 KB
Versions: 9
Compression:
Stored size: 1.43 KB
Contents
module Ninny module Repository class Gitlab attr_reader :gitlab attr_reader :project_id 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 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 def pull_request_label 'Merge Request' end def open_pull_requests gitlab.merge_requests(project_id, { state: 'opened' }).map{ |mr| to_pr(mr) } end def pull_request(id) to_pr(gitlab.merge_request(project_id, id)) end def create_merge_request_note(id, body) gitlab.create_merge_request_note(project_id, id, body) end private def to_pr(request) request && PullRequest.new(number: request.iid, title: request.title, branch: request.source_branch, description: request.description, comment_lambda: ->(body) { Ninny.repo.create_merge_request_note(request.iid, body) }) end end end end
Version data entries
9 entries across 9 versions & 1 rubygems