octokit 3.1.2 → 3.2.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.
@@ -8,18 +8,18 @@ module Octokit
8
8
 
9
9
  # List gists for a user or all public gists
10
10
  #
11
- # @param username [String] An optional user to filter listing
11
+ # @param user [String] An optional user to filter listing
12
12
  # @return [Array<Sawyer::Resource>] A list of gists
13
13
  # @example Fetch all gists for defunkt
14
14
  # Octokit.gists('defunkt')
15
15
  # @example Fetch all public gists
16
16
  # Octokit.gists
17
17
  # @see https://developer.github.com/v3/gists/#list-gists
18
- def gists(username=nil, options = {})
19
- if username.nil?
18
+ def gists(user=nil, options = {})
19
+ if user.nil?
20
20
  paginate 'gists', options
21
21
  else
22
- paginate "users/#{username}/gists", options
22
+ paginate "#{User.path user}/gists", options
23
23
  end
24
24
  end
25
25
  alias :list_gists :gists
@@ -8,7 +8,7 @@ module Octokit
8
8
 
9
9
  # List issues for the authenticated user or repository
10
10
  #
11
- # @param repository [String, Repository, Hash] A GitHub repository.
11
+ # @param repository [Integer, String, Repository, Hash] A GitHub repository.
12
12
  # @param options [Sawyer::Resource] A customizable set of options.
13
13
  # @option options [Integer] :milestone Milestone number.
14
14
  # @option options [String] :state (open) State: <tt>open</tt> or <tt>closed</tt>.
@@ -28,11 +28,7 @@ module Octokit
28
28
  # @client = Octokit::Client.new(:login => 'foo', :password => 'bar')
29
29
  # @client.list_issues
30
30
  def list_issues(repository = nil, options = {})
31
- path = ''
32
- path = "repos/#{Repository.new(repository)}" if repository
33
- path += "/issues"
34
-
35
- paginate path, options
31
+ paginate "#{Repository.new(repository).path}/issues", options
36
32
  end
37
33
  alias :issues :list_issues
38
34
 
@@ -58,7 +54,7 @@ module Octokit
58
54
 
59
55
  # List all issues for a given organization for the authenticated user
60
56
  #
61
- # @param org [String] Organization GitHub username.
57
+ # @param org [String, Integer] Organization GitHub login or id.
62
58
  # @param options [Sawyer::Resource] A customizable set of options.
63
59
  # @option options [String] :filter (assigned) State: <tt>assigned</tt>, <tt>created</tt>, <tt>mentioned</tt>, <tt>subscribed</tt> or <tt>closed</tt>.
64
60
  # @option options [String] :state (open) State: <tt>open</tt> or <tt>closed</tt>.
@@ -74,12 +70,12 @@ module Octokit
74
70
  # @client = Octokit::Client.new(:login => 'foo', :password => 'bar')
75
71
  # @client.org_issues("octokit")
76
72
  def org_issues(org, options = {})
77
- paginate "orgs/#{org}/issues", options
73
+ paginate "#{Organization.path org}/issues", options
78
74
  end
79
75
 
80
76
  # Create an issue for a repository
81
77
  #
82
- # @param repo [String, Repository, Hash] A GitHub repository
78
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
83
79
  # @param title [String] A descriptive title
84
80
  # @param body [String] A concise description
85
81
  # @param options [Hash] A customizable set of options.
@@ -97,25 +93,25 @@ module Octokit
97
93
  when Array
98
94
  options[:labels]
99
95
  end
100
- post "repos/#{Repository.new(repo)}/issues", options.merge({:title => title, :body => body})
96
+ post "#{Repository.path repo}/issues", options.merge({:title => title, :body => body})
101
97
  end
102
98
  alias :open_issue :create_issue
103
99
 
104
100
  # Get a single issue from a repository
105
101
  #
106
- # @param repo [String, Repository, Hash] A GitHub repository
102
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
107
103
  # @param number [Integer] Number ID of the issue
108
104
  # @return [Sawyer::Resource] The issue you requested, if it exists
109
105
  # @see https://developer.github.com/v3/issues/#get-a-single-issue
110
106
  # @example Get issue #25 from octokit/octokit.rb
111
107
  # Octokit.issue("octokit/octokit.rb", "25")
112
108
  def issue(repo, number, options = {})
113
- get "repos/#{Repository.new(repo)}/issues/#{number}", options
109
+ get "#{Repository.path repo}/issues/#{number}", options
114
110
  end
115
111
 
116
112
  # Close an issue
117
113
  #
118
- # @param repo [String, Repository, Hash] A GitHub repository
114
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
119
115
  # @param number [Integer] Number ID of the issue
120
116
  # @param options [Hash] A customizable set of options.
121
117
  # @option options [String] :assignee User login.
@@ -126,12 +122,12 @@ module Octokit
126
122
  # @example Close Issue #25 from octokit/octokit.rb
127
123
  # Octokit.close_issue("octokit/octokit.rb", "25")
128
124
  def close_issue(repo, number, options = {})
129
- patch "repos/#{Repository.new(repo)}/issues/#{number}", options.merge({:state => "closed"})
125
+ patch "#{Repository.path repo}/issues/#{number}", options.merge({:state => "closed"})
130
126
  end
131
127
 
132
128
  # Reopen an issue
133
129
  #
134
- # @param repo [String, Repository, Hash] A GitHub repository
130
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
135
131
  # @param number [Integer] Number ID of the issue
136
132
  # @param options [Hash] A customizable set of options.
137
133
  # @option options [String] :assignee User login.
@@ -142,12 +138,12 @@ module Octokit
142
138
  # @example Reopen Issue #25 from octokit/octokit.rb
143
139
  # Octokit.reopen_issue("octokit/octokit.rb", "25")
144
140
  def reopen_issue(repo, number, options = {})
145
- patch "repos/#{Repository.new(repo)}/issues/#{number}", options.merge({:state => "open"})
141
+ patch "#{Repository.path repo}/issues/#{number}", options.merge({:state => "open"})
146
142
  end
147
143
 
148
144
  # Update an issue
149
145
  #
150
- # @param repo [String, Repository, Hash] A GitHub repository
146
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
151
147
  # @param number [Integer] Number ID of the issue
152
148
  # @param title [String] Updated title for the issue
153
149
  # @param body [String] Updated body of the issue
@@ -161,14 +157,14 @@ module Octokit
161
157
  # @example Change the title of Issue #25
162
158
  # Octokit.update_issue("octokit/octokit.rb", "25", "A new title", "the same body"")
163
159
  def update_issue(repo, number, title, body, options = {})
164
- patch "repos/#{Repository.new(repo)}/issues/#{number}", options.merge({:title => title, :body => body})
160
+ patch "#{Repository.path repo}/issues/#{number}", options.merge({:title => title, :body => body})
165
161
  end
166
162
 
167
163
  # Get all comments attached to issues for the repository
168
164
  #
169
165
  # By default, Issue Comments are ordered by ascending ID.
170
166
  #
171
- # @param repo [String, Repository, Hash] A GitHub repository
167
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
172
168
  # @param options [Hash] Optional parameters
173
169
  # @option options [String] :sort created or updated
174
170
  # @option options [String] :direction asc or desc. Ignored without sort
@@ -190,36 +186,36 @@ module Octokit
190
186
  # :since => '2010-05-04T23:45:02Z'
191
187
  # })
192
188
  def issues_comments(repo, options = {})
193
- paginate "repos/#{Repository.new(repo)}/issues/comments", options
189
+ paginate "#{Repository.path repo}/issues/comments", options
194
190
  end
195
191
 
196
192
  # Get all comments attached to an issue
197
193
  #
198
- # @param repo [String, Repository, Hash] A GitHub repository
194
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
199
195
  # @param number [Integer] Number ID of the issue
200
196
  # @return [Array<Sawyer::Resource>] Array of comments that belong to an issue
201
197
  # @see https://developer.github.com/v3/issues/comments/#list-comments-on-an-issue
202
198
  # @example Get comments for issue #25 from octokit/octokit.rb
203
199
  # Octokit.issue_comments("octokit/octokit.rb", "25")
204
200
  def issue_comments(repo, number, options = {})
205
- paginate "repos/#{Repository.new(repo)}/issues/#{number}/comments", options
201
+ paginate "#{Repository.path repo}/issues/#{number}/comments", options
206
202
  end
207
203
 
208
204
  # Get a single comment attached to an issue
209
205
  #
210
- # @param repo [String, Repository, Hash] A GitHub repository
206
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
211
207
  # @param number [Integer] Number ID of the comment
212
208
  # @return [Sawyer::Resource] The specific comment in question
213
209
  # @see https://developer.github.com/v3/issues/comments/#get-a-single-comment
214
210
  # @example Get comment #1194549 from an issue on octokit/octokit.rb
215
211
  # Octokit.issue_comments("octokit/octokit.rb", 1194549)
216
212
  def issue_comment(repo, number, options = {})
217
- paginate "repos/#{Repository.new(repo)}/issues/comments/#{number}", options
213
+ paginate "#{Repository.path repo}/issues/comments/#{number}", options
218
214
  end
219
215
 
220
216
  # Add a comment to an issue
221
217
  #
222
- # @param repo [String, Repository, Hash] A GitHub repository
218
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
223
219
  # @param number [Integer] Issue number
224
220
  # @param comment [String] Comment to be added
225
221
  # @return [Sawyer::Resource] Comment
@@ -227,12 +223,12 @@ module Octokit
227
223
  # @example Add the comment "Almost to v1" to Issue #23 on octokit/octokit.rb
228
224
  # Octokit.add_comment("octokit/octokit.rb", 23, "Almost to v1")
229
225
  def add_comment(repo, number, comment, options = {})
230
- post "repos/#{Repository.new(repo)}/issues/#{number}/comments", options.merge({:body => comment})
226
+ post "#{Repository.path repo}/issues/#{number}/comments", options.merge({:body => comment})
231
227
  end
232
228
 
233
229
  # Update a single comment on an issue
234
230
  #
235
- # @param repo [String, Repository, Hash] A GitHub repository
231
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
236
232
  # @param number [Integer] Comment number
237
233
  # @param comment [String] Body of the comment which will replace the existing body.
238
234
  # @return [Sawyer::Resource] Comment
@@ -240,19 +236,19 @@ module Octokit
240
236
  # @example Update the comment #1194549 with body "I've started this on my 25-issue-comments-v3 fork" on an issue on octokit/octokit.rb
241
237
  # Octokit.update_comment("octokit/octokit.rb", 1194549, "Almost to v1, added this on my fork")
242
238
  def update_comment(repo, number, comment, options = {})
243
- patch "repos/#{Repository.new(repo)}/issues/comments/#{number}", options.merge({:body => comment})
239
+ patch "#{Repository.path repo}/issues/comments/#{number}", options.merge({:body => comment})
244
240
  end
245
241
 
246
242
  # Delete a single comment
247
243
  #
248
- # @param repo [String, Repository, Hash] A GitHub repository
244
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
249
245
  # @param number [Integer] Comment number
250
246
  # @return [Boolean] Success
251
247
  # @see https://developer.github.com/v3/issues/comments/#delete-a-comment
252
248
  # @example Delete the comment #1194549 on an issue on octokit/octokit.rb
253
249
  # Octokit.delete_comment("octokit/octokit.rb", 1194549)
254
250
  def delete_comment(repo, number, options = {})
255
- boolean_from_response :delete, "repos/#{Repository.new(repo)}/issues/comments/#{number}", options
251
+ boolean_from_response :delete, "#{Repository.path repo}/issues/comments/#{number}", options
256
252
  end
257
253
  end
258
254
  end
@@ -10,30 +10,30 @@ module Octokit
10
10
 
11
11
  # List available labels for a repository
12
12
  #
13
- # @param repo [String, Repository, Hash] A GitHub repository
13
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
14
14
  # @return [Array<Sawyer::Resource>] A list of the labels across the repository
15
15
  # @see https://developer.github.com/v3/issues/labels/#list-all-labels-for-this-repository
16
16
  # @example List labels for octokit/octokit.rb
17
17
  # Octokit.labels("octokit/octokit.rb")
18
18
  def labels(repo, options = {})
19
- paginate "repos/#{Repository.new(repo)}/labels", options
19
+ paginate "#{Repository.path repo}/labels", options
20
20
  end
21
21
 
22
22
  # Get single label for a repository
23
23
  #
24
- # @param repo [String, Repository, Hash] A GitHub repository
24
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
25
25
  # @param name [String] Name of the label
26
26
  # @return [Sawyer::Resource] A single label from the repository
27
27
  # @see https://developer.github.com/v3/issues/labels/#get-a-single-label
28
28
  # @example Get the "V3 Addition" label from octokit/octokit.rb
29
29
  # Octokit.labels("octokit/octokit.rb", "V3 Addition")
30
30
  def label(repo, name, options = {})
31
- get "repos/#{Repository.new(repo)}/labels/#{CGI.escape(name)}", options
31
+ get "#{Repository.path repo}/labels/#{CGI.escape(name)}", options
32
32
  end
33
33
 
34
34
  # Add a label to a repository
35
35
  #
36
- # @param repo [String, Repository, Hash] A GitHub repository
36
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
37
37
  # @param label [String] A new label
38
38
  # @param color [String] A color, in hex, without the leading #
39
39
  # @return [Sawyer::Resource] The new label
@@ -41,12 +41,12 @@ module Octokit
41
41
  # @example Add a new label "Version 1.0" with color "#cccccc"
42
42
  # Octokit.add_label("octokit/octokit.rb", "Version 1.0", "cccccc")
43
43
  def add_label(repo, label, color="ffffff", options = {})
44
- post "repos/#{Repository.new(repo)}/labels", options.merge({:name => label, :color => color})
44
+ post "#{Repository.path repo}/labels", options.merge({:name => label, :color => color})
45
45
  end
46
46
 
47
47
  # Update a label
48
48
  #
49
- # @param repo [String, Repository, Hash] A GitHub repository
49
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
50
50
  # @param label [String] The name of the label which will be updated
51
51
  # @param options [Hash] A customizable set of options.
52
52
  # @option options [String] :name An updated label name
@@ -56,28 +56,28 @@ module Octokit
56
56
  # @example Update the label "Version 1.0" with new color "#cceeaa"
57
57
  # Octokit.update_label("octokit/octokit.rb", "Version 1.0", {:color => "cceeaa"})
58
58
  def update_label(repo, label, options = {})
59
- patch "repos/#{Repository.new(repo)}/labels/#{CGI.escape(label)}", options
59
+ patch "#{Repository.path repo}/labels/#{CGI.escape(label)}", options
60
60
  end
61
61
 
62
62
  # Delete a label from a repository.
63
63
  #
64
64
  # This deletes the label from the repository, and removes it from all issues.
65
65
  #
66
- # @param repo [String, Repository, Hash] A GitHub repository
66
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
67
67
  # @param label [String] String name of the label
68
68
  # @return [Boolean] Success
69
69
  # @see https://developer.github.com/v3/issues/labels/#delete-a-label
70
70
  # @example Delete the label "Version 1.0" from the repository.
71
71
  # Octokit.delete_label!("octokit/octokit.rb", "Version 1.0")
72
72
  def delete_label!(repo, label, options = {})
73
- boolean_from_response :delete, "repos/#{Repository.new(repo)}/labels/#{CGI.escape(label)}", options
73
+ boolean_from_response :delete, "#{Repository.path repo}/labels/#{CGI.escape(label)}", options
74
74
  end
75
75
 
76
76
  # Remove a label from an Issue
77
77
  #
78
78
  # This removes the label from the Issue
79
79
  #
80
- # @param repo [String, Repository, Hash] A GitHub repository
80
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
81
81
  # @param number [Fixnum] Number ID of the issue
82
82
  # @param label [String] String name of the label
83
83
  # @return [Array<Sawyer::Resource>] A list of the labels currently on the issue
@@ -85,38 +85,38 @@ module Octokit
85
85
  # @example Remove the label "Version 1.0" from the repository.
86
86
  # Octokit.remove_label("octokit/octokit.rb", 23, "Version 1.0")
87
87
  def remove_label(repo, number, label, options = {})
88
- delete "repos/#{Repository.new(repo)}/issues/#{number}/labels/#{CGI.escape(label)}", options
88
+ delete "#{Repository.path repo}/issues/#{number}/labels/#{CGI.escape(label)}", options
89
89
  end
90
90
 
91
91
  # Remove all label from an Issue
92
92
  #
93
93
  # This removes the label from the Issue
94
94
  #
95
- # @param repo [String, Repository, Hash] A GitHub repository
95
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
96
96
  # @param number [Fixnum] Number ID of the issue
97
97
  # @return [Boolean] Success of operation
98
98
  # @see https://developer.github.com/v3/issues/labels/#remove-all-labels-from-an-issue
99
99
  # @example Remove all labels from Issue #23
100
100
  # Octokit.remove_all_labels("octokit/octokit.rb", 23)
101
101
  def remove_all_labels(repo, number, options = {})
102
- boolean_from_response :delete, "repos/#{Repository.new(repo)}/issues/#{number}/labels", options
102
+ boolean_from_response :delete, "#{Repository.path repo}/issues/#{number}/labels", options
103
103
  end
104
104
 
105
105
  # List labels for a given issue
106
106
  #
107
- # @param repo [String, Repository, Hash] A GitHub repository
107
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
108
108
  # @param number [Fixnum] Number ID of the issue
109
109
  # @return [Array<Sawyer::Resource>] A list of the labels currently on the issue
110
110
  # @see https://developer.github.com/v3/issues/labels/#list-labels-on-an-issue
111
111
  # @example List labels for octokit/octokit.rb, issue # 1
112
112
  # Octokit.labels_for_issue("octokit/octokit.rb", 1)
113
113
  def labels_for_issue(repo, number, options = {})
114
- paginate "repos/#{Repository.new(repo)}/issues/#{number}/labels", options
114
+ paginate "#{Repository.path repo}/issues/#{number}/labels", options
115
115
  end
116
116
 
117
117
  # Add label(s) to an Issue
118
118
  #
119
- # @param repo [String, Repository, Hash] A Github repository
119
+ # @param repo [Integer, String, Repository, Hash] A Github repository
120
120
  # @param number [Fixnum] Number ID of the issue
121
121
  # @param labels [Array] An array of labels to apply to this Issue
122
122
  # @return [Array<Sawyer::Resource>] A list of the labels currently on the issue
@@ -124,12 +124,12 @@ module Octokit
124
124
  # @example Add two labels for octokit/octokit.rb
125
125
  # Octokit.add_labels_to_an_issue("octokit/octokit.rb", 10, ['V3 Transition', 'Improvement'])
126
126
  def add_labels_to_an_issue(repo, number, labels)
127
- post "repos/#{Repository.new(repo)}/issues/#{number}/labels", labels
127
+ post "#{Repository.path repo}/issues/#{number}/labels", labels
128
128
  end
129
129
 
130
130
  # Replace all labels on an Issue
131
131
  #
132
- # @param repo [String, Repository, Hash] A Github repository
132
+ # @param repo [Integer, String, Repository, Hash] A Github repository
133
133
  # @param number [Fixnum] Number ID of the issue
134
134
  # @param labels [Array] An array of labels to use as replacement
135
135
  # @return [Array<Sawyer::Resource>] A list of the labels currently on the issue
@@ -137,19 +137,19 @@ module Octokit
137
137
  # @example Replace labels for octokit/octokit.rb Issue #10
138
138
  # Octokit.replace_all_labels("octokit/octokit.rb", 10, ['V3 Transition', 'Improvement'])
139
139
  def replace_all_labels(repo, number, labels, options = {})
140
- put "repos/#{Repository.new(repo)}/issues/#{number}/labels", labels
140
+ put "#{Repository.path repo}/issues/#{number}/labels", labels
141
141
  end
142
142
 
143
143
  # Get labels for every issue in a milestone
144
144
  #
145
- # @param repo [String, Repository, Hash] A GitHub repository
145
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
146
146
  # @param number [Fixnum] Number ID of the milestone
147
147
  # @return [Array<Sawyer::Resource>] A list of the labels across the milestone
148
148
  # @see http://developer.github.com/v3/issues/labels/#get-labels-for-every-issue-in-a-milestone
149
149
  # @example List all labels for milestone #2 on octokit/octokit.rb
150
150
  # Octokit.labels_for_milestone("octokit/octokit.rb", 2)
151
151
  def labels_for_milestone(repo, number, options = {})
152
- paginate "repos/#{Repository.new(repo)}/milestones/#{number}/labels", options
152
+ paginate "#{Repository.path repo}/milestones/#{number}/labels", options
153
153
  end
154
154
  end
155
155
  end
@@ -29,7 +29,7 @@ module Octokit
29
29
 
30
30
  # List your notifications in a repository
31
31
  #
32
- # @param repo [String, Hash, Repository] A GitHub repository
32
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
33
33
  # @param options [Hash] Optional parameters
34
34
  # @option options [Boolean] :all 'true' to show notifications marked as
35
35
  # read.
@@ -46,7 +46,7 @@ module Octokit
46
46
  # @example Get your notifications for octokit/octokit.rb since a time.
47
47
  # @client.repository_notifications({since: '2012-10-09T23:39:01Z'})
48
48
  def repository_notifications(repo, options = {})
49
- paginate "repos/#{Repository.new(repo)}/notifications", options
49
+ paginate "#{Repository.path repo}/notifications", options
50
50
  end
51
51
  alias :repo_notifications :repository_notifications
52
52
 
@@ -73,7 +73,7 @@ module Octokit
73
73
 
74
74
  # Mark notifications from a specific repository as read
75
75
  #
76
- # @param repo [String, Hash, Repository] A GitHub repository
76
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
77
77
  # @param options [Hash] Optional parameters
78
78
  # @option options [Boolean] :unread Changes the unread status of the
79
79
  # threads.
@@ -87,7 +87,7 @@ module Octokit
87
87
  # @example
88
88
  # @client.mark_notifications_as_read("octokit/octokit.rb")
89
89
  def mark_repository_notifications_as_read(repo, options = {})
90
- request :put, "repos/#{Repository.new(repo)}/notifications", options
90
+ request :put, "#{Repository.path repo}/notifications", options
91
91
 
92
92
  last_response.status == 205
93
93
  end
@@ -10,7 +10,7 @@ module Octokit
10
10
  #
11
11
  # Pass <tt>:recursive => true</tt> in <tt>options</tt> to fetch information about all of the tree's objects, including those in subdirectories.
12
12
  #
13
- # @param repo [String, Hash, Repository] A GitHub repository
13
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
14
14
  # @param tree_sha [String] The SHA of the tree to fetch
15
15
  # @return [Sawyer::Resource] A hash representing the fetched tree
16
16
  # @see https://developer.github.com/v3/git/trees/#get-a-tree
@@ -22,14 +22,14 @@ module Octokit
22
22
  # tree = Octokit.tree("octocat/Hello-World", "fc6274d15fa3ae2ab983129fb037999f264ba9a7", :recursive => true)
23
23
  # tree.tree.first.path # => "subdir/file.txt"
24
24
  def tree(repo, tree_sha, options = {})
25
- get "repos/#{Repository.new(repo)}/git/trees/#{tree_sha}", options
25
+ get "#{Repository.path repo}/git/trees/#{tree_sha}", options
26
26
  end
27
27
 
28
28
  # Create a tree
29
29
  #
30
30
  # Pass <tt>:base_tree => "827efc6..."</tt> in <tt>options</tt> to update an existing tree with new data.
31
31
  #
32
- # @param repo [String, Hash, Repository] A GitHub repository
32
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
33
33
  # @param tree [Array] An array of hashes representing a tree structure
34
34
  # @return [Sawyer::Resource] A hash representing the new tree
35
35
  # @see https://developer.github.com/v3/git/trees/#create-a-tree
@@ -39,12 +39,12 @@ module Octokit
39
39
  # tree.tree.first.path # => "file.rb"
40
40
  def create_tree(repo, tree, options = {})
41
41
  parameters = { :tree => tree }
42
- post "repos/#{Repository.new(repo)}/git/trees", options.merge(parameters)
42
+ post "#{Repository.path repo}/git/trees", options.merge(parameters)
43
43
  end
44
44
 
45
45
  # Get a single blob, fetching its content and encoding
46
46
  #
47
- # @param repo [String, Hash, Repository] A GitHub repository
47
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
48
48
  # @param blob_sha [String] The SHA of the blob to fetch
49
49
  # @return [Sawyer::Resource] A hash representing the fetched blob
50
50
  # @see https://developer.github.com/v3/git/blobs/#get-a-blob
@@ -59,12 +59,12 @@ module Octokit
59
59
  # blob.content # => "Rm9vIGJhciBiYXo="
60
60
  # Base64.decode64(blob.content) # => "Foo bar baz"
61
61
  def blob(repo, blob_sha, options = {})
62
- get "repos/#{Repository.new(repo)}/git/blobs/#{blob_sha}", options
62
+ get "#{Repository.path repo}/git/blobs/#{blob_sha}", options
63
63
  end
64
64
 
65
65
  # Create a blob
66
66
  #
67
- # @param repo [String, Hash, Repository] A GitHub repository
67
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
68
68
  # @param content [String] Content of the blob
69
69
  # @param encoding [String] The content's encoding. <tt>utf-8</tt> and <tt>base64</tt> are accepted. If your data cannot be losslessly sent as a UTF-8 string, you can base64 encode it
70
70
  # @return [String] The new blob's SHA, e.g. <tt>827efc6d56897b048c772eb4087f854f46256132</tt>
@@ -79,28 +79,28 @@ module Octokit
79
79
  :content => content,
80
80
  :encoding => encoding
81
81
  }
82
- blob = post "repos/#{Repository.new(repo)}/git/blobs", options.merge(parameters)
82
+ blob = post "#{Repository.path repo}/git/blobs", options.merge(parameters)
83
83
 
84
84
  blob.sha
85
85
  end
86
86
 
87
87
  # Get a tag
88
88
  #
89
- # @param repo [String, Hash, Repository] A GitHub repository.
89
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
90
90
  # @param tag_sha [String] The SHA of the tag to fetch.
91
91
  # @return [Sawyer::Resource] Hash representing the tag.
92
92
  # @see https://developer.github.com/v3/git/tags/#get-a-tag
93
93
  # @example Fetch a tag
94
94
  # Octokit.tag('octokit/octokit.rb', '23aad20633f4d2981b1c7209a800db3014774e96')
95
95
  def tag(repo, tag_sha, options = {})
96
- get "repos/#{Repository.new(repo)}/git/tags/#{tag_sha}", options
96
+ get "#{Repository.path repo}/git/tags/#{tag_sha}", options
97
97
  end
98
98
 
99
99
  # Create a tag
100
100
  #
101
101
  # Requires authenticated client.
102
102
  #
103
- # @param repo [String, Hash, Repository] A GitHub repository.
103
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
104
104
  # @param tag [String] Tag string.
105
105
  # @param message [String] Tag message.
106
106
  # @param object_sha [String] SHA of the git object this is tagging.
@@ -134,7 +134,7 @@ module Octokit
134
134
  :date => tagger_date
135
135
  }
136
136
  )
137
- post "repos/#{Repository.new(repo)}/git/tags", options
137
+ post "#{Repository.path repo}/git/tags", options
138
138
  end
139
139
  end
140
140
  end