Class: RepoProvider::Github

Inherits:
Object
  • Object
show all
Defined in:
lib/git-issues/providers/github.rb

Overview

API documentation: developer.github.com/v3/

Constant Summary collapse

URL_PATTERNS =
[
  /^(ssh:\/\/)[email protected]:(?<user>[^\/]+)\/(?<repo>.+)\.git$/,
  /^https:\/\/github.com\/(?<user>[^\/]+)\/(?<repo>.+)\.git$/
]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.get_repo(url) ⇒ Object



13
14
15
16
# File 'lib/git-issues/providers/github.rb', line 13

def self.get_repo url
  # find the url pattern that matches the url
  URL_PATTERNS.map{|p| p.match url }.compact.first
end

Instance Method Details

#issue_close(id) ⇒ Object



37
38
39
40
# File 'lib/git-issues/providers/github.rb', line 37

def issue_close id
  ret = github.close_issue gh_repo, id
  ret[:state] == 'closed'
end

#issue_create(title, content) ⇒ Object



27
28
29
30
# File 'lib/git-issues/providers/github.rb', line 27

def issue_create title, content
  ret = github.create_issue gh_repo, title, content
  ret.attrs && ret.attrs[:number] || -1
end

#issue_delete(id) ⇒ Object



42
43
44
# File 'lib/git-issues/providers/github.rb', line 42

def issue_delete id
  log.warn "You can't delete issues on GitHub. Please close/resolve them instead."
end

#issue_reopen(id) ⇒ Object



32
33
34
35
# File 'lib/git-issues/providers/github.rb', line 32

def issue_reopen id
  ret = github.reopen_issue gh_repo, id
  ret[:state] == 'open'
end

#issues_list(opts = {}) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/git-issues/providers/github.rb', line 18

def issues_list opts = {}
  # get open issues for this repo
  issues = github.issues gh_repo
  # get all closed issues if required
  issues += github.issues( gh_repo, state: 'closed' ) if opts[:all]
  # return issues
  format_issues( issues )
end

#providerObject



46
47
48
# File 'lib/git-issues/providers/github.rb', line 46

def provider
  github
end