Module: Octopolo::GitHub
- Extended by:
- UserConfigWrapper
- Defined in:
- lib/octopolo/github.rb,
lib/octopolo/github/user.rb,
lib/octopolo/github/issue.rb,
lib/octopolo/github/label.rb,
lib/octopolo/github/commit.rb,
lib/octopolo/github/pull_request.rb,
lib/octopolo/github/issue_creator.rb,
lib/octopolo/github/pull_request_creator.rb
Defined Under Namespace
Classes: Commit, Issue, IssueCreator, Label, PullRequest, PullRequestCreator, User
Constant Summary
collapse
- UNKNOWN_USER =
Used as the name of a user if we can’t find it on GitHub’s API
"Unknown User"
- TryAgain =
now that you’ve set up your credentials, try again
Class.new(StandardError)
- BadCredentials =
the credentials you’ve entered are bad
Class.new(StandardError)
Instance Attribute Summary
#user_config
Class Method Summary
collapse
Class Method Details
82
83
84
|
# File 'lib/octopolo/github.rb', line 82
def self. *args
client. *args
end
|
.add_label(*args) ⇒ Object
104
105
106
|
# File 'lib/octopolo/github.rb', line 104
def self.add_label *args
client.add_label *args
end
|
.add_labels_to_issue(*args) ⇒ Object
112
113
114
|
# File 'lib/octopolo/github.rb', line 112
def self.add_labels_to_issue *args
client.add_labels_to_an_issue *args
end
|
.check_connection ⇒ Object
Public: Check that GitHub credentials have been properly set up
47
48
49
50
51
52
|
# File 'lib/octopolo/github.rb', line 47
def self.check_connection
client.user && nil
rescue Octokit::Unauthorized
raise BadCredentials, "Your stored credentials were rejected by GitHub. Run `op github-auth` to generate a new token."
end
|
.client(options = {}) ⇒ Object
Public: A GitHub client object
35
36
37
38
39
|
# File 'lib/octopolo/github.rb', line 35
def self.client(options = {})
Octokit::Client.new(options.merge(login: user_config.github_user, access_token: user_config.github_token))
rescue UserConfig::MissingGitHubAuth
raise TryAgain, "No GitHub API token stored. Please run `op github-auth` to generate your token."
end
|
.connect(&block) ⇒ Object
Public: Perform the given block if the user has valid GitHub credentials
When performing anything that connects to GitHub, wrap with GitHub.connect to ensure that the user’s credentials are all set up before running anything.
Example:
GitHub.connect do
end
.crawling_client ⇒ Object
Public: A GitHub client configured to crawl through pages
42
43
44
|
# File 'lib/octopolo/github.rb', line 42
def self.crawling_client
client(auto_traversal: true)
end
|
.create_issue(*args) ⇒ Object
78
79
80
|
# File 'lib/octopolo/github.rb', line 78
def self.create_issue *args
client.create_issue *args
end
|
.create_pull_request(*args) ⇒ Object
70
71
72
|
# File 'lib/octopolo/github.rb', line 70
def self.create_pull_request *args
client.create_pull_request *args
end
|
.excluded_users ⇒ Object
96
97
98
|
# File 'lib/octopolo/github.rb', line 96
def self.excluded_users
["tst-octopolo"]
end
|
.issue(*args) ⇒ Object
74
75
76
|
# File 'lib/octopolo/github.rb', line 74
def self.issue *args
client.issue *args
end
|
62
63
64
|
# File 'lib/octopolo/github.rb', line 62
def self. *args
client. *args
end
|
.labels(*args) ⇒ Object
100
101
102
|
# File 'lib/octopolo/github.rb', line 100
def self.labels *args
client.labels *args
end
|
.org_repos(org_name = "sportngin") ⇒ Object
92
93
94
|
# File 'lib/octopolo/github.rb', line 92
def self.org_repos org_name="sportngin"
crawling_client.organization_repositories org_name
end
|
.pull_request(*args) ⇒ Object
54
55
56
|
# File 'lib/octopolo/github.rb', line 54
def self.pull_request *args
client.pull_request *args
end
|
.pull_request_commits(*args) ⇒ Object
58
59
60
|
# File 'lib/octopolo/github.rb', line 58
def self.pull_request_commits *args
client.pull_request_commits *args
end
|
.pull_requests(*args) ⇒ Object
66
67
68
|
# File 'lib/octopolo/github.rb', line 66
def self.pull_requests *args
crawling_client.pull_requests *args
end
|
.remove_label(*args) ⇒ Object
108
109
110
|
# File 'lib/octopolo/github.rb', line 108
def self.remove_label *args
client.remove_label *args
end
|
.search_issues(*args) ⇒ Object
116
117
118
|
# File 'lib/octopolo/github.rb', line 116
def self.search_issues *args
client.search_issues *args
end
|
.status(*args) ⇒ Object
120
121
122
|
# File 'lib/octopolo/github.rb', line 120
def self.status *args
client.status *args
end
|
.team_member?(team) ⇒ Boolean
124
125
126
|
# File 'lib/octopolo/github.rb', line 124
def self.team_member? team
client.team_member? team, user_config.github_user
end
|
.user(username) ⇒ Object
86
87
88
89
90
|
# File 'lib/octopolo/github.rb', line 86
def self.user username
client.user(username)
rescue
Hashie::Mash.new(name: UNKNOWN_USER)
end
|