class RepoProvider::Gitlab
API documentation: api.gitlab.org/
Constants
- URL_PATTERNS
Public Class Methods
get_repo(url)
click to toggle source
# File lib/git-issues/providers/gitlab.rb, line 12 def self.get_repo url # find the url pattern that matches the url URL_PATTERNS.map{|p| p.match url }.compact.first end
Public Instance Methods
issue_close(id)
click to toggle source
# File lib/git-issues/providers/gitlab.rb, line 33 def issue_close id gitlab.close_issue gl_project_id, id end
issue_create(title, content)
click to toggle source
# File lib/git-issues/providers/gitlab.rb, line 25 def issue_create title, content gitlab.create_issue gl_project_id, title, description: content end
issue_delete(id)
click to toggle source
# File lib/git-issues/providers/gitlab.rb, line 37 def issue_delete id log.warn "You can't delete issues on Gitlab anymore, it is deprecated. Please close/resolve them instead." end
issue_reopen(id)
click to toggle source
# File lib/git-issues/providers/gitlab.rb, line 29 def issue_reopen id gitlab.reopen_issue gl_project_id, id end
issues_list(opts = {})
click to toggle source
# File lib/git-issues/providers/gitlab.rb, line 17 def issues_list opts = {} issues = gitlab.issues gl_project_id # filter out closed issues if desired issues = issues.find_all{|i| i.state != 'closed' } if not opts[:all] # return issues format_issues( issues ) end
provider()
click to toggle source
# File lib/git-issues/providers/gitlab.rb, line 41 def provider gitlab end
Private Instance Methods
format_issues(is)
click to toggle source
# File lib/git-issues/providers/gitlab.rb, line 56 def format_issues is Array(is).map do |i| { 'number' => i.iid, 'title' => i.title, 'description' => i.description, 'state' => i.state } end end
gitlab()
click to toggle source
# File lib/git-issues/providers/gitlab.rb, line 67 def gitlab init_gitlab if @gitlab.nil? @gitlab end
gl_project_id()
click to toggle source
# File lib/git-issues/providers/gitlab.rb, line 47 def gl_project_id @gl_project_id ||= begin path = "#{repo['user']}/#{repo['repo']}" p = gitlab.projects.find{|p| p.path_with_namespace == path} log.info "using project id = #{p.id} (#{p.path_with_namespace})" if not p.nil? (p.nil?) ? nil : p.id end end
init_gitlab()
click to toggle source
# File lib/git-issues/providers/gitlab.rb, line 72 def init_gitlab ot = oauth_token @gitlab = Gitlab.client endpoint: "http://#{repo['host']}/api/v3", private_token: ot end