forked from travis-ci/travis-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub.rb
More file actions
22 lines (20 loc) · 695 Bytes
/
Copy pathgithub.rb
File metadata and controls
22 lines (20 loc) · 695 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module Travis
module Github
require 'travis/github/services'
class << self
def authenticated(user, &block)
fail "we don't have a github token for #{user.inspect}" if user.github_oauth_token.blank?
GH.with(:token => user.github_oauth_token, &block)
end
# TODO: Maybe this should move to gh?
def scopes_for(token)
token = token.github_oauth_token if token.respond_to? :github_oauth_token
scopes = GH.with(token: token.to_s) { GH.head('user') }.headers['x-oauth-scopes'] if token.present?
scopes &&= scopes.gsub(/\s/,'').split(',')
Array(scopes).sort
rescue GH::Error
[]
end
end
end
end