github_api2 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +770 -0
- data/LICENSE.txt +20 -0
- data/README.md +741 -0
- data/lib/github_api2/api/actions.rb +60 -0
- data/lib/github_api2/api/arguments.rb +253 -0
- data/lib/github_api2/api/config/property.rb +30 -0
- data/lib/github_api2/api/config/property_set.rb +120 -0
- data/lib/github_api2/api/config.rb +105 -0
- data/lib/github_api2/api/factory.rb +33 -0
- data/lib/github_api2/api.rb +398 -0
- data/lib/github_api2/authorization.rb +75 -0
- data/lib/github_api2/client/activity/events.rb +233 -0
- data/lib/github_api2/client/activity/feeds.rb +50 -0
- data/lib/github_api2/client/activity/notifications.rb +181 -0
- data/lib/github_api2/client/activity/starring.rb +130 -0
- data/lib/github_api2/client/activity/watching.rb +176 -0
- data/lib/github_api2/client/activity.rb +31 -0
- data/lib/github_api2/client/authorizations/app.rb +98 -0
- data/lib/github_api2/client/authorizations.rb +142 -0
- data/lib/github_api2/client/emojis.rb +19 -0
- data/lib/github_api2/client/gists/comments.rb +100 -0
- data/lib/github_api2/client/gists.rb +289 -0
- data/lib/github_api2/client/git_data/blobs.rb +51 -0
- data/lib/github_api2/client/git_data/commits.rb +101 -0
- data/lib/github_api2/client/git_data/references.rb +150 -0
- data/lib/github_api2/client/git_data/tags.rb +95 -0
- data/lib/github_api2/client/git_data/trees.rb +113 -0
- data/lib/github_api2/client/git_data.rb +31 -0
- data/lib/github_api2/client/gitignore.rb +57 -0
- data/lib/github_api2/client/issues/assignees.rb +77 -0
- data/lib/github_api2/client/issues/comments.rb +146 -0
- data/lib/github_api2/client/issues/events.rb +50 -0
- data/lib/github_api2/client/issues/labels.rb +189 -0
- data/lib/github_api2/client/issues/milestones.rb +146 -0
- data/lib/github_api2/client/issues.rb +248 -0
- data/lib/github_api2/client/markdown.rb +62 -0
- data/lib/github_api2/client/meta.rb +19 -0
- data/lib/github_api2/client/orgs/hooks.rb +182 -0
- data/lib/github_api2/client/orgs/members.rb +142 -0
- data/lib/github_api2/client/orgs/memberships.rb +131 -0
- data/lib/github_api2/client/orgs/projects.rb +57 -0
- data/lib/github_api2/client/orgs/teams.rb +407 -0
- data/lib/github_api2/client/orgs.rb +127 -0
- data/lib/github_api2/client/projects/cards.rb +158 -0
- data/lib/github_api2/client/projects/columns.rb +146 -0
- data/lib/github_api2/client/projects.rb +83 -0
- data/lib/github_api2/client/pull_requests/comments.rb +140 -0
- data/lib/github_api2/client/pull_requests/reviews.rb +158 -0
- data/lib/github_api2/client/pull_requests.rb +195 -0
- data/lib/github_api2/client/repos/branches/protections.rb +75 -0
- data/lib/github_api2/client/repos/branches.rb +48 -0
- data/lib/github_api2/client/repos/collaborators.rb +84 -0
- data/lib/github_api2/client/repos/comments.rb +125 -0
- data/lib/github_api2/client/repos/commits.rb +80 -0
- data/lib/github_api2/client/repos/contents.rb +263 -0
- data/lib/github_api2/client/repos/deployments.rb +138 -0
- data/lib/github_api2/client/repos/downloads.rb +62 -0
- data/lib/github_api2/client/repos/forks.rb +50 -0
- data/lib/github_api2/client/repos/hooks.rb +214 -0
- data/lib/github_api2/client/repos/invitations.rb +41 -0
- data/lib/github_api2/client/repos/keys.rb +104 -0
- data/lib/github_api2/client/repos/merging.rb +47 -0
- data/lib/github_api2/client/repos/pages.rb +48 -0
- data/lib/github_api2/client/repos/projects.rb +62 -0
- data/lib/github_api2/client/repos/pub_sub_hubbub.rb +133 -0
- data/lib/github_api2/client/repos/releases/assets.rb +136 -0
- data/lib/github_api2/client/repos/releases/tags.rb +24 -0
- data/lib/github_api2/client/repos/releases.rb +189 -0
- data/lib/github_api2/client/repos/statistics.rb +89 -0
- data/lib/github_api2/client/repos/statuses.rb +91 -0
- data/lib/github_api2/client/repos.rb +473 -0
- data/lib/github_api2/client/say.rb +25 -0
- data/lib/github_api2/client/scopes.rb +46 -0
- data/lib/github_api2/client/search/legacy.rb +111 -0
- data/lib/github_api2/client/search.rb +133 -0
- data/lib/github_api2/client/users/emails.rb +65 -0
- data/lib/github_api2/client/users/followers.rb +115 -0
- data/lib/github_api2/client/users/keys.rb +104 -0
- data/lib/github_api2/client/users.rb +117 -0
- data/lib/github_api2/client.rb +77 -0
- data/lib/github_api2/configuration.rb +70 -0
- data/lib/github_api2/connection.rb +82 -0
- data/lib/github_api2/constants.rb +61 -0
- data/lib/github_api2/core_ext/array.rb +25 -0
- data/lib/github_api2/core_ext/hash.rb +91 -0
- data/lib/github_api2/deprecation.rb +39 -0
- data/lib/github_api2/error/client_error.rb +89 -0
- data/lib/github_api2/error/service_error.rb +223 -0
- data/lib/github_api2/error.rb +32 -0
- data/lib/github_api2/ext/faraday.rb +40 -0
- data/lib/github_api2/mash.rb +7 -0
- data/lib/github_api2/middleware.rb +37 -0
- data/lib/github_api2/mime_type.rb +33 -0
- data/lib/github_api2/normalizer.rb +23 -0
- data/lib/github_api2/null_encoder.rb +25 -0
- data/lib/github_api2/page_iterator.rb +138 -0
- data/lib/github_api2/page_links.rb +63 -0
- data/lib/github_api2/paged_request.rb +42 -0
- data/lib/github_api2/pagination.rb +115 -0
- data/lib/github_api2/parameter_filter.rb +35 -0
- data/lib/github_api2/params_hash.rb +115 -0
- data/lib/github_api2/rate_limit.rb +25 -0
- data/lib/github_api2/request/basic_auth.rb +36 -0
- data/lib/github_api2/request/jsonize.rb +54 -0
- data/lib/github_api2/request/oauth2.rb +45 -0
- data/lib/github_api2/request/verbs.rb +63 -0
- data/lib/github_api2/request.rb +84 -0
- data/lib/github_api2/response/atom_parser.rb +22 -0
- data/lib/github_api2/response/follow_redirects.rb +140 -0
- data/lib/github_api2/response/header.rb +87 -0
- data/lib/github_api2/response/jsonize.rb +28 -0
- data/lib/github_api2/response/mashify.rb +24 -0
- data/lib/github_api2/response/raise_error.rb +22 -0
- data/lib/github_api2/response/xmlize.rb +28 -0
- data/lib/github_api2/response.rb +48 -0
- data/lib/github_api2/response_wrapper.rb +161 -0
- data/lib/github_api2/ssl_certs/cacerts.pem +2183 -0
- data/lib/github_api2/utils/url.rb +63 -0
- data/lib/github_api2/validations/format.rb +26 -0
- data/lib/github_api2/validations/presence.rb +32 -0
- data/lib/github_api2/validations/required.rb +21 -0
- data/lib/github_api2/validations/token.rb +41 -0
- data/lib/github_api2/validations.rb +22 -0
- data/lib/github_api2/version.rb +5 -0
- data/lib/github_api2.rb +92 -0
- metadata +363 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
class Client::GitData::References < API
|
|
7
|
+
|
|
8
|
+
VALID_REF_PARAM_NAMES = %w[ ref sha force ].freeze
|
|
9
|
+
|
|
10
|
+
REQUIRED_REF_PARAMS = %w[ ref sha ].freeze
|
|
11
|
+
|
|
12
|
+
VALID_REF_PARAM_VALUES = {
|
|
13
|
+
'ref' => %r{^refs\/\w+(\/\w+)*} # test fully qualified reference
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
# Get all references
|
|
17
|
+
#
|
|
18
|
+
# This will return an array of all the references on the system,
|
|
19
|
+
# including things like notes and stashes if they exist on the server.
|
|
20
|
+
# Anything in the namespace, not just <tt>heads</tt> and <tt>tags</tt>,
|
|
21
|
+
# though that would be the most common.
|
|
22
|
+
#
|
|
23
|
+
# @example
|
|
24
|
+
# github = Github.new
|
|
25
|
+
# github.git_data.references.list 'user-name', 'repo-name'
|
|
26
|
+
#
|
|
27
|
+
# @example
|
|
28
|
+
# github.git_data.references.list 'user-name', 'repo-name', ref:'tags'
|
|
29
|
+
#
|
|
30
|
+
# @api public
|
|
31
|
+
def list(*args)
|
|
32
|
+
arguments(args, required: [:user, :repo])
|
|
33
|
+
params = arguments.params
|
|
34
|
+
user = arguments.user
|
|
35
|
+
repo = arguments.repo
|
|
36
|
+
|
|
37
|
+
response = if (ref = params.delete('ref'))
|
|
38
|
+
formatted_ref = validate_reference ref
|
|
39
|
+
get_request("/repos/#{user}/#{repo}/git/#{formatted_ref}", params)
|
|
40
|
+
else
|
|
41
|
+
get_request("/repos/#{user}/#{repo}/git/refs", params)
|
|
42
|
+
end
|
|
43
|
+
return response unless block_given?
|
|
44
|
+
response.each { |el| yield el }
|
|
45
|
+
end
|
|
46
|
+
alias :all :list
|
|
47
|
+
|
|
48
|
+
# Get a reference
|
|
49
|
+
#
|
|
50
|
+
# The ref in the URL must be formatted as <tt>heads/branch</tt>,
|
|
51
|
+
# not just branch. For example, the call to get the data for a
|
|
52
|
+
# branch named sc/featureA would be formatted as heads/sc/featureA
|
|
53
|
+
#
|
|
54
|
+
# @example
|
|
55
|
+
# github = Github.new
|
|
56
|
+
# github.git_data.references.get 'user-name', 'repo-name', 'heads/branch'
|
|
57
|
+
#
|
|
58
|
+
# @api public
|
|
59
|
+
def get(*args)
|
|
60
|
+
arguments(args, required: [:user, :repo, :ref])
|
|
61
|
+
validate_reference arguments.ref
|
|
62
|
+
params = arguments.params
|
|
63
|
+
|
|
64
|
+
get_request("/repos/#{arguments.user}/#{arguments.repo}/git/refs/#{arguments.ref}", params)
|
|
65
|
+
end
|
|
66
|
+
alias :find :get
|
|
67
|
+
|
|
68
|
+
# Create a reference
|
|
69
|
+
#
|
|
70
|
+
# @param [Hash] params
|
|
71
|
+
# @input params [String] :ref
|
|
72
|
+
# The name of the fully qualified reference (ie: refs/heads/master).
|
|
73
|
+
# If it doesn’t start with ‘refs’ and have at least two slashes,
|
|
74
|
+
# it will be rejected.
|
|
75
|
+
# @input params [String] :sha
|
|
76
|
+
# The SHA1 value to set this reference to
|
|
77
|
+
#
|
|
78
|
+
# @example
|
|
79
|
+
# github = Github.new
|
|
80
|
+
# github.git_data.references.create 'user-name', 'repo-name',
|
|
81
|
+
# ref: "refs/heads/master",
|
|
82
|
+
# sha: "827efc6d56897b048c772eb4087f854f46256132"
|
|
83
|
+
#
|
|
84
|
+
# @api public
|
|
85
|
+
def create(*args)
|
|
86
|
+
arguments(args, required: [:user, :repo]) do
|
|
87
|
+
permit VALID_REF_PARAM_NAMES
|
|
88
|
+
assert_required REQUIRED_REF_PARAMS
|
|
89
|
+
end
|
|
90
|
+
params = arguments.params
|
|
91
|
+
validate_reference params['ref']
|
|
92
|
+
|
|
93
|
+
post_request("/repos/#{arguments.user}/#{arguments.repo}/git/refs", params)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Update a reference
|
|
97
|
+
#
|
|
98
|
+
# @param [Hash] params
|
|
99
|
+
# @input params [String] :sha
|
|
100
|
+
# The SHA1 value to set this reference to
|
|
101
|
+
# @input params [Boolean] :force
|
|
102
|
+
# Indicates whether to force the update or to make sure the update
|
|
103
|
+
# is a fast-forward update. Leaving this out or setting it to false
|
|
104
|
+
# will make sure you’re not overwriting work. Default: false
|
|
105
|
+
#
|
|
106
|
+
# @example
|
|
107
|
+
# github = Github.new
|
|
108
|
+
# github.git_data.references.update 'user-name', 'repo-name', 'heads/master',
|
|
109
|
+
# sha: "827efc6d56897b048c772eb4087f854f46256132",
|
|
110
|
+
# force: true
|
|
111
|
+
#
|
|
112
|
+
# @api public
|
|
113
|
+
def update(*args)
|
|
114
|
+
arguments(args, required: [:user, :repo, :ref]) do
|
|
115
|
+
permit VALID_REF_PARAM_NAMES
|
|
116
|
+
assert_required %w[ sha ]
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
patch_request("/repos/#{arguments.user}/#{arguments.repo}/git/refs/#{arguments.ref}", arguments.params)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Delete a reference
|
|
123
|
+
#
|
|
124
|
+
# @example
|
|
125
|
+
# github = Github.new
|
|
126
|
+
# github.git_data.references.delete 'user-name', 'repo-name',
|
|
127
|
+
# "heads/master"
|
|
128
|
+
#
|
|
129
|
+
# @api public
|
|
130
|
+
def delete(*args)
|
|
131
|
+
arguments(args, required: [:user, :repo, :ref])
|
|
132
|
+
params = arguments.params
|
|
133
|
+
|
|
134
|
+
delete_request("/repos/#{arguments.user}/#{arguments.repo}/git/refs/#{arguments.ref}", params)
|
|
135
|
+
end
|
|
136
|
+
alias :remove :delete
|
|
137
|
+
|
|
138
|
+
private
|
|
139
|
+
|
|
140
|
+
def validate_reference(ref)
|
|
141
|
+
refs = (ref =~ (/^(\/)?refs.*/) ? ref : "refs/#{ref}").gsub(/(\/)+/, '/')
|
|
142
|
+
refs.gsub!(/^\//, '')
|
|
143
|
+
unless VALID_REF_PARAM_VALUES['ref'] =~ refs
|
|
144
|
+
raise ArgumentError, "Provided 'reference' is invalid"
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
refs
|
|
148
|
+
end
|
|
149
|
+
end # GitData::References
|
|
150
|
+
end # Github
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
class Client::GitData::Tags < API
|
|
7
|
+
# This tags api only deals with tag objects -
|
|
8
|
+
# so only annotated tags, not lightweight tags.
|
|
9
|
+
# Refer https://developer.github.com/v3/git/tags/#parameters
|
|
10
|
+
|
|
11
|
+
VALID_TAG_PARAM_NAMES = %w[
|
|
12
|
+
tag
|
|
13
|
+
message
|
|
14
|
+
object
|
|
15
|
+
type
|
|
16
|
+
name
|
|
17
|
+
email
|
|
18
|
+
date
|
|
19
|
+
tagger
|
|
20
|
+
].freeze
|
|
21
|
+
|
|
22
|
+
VALID_TAG_PARAM_VALUES = {
|
|
23
|
+
'type' => %w[ blob tree commit ]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
# Get a tag
|
|
27
|
+
#
|
|
28
|
+
# @example
|
|
29
|
+
# github = Github.new
|
|
30
|
+
# github.git_data.tags.get 'user-name', 'repo-name', 'sha'
|
|
31
|
+
#
|
|
32
|
+
# @api public
|
|
33
|
+
def get(*args)
|
|
34
|
+
arguments(args, required: [:user, :repo, :sha])
|
|
35
|
+
params = arguments.params
|
|
36
|
+
|
|
37
|
+
get_request("/repos/#{arguments.user}/#{arguments.repo}/git/tags/#{arguments.sha}", params)
|
|
38
|
+
end
|
|
39
|
+
alias :find :get
|
|
40
|
+
|
|
41
|
+
# Create a tag object
|
|
42
|
+
#
|
|
43
|
+
# Note that creating a tag object does not create the reference that
|
|
44
|
+
# makes a tag in Git. If you want to create an annotated tag in Git,
|
|
45
|
+
# you have to do this call to create the tag object, and then create
|
|
46
|
+
# the refs/tags/[tag] reference. If you want to create a lightweight
|
|
47
|
+
# tag, you simply have to create the reference -
|
|
48
|
+
# this call would be unnecessary.
|
|
49
|
+
#
|
|
50
|
+
# @param [Hash] params
|
|
51
|
+
# @input params [String] :tag
|
|
52
|
+
# The tag
|
|
53
|
+
# @input params [String] :message
|
|
54
|
+
# The tag message
|
|
55
|
+
# @input params [String] :object
|
|
56
|
+
# The SHA of the git object this is tagging
|
|
57
|
+
# @input params [String] :type
|
|
58
|
+
# The type of the object we're tagging.
|
|
59
|
+
# Normally this is a commit but it can also be a tree or a blob
|
|
60
|
+
# @input params [Hash] :tagger
|
|
61
|
+
# A hash with information about the individual creating the tag.
|
|
62
|
+
#
|
|
63
|
+
# The tagger hash contains the following keys:
|
|
64
|
+
# @input tagger [String] :name
|
|
65
|
+
# The name of the author of the tag
|
|
66
|
+
# @input tagger [String] :email
|
|
67
|
+
# The email of the author of the tag
|
|
68
|
+
# @input tagger [String] :date
|
|
69
|
+
# When this object was tagged. This is a timestamp in ISO 8601
|
|
70
|
+
# format: YYYY-MM-DDTHH:MM:SSZ.
|
|
71
|
+
#
|
|
72
|
+
# @xample
|
|
73
|
+
# github = Github.new
|
|
74
|
+
# github.git_data.tags.create 'user-name', 'repo-name',
|
|
75
|
+
# tag: "v0.0.1",
|
|
76
|
+
# message: "initial version\n",
|
|
77
|
+
# type: "commit",
|
|
78
|
+
# object: "c3d0be41ecbe669545ee3e94d31ed9a4bc91ee3c",
|
|
79
|
+
# tagger: {
|
|
80
|
+
# name: "Scott Chacon",
|
|
81
|
+
# email: "schacon@gmail.com",
|
|
82
|
+
# date: "2011-06-17T14:53:3"
|
|
83
|
+
# }
|
|
84
|
+
#
|
|
85
|
+
# @api public
|
|
86
|
+
def create(*args)
|
|
87
|
+
arguments(args, required: [:user, :repo]) do
|
|
88
|
+
permit VALID_TAG_PARAM_NAMES
|
|
89
|
+
assert_values VALID_TAG_PARAM_VALUES
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
post_request("/repos/#{arguments.user}/#{arguments.repo}/git/tags", arguments.params)
|
|
93
|
+
end
|
|
94
|
+
end # GitData::Tags
|
|
95
|
+
end # Github
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
class Client::GitData::Trees < API
|
|
7
|
+
|
|
8
|
+
VALID_TREE_PARAM_NAMES = %w[
|
|
9
|
+
base_tree
|
|
10
|
+
tree
|
|
11
|
+
path
|
|
12
|
+
mode
|
|
13
|
+
type
|
|
14
|
+
sha
|
|
15
|
+
content
|
|
16
|
+
url
|
|
17
|
+
].freeze
|
|
18
|
+
|
|
19
|
+
VALID_TREE_PARAM_VALUES = {
|
|
20
|
+
'mode' => %w[ 100644 100755 040000 160000 120000 ],
|
|
21
|
+
'type' => %w[ blob tree commit ]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
# Get a tree
|
|
25
|
+
#
|
|
26
|
+
# @example
|
|
27
|
+
# github = Github.new
|
|
28
|
+
# github.git_data.trees.get 'user-name', 'repo-name', 'sha'
|
|
29
|
+
# github.git_data.trees.get 'user-name', 'repo-name', 'sha' do |file|
|
|
30
|
+
# file.path
|
|
31
|
+
# end
|
|
32
|
+
#
|
|
33
|
+
# Get a tree recursively
|
|
34
|
+
#
|
|
35
|
+
# @example
|
|
36
|
+
# github = Github.new
|
|
37
|
+
# github.git_data.trees.get 'user-name', 'repo-name', 'sha', recursive: true
|
|
38
|
+
#
|
|
39
|
+
# @api public
|
|
40
|
+
def get(*args)
|
|
41
|
+
arguments(args, required: [:user, :repo, :sha])
|
|
42
|
+
user = arguments.user
|
|
43
|
+
repo = arguments.repo
|
|
44
|
+
sha = arguments.sha
|
|
45
|
+
params = arguments.params
|
|
46
|
+
|
|
47
|
+
response = if params['recursive']
|
|
48
|
+
params['recursive'] = 1
|
|
49
|
+
get_request("/repos/#{user}/#{repo}/git/trees/#{sha}", params)
|
|
50
|
+
else
|
|
51
|
+
get_request("/repos/#{user}/#{repo}/git/trees/#{sha.to_s}", params)
|
|
52
|
+
end
|
|
53
|
+
return response unless block_given?
|
|
54
|
+
response.tree.each { |el| yield el }
|
|
55
|
+
end
|
|
56
|
+
alias :find :get
|
|
57
|
+
|
|
58
|
+
# Create a tree
|
|
59
|
+
#
|
|
60
|
+
# The tree creation API will take nested entries as well.
|
|
61
|
+
# If both a tree and a nested path modifying that tree are specified,
|
|
62
|
+
# it will overwrite the contents of that tree with the new path contents
|
|
63
|
+
# and write a new tree out.
|
|
64
|
+
#
|
|
65
|
+
# @param [Hash] params
|
|
66
|
+
# @input params [String] :base_tree
|
|
67
|
+
# The SHA1 of the tree you want to update with new data
|
|
68
|
+
# @input params [Array[Hash]] :tree
|
|
69
|
+
# Required. Objects (of path, mode, type, and sha)
|
|
70
|
+
# specifying a tree structure
|
|
71
|
+
#
|
|
72
|
+
# The tree parameter takes the following keys:
|
|
73
|
+
# @input tree [String] :path
|
|
74
|
+
# The file referenced in the tree
|
|
75
|
+
# @input tree [String] :mode
|
|
76
|
+
# The file mode; one of 100644 for file (blob), 100755 for
|
|
77
|
+
# executable (blob), 040000 for subdirectory (tree), 160000 for
|
|
78
|
+
# submodule (commit), or 120000 for a blob that specifies
|
|
79
|
+
# the path of a symlink
|
|
80
|
+
# @input tree [String] :type
|
|
81
|
+
# Either blob, tree, or commit
|
|
82
|
+
# @input tree [String] :sha
|
|
83
|
+
# The SHA1 checksum ID of the object in the tree
|
|
84
|
+
# @input tree [String] :content
|
|
85
|
+
# The content you want this file to have - GitHub will write
|
|
86
|
+
# this blob out and use the SHA for this entry.
|
|
87
|
+
# Use either this or <tt>tree.sha</tt>
|
|
88
|
+
#
|
|
89
|
+
# @example
|
|
90
|
+
# github = Github.new
|
|
91
|
+
# github.git_data.trees.create 'user-name', 'repo-name',
|
|
92
|
+
# tree: [
|
|
93
|
+
# {
|
|
94
|
+
# path: "file.rb",
|
|
95
|
+
# mode: "100644",
|
|
96
|
+
# type: "blob",
|
|
97
|
+
# sha: "44b4fc6d56897b048c772eb4087f854f46256132"
|
|
98
|
+
# },
|
|
99
|
+
# ...
|
|
100
|
+
# ]
|
|
101
|
+
#
|
|
102
|
+
# @api public
|
|
103
|
+
def create(*args)
|
|
104
|
+
arguments(args, required: [:user, :repo]) do
|
|
105
|
+
assert_required %w[ tree ]
|
|
106
|
+
permit VALID_TREE_PARAM_NAMES, 'tree', { recursive: true }
|
|
107
|
+
assert_values VALID_TREE_PARAM_VALUES, 'tree'
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
post_request("/repos/#{arguments.user}/#{arguments.repo}/git/trees", arguments.params)
|
|
111
|
+
end
|
|
112
|
+
end # GitData::Trees
|
|
113
|
+
end # Github
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
class Client::GitData < API
|
|
7
|
+
|
|
8
|
+
require_all 'github_api2/client/git_data',
|
|
9
|
+
'blobs',
|
|
10
|
+
'commits',
|
|
11
|
+
'references',
|
|
12
|
+
'tags',
|
|
13
|
+
'trees'
|
|
14
|
+
|
|
15
|
+
# Access to GitData::Blobs API
|
|
16
|
+
namespace :blobs
|
|
17
|
+
|
|
18
|
+
# Access to GitData::Commits API
|
|
19
|
+
namespace :commits
|
|
20
|
+
|
|
21
|
+
# Access to GitData::References API
|
|
22
|
+
namespace :references
|
|
23
|
+
|
|
24
|
+
# Access to GitData::Tags API
|
|
25
|
+
namespace :tags
|
|
26
|
+
|
|
27
|
+
# Access to GitData::Tags API
|
|
28
|
+
namespace :trees
|
|
29
|
+
|
|
30
|
+
end # GitData
|
|
31
|
+
end # Github
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
# When you create a new GitHub repository via the API, you can specify a
|
|
7
|
+
# .gitignore template to apply to the repository upon creation.
|
|
8
|
+
class Client::Gitignore < API
|
|
9
|
+
# List all templates available to pass as an option
|
|
10
|
+
# when creating a repository.
|
|
11
|
+
#
|
|
12
|
+
# @see https://developer.github.com/v3/gitignore/#listing-available-templates
|
|
13
|
+
#
|
|
14
|
+
# @example
|
|
15
|
+
# github = Github.new
|
|
16
|
+
# github.gitignore.list
|
|
17
|
+
# github.gitignore.list { |template| ... }
|
|
18
|
+
#
|
|
19
|
+
# @api public
|
|
20
|
+
def list(*args)
|
|
21
|
+
arguments(args)
|
|
22
|
+
|
|
23
|
+
response = get_request("/gitignore/templates", arguments.params)
|
|
24
|
+
return response unless block_given?
|
|
25
|
+
response.each { |el| yield el }
|
|
26
|
+
end
|
|
27
|
+
alias :all :list
|
|
28
|
+
|
|
29
|
+
# Get a single template
|
|
30
|
+
#
|
|
31
|
+
# @see https://developer.github.com/v3/gitignore/#get-a-single-template
|
|
32
|
+
#
|
|
33
|
+
# @example
|
|
34
|
+
# github = Github.new
|
|
35
|
+
# github.gitignore.get "template-name"
|
|
36
|
+
#
|
|
37
|
+
# Use the raw media type to get the raw contents.
|
|
38
|
+
#
|
|
39
|
+
# @examples
|
|
40
|
+
# github = Github.new
|
|
41
|
+
# github.gitignore.get "template-name", accept: 'applicatin/vnd.github.raw'
|
|
42
|
+
#
|
|
43
|
+
# @api public
|
|
44
|
+
def get(*args)
|
|
45
|
+
arguments(args, required: [:name])
|
|
46
|
+
params = arguments.params
|
|
47
|
+
|
|
48
|
+
if (media = params.delete('accept'))
|
|
49
|
+
params['accept'] = media
|
|
50
|
+
params['raw'] = true
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
get_request("/gitignore/templates/#{arguments.name}", params)
|
|
54
|
+
end
|
|
55
|
+
alias :find :get
|
|
56
|
+
end # Client::Gitignore
|
|
57
|
+
end # Github
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
class Client::Issues::Assignees < API
|
|
7
|
+
# Lists all the available assignees (owner + collaborators)
|
|
8
|
+
# to which issues may be assigned.
|
|
9
|
+
#
|
|
10
|
+
# @example
|
|
11
|
+
# Github.issues.assignees.list 'owner', 'repo'
|
|
12
|
+
# Github.issues.assignees.list 'owner', 'repo' { |assignee| ... }
|
|
13
|
+
#
|
|
14
|
+
# @api public
|
|
15
|
+
def list(*args)
|
|
16
|
+
arguments(args, required: [:owner, :repo])
|
|
17
|
+
|
|
18
|
+
response = get_request("/repos/#{arguments.owner}/#{arguments.repo}/assignees", arguments.params)
|
|
19
|
+
return response unless block_given?
|
|
20
|
+
response.each { |el| yield el }
|
|
21
|
+
end
|
|
22
|
+
alias :all :list
|
|
23
|
+
|
|
24
|
+
# Check to see if a particular user is an assignee for a repository.
|
|
25
|
+
#
|
|
26
|
+
# @example
|
|
27
|
+
# Github.issues.assignees.check 'user', 'repo', 'assignee'
|
|
28
|
+
#
|
|
29
|
+
# @example
|
|
30
|
+
# github = Github.new user: 'user-name', repo: 'repo-name'
|
|
31
|
+
# github.issues.assignees.check 'assignee'
|
|
32
|
+
#
|
|
33
|
+
# @api public
|
|
34
|
+
def check(*args)
|
|
35
|
+
arguments(args, required: [:owner, :repo, :assignee])
|
|
36
|
+
params = arguments.params
|
|
37
|
+
|
|
38
|
+
get_request("/repos/#{arguments.owner}/#{arguments.repo}/assignees/#{arguments.assignee}",params)
|
|
39
|
+
true
|
|
40
|
+
rescue Github::Error::NotFound
|
|
41
|
+
false
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Add assignees to an issue
|
|
45
|
+
#
|
|
46
|
+
# @example
|
|
47
|
+
# github = Github.new
|
|
48
|
+
# github.issues.assignees.add 'user', 'repo', 'issue-number',
|
|
49
|
+
# 'hubot', 'other_assignee', ...
|
|
50
|
+
#
|
|
51
|
+
# @api public
|
|
52
|
+
def add(*args)
|
|
53
|
+
arguments(args, required: [:user, :repo, :number])
|
|
54
|
+
params = arguments.params
|
|
55
|
+
params['data'] = { 'assignees' => arguments.remaining } unless arguments.remaining.empty?
|
|
56
|
+
|
|
57
|
+
post_request("/repos/#{arguments.user}/#{arguments.repo}/issues/#{arguments.number}/assignees", params)
|
|
58
|
+
end
|
|
59
|
+
alias :<< :add
|
|
60
|
+
|
|
61
|
+
# Remove a assignees from an issue
|
|
62
|
+
#
|
|
63
|
+
# @example
|
|
64
|
+
# github = Github.new
|
|
65
|
+
# github.issues.assignees.remove 'user', 'repo', 'issue-number',
|
|
66
|
+
# 'hubot', 'other_assignee'
|
|
67
|
+
#
|
|
68
|
+
# @api public
|
|
69
|
+
def remove(*args)
|
|
70
|
+
arguments(args, required: [:user, :repo, :number])
|
|
71
|
+
params = arguments.params
|
|
72
|
+
params['data'] = { 'assignees' => arguments.remaining } unless arguments.remaining.empty?
|
|
73
|
+
|
|
74
|
+
delete_request("/repos/#{arguments.user}/#{arguments.repo}/issues/#{arguments.number}/assignees", params)
|
|
75
|
+
end
|
|
76
|
+
end # Issues::Assignees
|
|
77
|
+
end # Github
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require_relative '../../api'
|
|
4
|
+
|
|
5
|
+
module Github
|
|
6
|
+
class Client::Issues::Comments < API
|
|
7
|
+
|
|
8
|
+
VALID_ISSUE_COMMENT_PARAM_NAME = %w[
|
|
9
|
+
body
|
|
10
|
+
resource
|
|
11
|
+
mime_type
|
|
12
|
+
].freeze
|
|
13
|
+
|
|
14
|
+
# List comments on an issue
|
|
15
|
+
#
|
|
16
|
+
# @example
|
|
17
|
+
# github = Github.new
|
|
18
|
+
# github.issues.comments.all 'owner-name', 'repo-name', number: 'id'
|
|
19
|
+
# github.issues.comments.all 'owner-name', 'repo-name', number: 'id' {|com| .. }
|
|
20
|
+
# @example
|
|
21
|
+
# github.issues.comments.all owner: 'username', repo: 'repo-name', number: 'id'
|
|
22
|
+
#
|
|
23
|
+
# List comments in a repository
|
|
24
|
+
#
|
|
25
|
+
# @param [Hash] params
|
|
26
|
+
# @option params [String] :sort
|
|
27
|
+
# Optional string, created or updated
|
|
28
|
+
# @option params [String] :direction
|
|
29
|
+
# Optional string, asc or desc. Ignored with sort parameter.
|
|
30
|
+
# @option params [String] :since
|
|
31
|
+
# Optional string of a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
|
|
32
|
+
#
|
|
33
|
+
# @example
|
|
34
|
+
# github = Github.new
|
|
35
|
+
# github.issues.comments.all 'user-name', 'repo-name'
|
|
36
|
+
# github.issues.comments.all 'user-name', 'repo-name' {|com| .. }
|
|
37
|
+
#
|
|
38
|
+
# @api public
|
|
39
|
+
def list(*args)
|
|
40
|
+
arguments(args, required: [:user, :repo])
|
|
41
|
+
params = arguments.params
|
|
42
|
+
|
|
43
|
+
response = if (number = params.delete('number'))
|
|
44
|
+
get_request("/repos/#{arguments.user}/#{arguments.repo}/issues/#{number}/comments", params)
|
|
45
|
+
else
|
|
46
|
+
get_request("/repos/#{arguments.user}/#{arguments.repo}/issues/comments", params)
|
|
47
|
+
end
|
|
48
|
+
return response unless block_given?
|
|
49
|
+
response.each { |el| yield el }
|
|
50
|
+
end
|
|
51
|
+
alias :all :list
|
|
52
|
+
|
|
53
|
+
# Get a single comment
|
|
54
|
+
#
|
|
55
|
+
# @example
|
|
56
|
+
# github = Github.new
|
|
57
|
+
# github.issues.comments.find 'user-name', 'repo-name', 'id'
|
|
58
|
+
#
|
|
59
|
+
# @example
|
|
60
|
+
# github.issues.comments.find owner: 'user-name', repo: 'repo-name', id: 'id'
|
|
61
|
+
#
|
|
62
|
+
def get(*args)
|
|
63
|
+
arguments(args, required: [:user, :repo, :id])
|
|
64
|
+
params = arguments.params
|
|
65
|
+
|
|
66
|
+
get_request("/repos/#{arguments.user}/#{arguments.repo}/issues/comments/#{arguments.id}", params)
|
|
67
|
+
end
|
|
68
|
+
alias :find :get
|
|
69
|
+
|
|
70
|
+
# Create a comment
|
|
71
|
+
#
|
|
72
|
+
# @param [Hash] params
|
|
73
|
+
# @option [String] :body
|
|
74
|
+
# Required string
|
|
75
|
+
#
|
|
76
|
+
# @example
|
|
77
|
+
# github = Github.new
|
|
78
|
+
# github.issues.comments.create 'user-name', 'repo-name', 'number',
|
|
79
|
+
# body: 'a new comment'
|
|
80
|
+
#
|
|
81
|
+
# @example
|
|
82
|
+
# github.issues.comments.create
|
|
83
|
+
# user: 'owner-name',
|
|
84
|
+
# repo: 'repo-name',
|
|
85
|
+
# number: 'issue-number',
|
|
86
|
+
# body: 'a new comment body'
|
|
87
|
+
#
|
|
88
|
+
# @api public
|
|
89
|
+
def create(*args)
|
|
90
|
+
arguments(args, required: [:user, :repo, :number]) do
|
|
91
|
+
permit VALID_ISSUE_COMMENT_PARAM_NAME
|
|
92
|
+
assert_required %w[ body ]
|
|
93
|
+
end
|
|
94
|
+
params = arguments.params
|
|
95
|
+
|
|
96
|
+
post_request("/repos/#{arguments.user}/#{arguments.repo}/issues/#{arguments.number}/comments", params)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Edit a comment
|
|
100
|
+
#
|
|
101
|
+
# @param [Hash] params
|
|
102
|
+
# @option params [String] :body
|
|
103
|
+
# Required string
|
|
104
|
+
#
|
|
105
|
+
# @example
|
|
106
|
+
# github = Github.new
|
|
107
|
+
# github.issues.comments.edit 'owner-name', 'repo-name', 'id',
|
|
108
|
+
# body: 'a new comment'
|
|
109
|
+
#
|
|
110
|
+
# @example
|
|
111
|
+
# github.issues.comments.edit
|
|
112
|
+
# user: 'owner-name',
|
|
113
|
+
# repo: 'repo-name',
|
|
114
|
+
# id: 'comment-id',
|
|
115
|
+
# body: 'a new comment body'
|
|
116
|
+
#
|
|
117
|
+
# @api public
|
|
118
|
+
def edit(*args)
|
|
119
|
+
arguments(args, required: [:user, :repo, :id]) do
|
|
120
|
+
permit VALID_ISSUE_COMMENT_PARAM_NAME
|
|
121
|
+
assert_required %w[ body ]
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
patch_request("/repos/#{arguments.user}/#{arguments.repo}/issues/comments/#{arguments.id}", arguments.params)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# Delete a comment
|
|
128
|
+
#
|
|
129
|
+
# = Examples
|
|
130
|
+
# github = Github.new
|
|
131
|
+
# github.issues.comments.delete 'owner-name', 'repo-name', 'comment-id'
|
|
132
|
+
#
|
|
133
|
+
# @example
|
|
134
|
+
# github.issues.comments.delete
|
|
135
|
+
# user: 'owner-name',
|
|
136
|
+
# repo: 'repo-name',
|
|
137
|
+
# id: 'comment-id',
|
|
138
|
+
#
|
|
139
|
+
# @api public
|
|
140
|
+
def delete(*args)
|
|
141
|
+
arguments(args, required: [:user, :repo, :id])
|
|
142
|
+
|
|
143
|
+
delete_request("/repos/#{arguments.user}/#{arguments.repo}/issues/comments/#{arguments.id}", arguments.params)
|
|
144
|
+
end
|
|
145
|
+
end # Issues::Comments
|
|
146
|
+
end # Github
|