octokit 1.15.1 → 1.17.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.
- data/CHANGELOG.md +2 -0
- data/lib/octokit/client/commits.rb +56 -0
- data/lib/octokit/client/gists.rb +102 -31
- data/lib/octokit/client/issues.rb +10 -3
- data/lib/octokit/client/organizations.rb +6 -1
- data/lib/octokit/client/pulls.rb +102 -9
- data/lib/octokit/client/repositories.rb +114 -5
- data/lib/octokit/configuration.rb +5 -0
- data/lib/octokit/connection.rb +6 -0
- data/lib/octokit/version.rb +1 -1
- data/octokit.gemspec +1 -1
- data/spec/faraday/response_spec.rb +20 -0
- data/spec/fixtures/v3/commit_comment_create.json +19 -0
- data/spec/fixtures/v3/commit_comment_update.json +19 -0
- data/spec/fixtures/v3/pull_request_comments.json +35 -0
- data/spec/fixtures/v3/pull_request_files.json +35 -0
- data/spec/octokit/client/commits_spec.rb +41 -0
- data/spec/octokit/client/gists_spec.rb +1 -1
- data/spec/octokit/client/issues_spec.rb +8 -1
- data/spec/octokit/client/pulls_spec.rb +37 -2
- data/spec/octokit/client/repositories_spec.rb +5 -5
- data/spec/octokit/client_spec.rb +13 -0
- metadata +19 -11
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
* [1.17.0 - October 8, 2012](https://github.com/pengwynn/octokit/compare/v1.16.0...v1.17.0)
|
4
|
+
* [1.16.0 - September 25,2012](https://github.com/pengwynn/octokit/compare/v1.15.1...v1.16.0)
|
3
5
|
* [1.15.1 - September 24,2012](https://github.com/pengwynn/octokit/compare/v1.15.0...v1.15.1)
|
4
6
|
* [1.15.0 - September 24,2012](https://github.com/pengwynn/octokit/compare/v1.14.0...v1.15.0)
|
5
7
|
* [1.14.0 - September 22,2012](https://github.com/pengwynn/octokit/compare/v1.13.0...v1.14.0)
|
@@ -81,6 +81,62 @@ module Octokit
|
|
81
81
|
get("repos/#{Repository.new(repo)}/comments/#{id}", options, 3)
|
82
82
|
end
|
83
83
|
|
84
|
+
# Create a commit comment
|
85
|
+
#
|
86
|
+
# @param repo [String, Hash, Repository] A GitHub repository
|
87
|
+
# @param sha [String] Sha of the commit to comment on
|
88
|
+
# @param body [String] Message
|
89
|
+
# @param path [String] Relative path of file to comment on
|
90
|
+
# @param line [Integer] Line number in the file to comment on
|
91
|
+
# @param position [Integer] Line index in the diff to comment on
|
92
|
+
# @return [Hashie::Mash] A hash representing the new commit comment
|
93
|
+
# @see http://developer.github.com/v3/repos/comments/
|
94
|
+
# @example Create a commit comment
|
95
|
+
# commit = Octokit.create_commit_comment("octocat/Hello-World", "827efc6d56897b048c772eb4087f854f46256132", "My comment message", "README.md", 10, 1)
|
96
|
+
# commit.commit_id # => "827efc6d56897b048c772eb4087f854f46256132"
|
97
|
+
# commit.body # => "My comment message"
|
98
|
+
# commit.path # => "README.md"
|
99
|
+
# commit.line # => 10
|
100
|
+
# commit.position # => 1
|
101
|
+
def create_commit_comment(repo, sha, body, path=nil, line=nil, position=nil, options={})
|
102
|
+
params = {
|
103
|
+
:body => body,
|
104
|
+
:commit_id => sha,
|
105
|
+
:path => path,
|
106
|
+
:line => line,
|
107
|
+
:position => position
|
108
|
+
}
|
109
|
+
post("repos/#{Repository.new(repo)}/commits/#{sha}/comments", options.merge(params), 3)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Update a commit comment
|
113
|
+
#
|
114
|
+
# @param repo [String, Hash, Repository] A GitHub repository
|
115
|
+
# @param id [String] The ID of the comment to update
|
116
|
+
# @param body [String] Message
|
117
|
+
# @return [Hashie::Mash] A hash representing the updated commit comment
|
118
|
+
# @see http://developer.github.com/v3/repos/comments/
|
119
|
+
# @example Update a commit comment
|
120
|
+
# commit = Octokit.update_commit_comment("octocat/Hello-World", "860296", "Updated commit comment")
|
121
|
+
# commit.id # => 860296
|
122
|
+
# commit.body # => "Updated commit comment"
|
123
|
+
def update_commit_comment(repo, id, body, options={})
|
124
|
+
params = {
|
125
|
+
:body => body
|
126
|
+
}
|
127
|
+
patch("repos/#{Repository.new(repo)}/comments/#{id}", options.merge(params), 3)
|
128
|
+
end
|
129
|
+
|
130
|
+
# Delete a commit comment
|
131
|
+
#
|
132
|
+
# @param repo [String, Hash, Repository] A GitHub repository
|
133
|
+
# @param id [String] The ID of the comment to delete
|
134
|
+
# @return [nil] nil
|
135
|
+
# @see http://developer.github.com/v3/repos/comments/
|
136
|
+
def delete_commit_comment(repo, id, options={})
|
137
|
+
delete("repos/#{Repository.new(repo)}/comments/#{id}", options, 3)
|
138
|
+
end
|
139
|
+
|
84
140
|
# Compare two commits
|
85
141
|
#
|
86
142
|
# @param repo [String, Hash, Repository] A GitHub repository
|
data/lib/octokit/client/gists.rb
CHANGED
@@ -2,32 +2,108 @@ module Octokit
|
|
2
2
|
class Client
|
3
3
|
module Gists
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
# List gists for a user or all public gists
|
6
|
+
#
|
7
|
+
# @param username [String] An optional user to filter listing
|
8
|
+
# @return [Array<Hashie::Mash>] A list of gists
|
9
|
+
# @example Fetch all gists for defunkt
|
10
|
+
# Octokit.gists('defunkt')
|
11
|
+
# @example Fetch all public gists
|
12
|
+
# Octokit.gists
|
13
|
+
# @see http://developer.github.com/v3/gists/#list-gists
|
14
|
+
def gists(username=nil, options={})
|
15
|
+
if username.nil?
|
16
|
+
get 'gists', options, 3
|
17
|
+
else
|
18
|
+
get "users/#{username}/gists", options, 3
|
19
|
+
end
|
7
20
|
end
|
21
|
+
alias :list_gists :gists
|
8
22
|
|
9
|
-
|
10
|
-
|
11
|
-
|
23
|
+
# List public gists
|
24
|
+
#
|
25
|
+
# @return [Array<Hashie::Mash>] A list of gists
|
26
|
+
# @example Fetch all public gists
|
27
|
+
# Octokit.public_gists
|
28
|
+
# @see http://developer.github.com/v3/gists/#list-gists
|
29
|
+
def public_gists(options={})
|
30
|
+
get 'gists/public', options, 3
|
12
31
|
end
|
13
32
|
|
14
|
-
|
15
|
-
|
33
|
+
# List the authenticated user’s starred gists
|
34
|
+
#
|
35
|
+
# @return [Array<Hashie::Mash>] A list of gists
|
36
|
+
def starred_gists(options={})
|
37
|
+
get 'gists/starred', options, 3
|
16
38
|
end
|
17
39
|
|
40
|
+
# Get a single gist
|
41
|
+
#
|
42
|
+
# @param gist [String] ID of gist to fetch
|
43
|
+
# @return [Hash::Mash] Gist information
|
44
|
+
# @see http://developer.github.com/v3/gists/#get-a-single-gist
|
18
45
|
def gist(gist, options={})
|
19
46
|
get "gists/#{Gist.new gist}", options, 3
|
20
47
|
end
|
21
48
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
49
|
+
# Create a gist
|
50
|
+
#
|
51
|
+
# @param options [Hash] Gist information.
|
52
|
+
# @option options [String] :description
|
53
|
+
# @option options [Boolean] :public Sets gist visibility
|
54
|
+
# @option options [Array<Hash>] :files Files that make up this gist. Keys
|
55
|
+
# should be the filename, the value a Hash with a :content key with text
|
56
|
+
# conent of the Gist.
|
57
|
+
# @return [Hashie::Mash] Newly created gist info
|
58
|
+
# @see http://developer.github.com/v3/gists/#create-a-gist
|
59
|
+
def create_gist(options={})
|
60
|
+
post 'gists', options, 3
|
28
61
|
end
|
29
62
|
|
30
|
-
#
|
63
|
+
# Edit a gist
|
64
|
+
#
|
65
|
+
# @param options [Hash] Gist information.
|
66
|
+
# @option options [String] :description
|
67
|
+
# @option options [Boolean] :public Sets gist visibility
|
68
|
+
# @option options [Array<Hash>] :files Files that make up this gist. Keys
|
69
|
+
# should be the filename, the value a Hash with a :content key with text
|
70
|
+
# conent of the Gist.
|
71
|
+
#
|
72
|
+
# NOTE: All files from the previous version of the
|
73
|
+
# gist are carried over by default if not included in the hash. Deletes
|
74
|
+
# can be performed by including the filename with a null hash.
|
75
|
+
# @return
|
76
|
+
# [Hashie::Mash] Newly created gist info
|
77
|
+
# @see http://developer.github.com/v3/gists/#edit-a-gist
|
78
|
+
def edit_gist(gist, options={})
|
79
|
+
patch "gists/#{Gist.new gist}", options, 3
|
80
|
+
end
|
81
|
+
#
|
82
|
+
# Star a gist
|
83
|
+
#
|
84
|
+
# @param gist [String] Gist ID
|
85
|
+
# @return [Boolean] Indicates if gist is starred successfully
|
86
|
+
# @see http://developer.github.com/v3/gists/#star-a-gist
|
87
|
+
def star_gist(gist, options={})
|
88
|
+
response = put("gists/#{Gist.new gist}/star", options, 3, true, true)
|
89
|
+
response.status == 204
|
90
|
+
end
|
91
|
+
|
92
|
+
# Unstar a gist
|
93
|
+
#
|
94
|
+
# @param gist [String] Gist ID
|
95
|
+
# @return [Boolean] Indicates if gist is unstarred successfully
|
96
|
+
# @see http://developer.github.com/v3/gists/#unstar-a-gist
|
97
|
+
def unstar_gist(gist, options={})
|
98
|
+
response = delete("gists/#{Gist.new gist}/star", options, 3, true, true)
|
99
|
+
response.status == 204
|
100
|
+
end
|
101
|
+
|
102
|
+
# Check if a gist is starred
|
103
|
+
#
|
104
|
+
# @param gist [String] Gist ID
|
105
|
+
# @return [Boolean] Indicates if gist is starred
|
106
|
+
# @see http://developer.github.com/v3/gists/#check-if-a-gist-is-starred
|
31
107
|
def gist_starred?(gist, options={})
|
32
108
|
begin
|
33
109
|
get("gists/#{Gist.new gist}/star", options, 3, true, true)
|
@@ -37,27 +113,22 @@ module Octokit
|
|
37
113
|
end
|
38
114
|
end
|
39
115
|
|
116
|
+
# Fork a gist
|
117
|
+
#
|
118
|
+
# @param gist [String] Gist ID
|
119
|
+
# @return [Hashie::Mash] Data for the new gist
|
120
|
+
# @see http://developer.github.com/v3/gists/#fork-a-gist
|
40
121
|
def fork_gist(gist, options={})
|
41
122
|
post "gists/#{Gist.new gist}/fork", options, 3
|
42
123
|
end
|
43
124
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
# Returns +true+ or +false+ based on success.
|
53
|
-
def star_gist(gist, options={})
|
54
|
-
response = put("gists/#{Gist.new gist}/star", options, 3, true, true)
|
55
|
-
response.status == 204
|
56
|
-
end
|
57
|
-
|
58
|
-
# Returns +true+ or +false+ based on success.
|
59
|
-
def unstar_gist(gist, options={})
|
60
|
-
response = delete("gists/#{Gist.new gist}/star", options, 3, true, true)
|
125
|
+
# Delete a gist
|
126
|
+
#
|
127
|
+
# @param gist [String] Gist ID
|
128
|
+
# @return [Boolean] Indicating success of deletion
|
129
|
+
# @see http://developer.github.com/v3/gists/#delete-a-gist
|
130
|
+
def delete_gist(gist, options={})
|
131
|
+
response = delete("gists/#{Gist.new gist}", options, 3, true, true)
|
61
132
|
response.status == 204
|
62
133
|
end
|
63
134
|
|
@@ -15,13 +15,14 @@ module Octokit
|
|
15
15
|
get("legacy/issues/search/#{Repository.new(repo)}/#{state}/#{search_term}", options, 3)['issues']
|
16
16
|
end
|
17
17
|
|
18
|
-
# List issues for a repository
|
18
|
+
# List issues for a the authenticated user or repository
|
19
19
|
#
|
20
20
|
# @param repository [String, Repository, Hash] A GitHub repository.
|
21
21
|
# @param options [Hash] A customizable set of options.
|
22
22
|
# @option options [Integer] :milestone Milestone number.
|
23
23
|
# @option options [String] :state (open) State: <tt>open</tt> or <tt>closed</tt>.
|
24
24
|
# @option options [String] :assignee User login.
|
25
|
+
# @option options [String] :creator User login.
|
25
26
|
# @option options [String] :mentioned User login.
|
26
27
|
# @option options [String] :labels List of comma separated Label names. Example: <tt>bug,ui,@high</tt>.
|
27
28
|
# @option options [String] :sort (created) Sort: <tt>created</tt>, <tt>updated</tt>, or <tt>comments</tt>.
|
@@ -31,8 +32,14 @@ module Octokit
|
|
31
32
|
# @see http://developer.github.com/v3/issues/#list-issues-for-this-repository
|
32
33
|
# @example List issues for a repository
|
33
34
|
# Octokit.list_issues("sferik/rails_admin")
|
34
|
-
|
35
|
-
|
35
|
+
# @example List issues for the authenticted user across repositories
|
36
|
+
# @client = Octokit::Client.new(:login => 'foo', :password => 'bar')
|
37
|
+
# @client.list_issues
|
38
|
+
def list_issues(repository = nil, options={})
|
39
|
+
path = ''
|
40
|
+
path = "repos/#{Repository.new(repository)}" if repository
|
41
|
+
path += "/issues"
|
42
|
+
get(path, options, 3)
|
36
43
|
end
|
37
44
|
alias :issues :list_issues
|
38
45
|
|
@@ -22,7 +22,12 @@ module Octokit
|
|
22
22
|
alias :list_orgs :organizations
|
23
23
|
alias :orgs :organizations
|
24
24
|
|
25
|
-
|
25
|
+
# List organization repositories
|
26
|
+
#
|
27
|
+
# @see http://developer.github.com/v3/repos/#list-organization-repositories
|
28
|
+
# @param org [String] Organization handle for which to list repos
|
29
|
+
# @return [Array<Hashie::Mash>] List of repositories
|
30
|
+
def organization_repositories(org, options={})
|
26
31
|
get("orgs/#{org}/repos", options, 3)
|
27
32
|
end
|
28
33
|
alias :org_repositories :organization_repositories
|
data/lib/octokit/client/pulls.rb
CHANGED
@@ -1,6 +1,43 @@
|
|
1
1
|
module Octokit
|
2
2
|
class Client
|
3
3
|
module Pulls
|
4
|
+
# List pull requests for a repository
|
5
|
+
#
|
6
|
+
# @see http://developer.github.com/v3/pulls/#list-pull-requests
|
7
|
+
# @param repo [String, Hash, Repository] A GitHub repository
|
8
|
+
# @param options [Hash] Method options
|
9
|
+
# @option options [String] :state `open` or `closed`. Default is `open`.
|
10
|
+
# @return [Array<Hashie::Mash>] Array of pulls
|
11
|
+
# @example
|
12
|
+
# Octokit.pull_requests('rails/rails')
|
13
|
+
def pull_requests(repo, state='open', options={})
|
14
|
+
get("repos/#{Repository.new(repo)}/pulls", options.merge({:state => state}), 3)
|
15
|
+
end
|
16
|
+
alias :pulls :pull_requests
|
17
|
+
|
18
|
+
# Get a pull request
|
19
|
+
#
|
20
|
+
# @see http://developer.github.com/v3/pulls/#get-a-single-pull-request
|
21
|
+
# @param repo [String, Hash, Repository] A GitHub repository
|
22
|
+
# @param number [Integer] Number of the pull request to fetch
|
23
|
+
# @return [Hashie::Mash] Pull request info
|
24
|
+
def pull_request(repo, number, options={})
|
25
|
+
get("repos/#{Repository.new(repo)}/pulls/#{number}", options)
|
26
|
+
end
|
27
|
+
alias :pull :pull_request
|
28
|
+
|
29
|
+
# Create a pull request
|
30
|
+
#
|
31
|
+
# @see http://developer.github.com/v3/pulls/#create-a-pull-request
|
32
|
+
# @param repo [String, Hash, Repository] A GitHub repository
|
33
|
+
# @param base [String] The branch (or git ref) you want your changes
|
34
|
+
# pulled into. This should be an existing branch on the current
|
35
|
+
# repository. You cannot submit a pull request to one repo that requests
|
36
|
+
# a merge to a base of another repo.
|
37
|
+
# @param head [String] The branch (or git ref) where your changes are implemented.
|
38
|
+
# @param title [String] Title for the pull request
|
39
|
+
# @param body [String] The body for the pull request. Supports GFM.
|
40
|
+
# @return [Hashie::Mash] The newly created pull request
|
4
41
|
def create_pull_request(repo, base, head, title, body, options={})
|
5
42
|
pull = {
|
6
43
|
:base => base,
|
@@ -11,6 +48,17 @@ module Octokit
|
|
11
48
|
post("repos/#{Repository.new(repo)}/pulls", options.merge(pull))
|
12
49
|
end
|
13
50
|
|
51
|
+
# Create a pull request from existing issue
|
52
|
+
#
|
53
|
+
# @see http://developer.github.com/v3/pulls/#alternative-input
|
54
|
+
# @param repo [String, Hash, Repository] A GitHub repository
|
55
|
+
# @param base [String] The branch (or git ref) you want your changes
|
56
|
+
# pulled into. This should be an existing branch on the current
|
57
|
+
# repository. You cannot submit a pull request to one repo that requests
|
58
|
+
# a merge to a base of another repo.
|
59
|
+
# @param head [String] The branch (or git ref) where your changes are implemented.
|
60
|
+
# @param issue [Integer] Number of Issue on which to base this pull request
|
61
|
+
# @return [Hashie::Mash] The newly created pull request
|
14
62
|
def create_pull_request_for_issue(repo, base, head, issue, options={})
|
15
63
|
pull = {
|
16
64
|
:base => base,
|
@@ -20,24 +68,69 @@ module Octokit
|
|
20
68
|
post("repos/#{Repository.new(repo)}/pulls", options.merge(pull))
|
21
69
|
end
|
22
70
|
|
23
|
-
def pull_requests(repo, state='open', options={})
|
24
|
-
get("repos/#{Repository.new(repo)}/pulls", options.merge({:state => state}), 3)
|
25
|
-
end
|
26
|
-
alias :pulls :pull_requests
|
27
|
-
|
28
|
-
def pull_request(repo, number, options={})
|
29
|
-
get("repos/#{Repository.new(repo)}/pulls/#{number}", options)
|
30
|
-
end
|
31
|
-
alias :pull :pull_request
|
32
71
|
|
72
|
+
# List commits on a pull request
|
73
|
+
#
|
74
|
+
# @see http://developer.github.com/v3/pulls/#list-commits-on-a-pull-request
|
75
|
+
# @param repo [String, Hash, Repository] A GitHub repository
|
76
|
+
# @param number [Integer] Number of pull request
|
77
|
+
# @return [Array<Hashie::Mash>] List of commits
|
33
78
|
def pull_request_commits(repo, number, options={})
|
34
79
|
get("repos/#{Repository.new(repo)}/pulls/#{number}/commits", options)
|
35
80
|
end
|
36
81
|
alias :pull_commits :pull_request_commits
|
37
82
|
|
83
|
+
# List comments on a pull request
|
84
|
+
#
|
85
|
+
# @see http://developer.github.com/v3/pulls/#list-comments-on-a-pull-request
|
86
|
+
# @param repo [String, Hash, Repository] A GitHub repository
|
87
|
+
# @param number [Integer] Number of pull request
|
88
|
+
# @return [Array<Hashie::Mash>] List of comments
|
89
|
+
def pull_request_comments(repo, number, options={})
|
90
|
+
# return the comments for a pull request
|
91
|
+
get("repos/#{Repository.new(repo)}/pulls/#{number}/comments", options)
|
92
|
+
end
|
93
|
+
alias :pull_comments :pull_request_comments
|
94
|
+
alias :review_comments :pull_request_comments
|
95
|
+
|
96
|
+
# List files on a pull request
|
97
|
+
#
|
98
|
+
# @see http://developer.github.com/v3/pulls/#list-files-on-a-pull-request
|
99
|
+
# @param repo [String, Hash, Repository] A GitHub repository
|
100
|
+
# @param number [Integer] Number of pull request
|
101
|
+
# @return [Array<Hashie::Mash>] List of files
|
102
|
+
def pull_request_files(repo, number, options={})
|
103
|
+
get("repos/#{Repository.new(repo)}/pulls/#{number}/files", options)
|
104
|
+
end
|
105
|
+
alias :pull_files :pull_request_files
|
106
|
+
|
107
|
+
# Merge a pull request
|
108
|
+
#
|
109
|
+
# @see http://developer.github.com/v3/pulls/#merge-a-pull-request-merge-buttontrade
|
110
|
+
# @param repo [String, Hash, Repository] A GitHub repository
|
111
|
+
# @param number [Integer] Number of pull request
|
112
|
+
# @param commit_message [String] Optional commit message for the merge commit
|
113
|
+
# @return [Array<Hashie::Mash>] Merge commit info if successful
|
38
114
|
def merge_pull_request(repo, number, commit_message='', options={})
|
39
115
|
put("repos/#{Repository.new(repo)}/pulls/#{number}/merge", options.merge({:commit_message => commit_message}))
|
40
116
|
end
|
117
|
+
|
118
|
+
# Check pull request merge status
|
119
|
+
#
|
120
|
+
# @see http://developer.github.com/v3/pulls/#get-if-a-pull-request-has-been-merged
|
121
|
+
# @param repo [String, Hash, Repository] A GitHub repository
|
122
|
+
# @param number [Integer] Number of pull request
|
123
|
+
# @return [Boolean] True if the pull request has been merged
|
124
|
+
def pull_merged?(repo, number, options={})
|
125
|
+
begin
|
126
|
+
get("repos/#{Repository.new(repo)}/pulls/#{number}/merged", options)
|
127
|
+
return true
|
128
|
+
rescue Octokit::NotFound
|
129
|
+
return false
|
130
|
+
end
|
131
|
+
end
|
132
|
+
alias :pull_request_merged? :pull_merged?
|
133
|
+
|
41
134
|
end
|
42
135
|
end
|
43
136
|
end
|
@@ -1,16 +1,40 @@
|
|
1
1
|
module Octokit
|
2
2
|
class Client
|
3
3
|
module Repositories
|
4
|
+
|
5
|
+
# Legacy repository search
|
6
|
+
#
|
7
|
+
# @see http://developer.github.com/v3/search/#search-repositories
|
8
|
+
# @param q [String] Search keyword
|
9
|
+
# @return [Array<Hashie::Mash>] List of repositories found
|
4
10
|
def search_repositories(q, options={})
|
5
11
|
get("legacy/repos/search/#{q}", options, 3)['repositories']
|
6
12
|
end
|
7
13
|
alias :search_repos :search_repositories
|
8
14
|
|
15
|
+
# Get a single repository
|
16
|
+
#
|
17
|
+
# @see http://developer.github.com/v3/repos/#get
|
18
|
+
# @param repo [String, Hash, Repository] A GitHub repository
|
19
|
+
# @return [Hashie::Mash] Repository information
|
9
20
|
def repository(repo, options={})
|
10
21
|
get "repos/#{Repository.new repo}", options, 3
|
11
22
|
end
|
12
23
|
alias :repo :repository
|
13
24
|
|
25
|
+
# Edit a repository
|
26
|
+
#
|
27
|
+
# @see http://developer.github.com/v3/repos/#edit
|
28
|
+
# @param repo [String, Hash, Repository] A GitHub repository
|
29
|
+
# @param options [Hash] Repository information to update
|
30
|
+
# @option options [String] :name Name of the repo
|
31
|
+
# @option options [String] :description Description of the repo
|
32
|
+
# @option options [String] :homepage Home page of the repo
|
33
|
+
# @option options [String] :private `true` makes the repository private, and `false` makes it public.
|
34
|
+
# @option options [String] :has_issues `true` enables issues for this repo, `false` disables issues.
|
35
|
+
# @option options [String] :has_wiki `true` enables wiki for this repo, `false` disables wiki.
|
36
|
+
# @option options [String] :has_downloads `true` enables downloads for this repo, `false` disables downloads.
|
37
|
+
# @return [Hashie::Mash] Repository information
|
14
38
|
def edit_repository(repo, options={})
|
15
39
|
patch "repos/#{Repository.new repo}", options, 3
|
16
40
|
end
|
@@ -18,6 +42,14 @@ module Octokit
|
|
18
42
|
alias :update_repository :edit_repository
|
19
43
|
alias :update :edit_repository
|
20
44
|
|
45
|
+
# List repositories
|
46
|
+
#
|
47
|
+
# If username is not supplied, repositories for the current
|
48
|
+
# authenticated user are returned
|
49
|
+
#
|
50
|
+
# @see http://developer.github.com/v3/repos/#list-your-repositories
|
51
|
+
# @param username [String] Optional username for which to list repos
|
52
|
+
# @return [Array<Hashie::Mash>] List of repositories
|
21
53
|
def repositories(username=nil, options={})
|
22
54
|
if username.nil?
|
23
55
|
get 'user/repos', options, 3
|
@@ -29,26 +61,83 @@ module Octokit
|
|
29
61
|
alias :list_repos :repositories
|
30
62
|
alias :repos :repositories
|
31
63
|
|
64
|
+
# Star a repository
|
65
|
+
#
|
66
|
+
# @param repo [String, Hash, Repository] A GitHub repository
|
67
|
+
# @return [Boolean] `true` if successfully starred
|
32
68
|
def star(repo, options={})
|
33
|
-
|
69
|
+
begin
|
70
|
+
put "user/starred/#{Repository.new repo}", options, 3
|
71
|
+
return true
|
72
|
+
rescue Octokit::NotFound
|
73
|
+
return false
|
74
|
+
end
|
34
75
|
end
|
35
76
|
|
77
|
+
# Unstar a repository
|
78
|
+
#
|
79
|
+
# @param repo [String, Hash, Repository] A GitHub repository
|
80
|
+
# @return [Boolean] `true` if successfully unstarred
|
36
81
|
def unstar(repo, options={})
|
37
|
-
|
82
|
+
begin
|
83
|
+
delete "user/starred/#{Repository.new repo}", options, 3
|
84
|
+
return true
|
85
|
+
rescue Octokit::NotFound
|
86
|
+
return false
|
87
|
+
end
|
38
88
|
end
|
39
89
|
|
90
|
+
# Watch a repository
|
91
|
+
#
|
92
|
+
# @param repo [String, Hash, Repository] A GitHub repository
|
93
|
+
# @return [Boolean] `true` if successfully watched
|
94
|
+
# @deprecated Use #star instead
|
40
95
|
def watch(repo, options={})
|
41
|
-
|
96
|
+
begin
|
97
|
+
put "user/watched/#{Repository.new repo}", options, 3
|
98
|
+
return true
|
99
|
+
rescue Octokit::NotFound
|
100
|
+
return false
|
101
|
+
end
|
42
102
|
end
|
43
103
|
|
104
|
+
# Unwatch a repository
|
105
|
+
#
|
106
|
+
# @param repo [String, Hash, Repository] A GitHub repository
|
107
|
+
# @return [Boolean] `true` if successfully unwatched
|
108
|
+
# @deprecated Use #unstar instead
|
44
109
|
def unwatch(repo, options={})
|
45
|
-
|
110
|
+
begin
|
111
|
+
delete "user/watched/#{Repository.new repo}", options, 3
|
112
|
+
return true
|
113
|
+
rescue Octokit::NotFound
|
114
|
+
return false
|
115
|
+
end
|
46
116
|
end
|
47
117
|
|
118
|
+
# Fork a repository
|
119
|
+
#
|
120
|
+
# @param repo [String, Hash, Repository] A GitHub repository
|
121
|
+
# @return [Hashie::Mash] Repository info for the new fork
|
48
122
|
def fork(repo, options={})
|
49
123
|
post "repos/#{Repository.new repo}/forks", options, 3
|
50
124
|
end
|
51
125
|
|
126
|
+
# Create a repository for a user or organization
|
127
|
+
#
|
128
|
+
# @param name [String] Name of the new repo
|
129
|
+
# @option options [String] :description Description of the repo
|
130
|
+
# @option options [String] :homepage Home page of the repo
|
131
|
+
# @option options [String] :private `true` makes the repository private, and `false` makes it public.
|
132
|
+
# @option options [String] :has_issues `true` enables issues for this repo, `false` disables issues.
|
133
|
+
# @option options [String] :has_wiki `true` enables wiki for this repo, `false` disables wiki.
|
134
|
+
# @option options [String] :has_downloads `true` enables downloads for this repo, `false` disables downloads.
|
135
|
+
# @option options [String] :organization Short name for the org under which to create the repo.
|
136
|
+
# @option options [Integer] :team_id The id of the team that will be granted access to this repository. This is only valid when creating a repo in an organization.
|
137
|
+
# @option options [Boolean] :auto_init `true` to create an initial commit with empty README. Default is `false`.
|
138
|
+
# @option options [String] :gitignore_template Desired language or platform .gitignore template to apply. Ignored if auto_init parameter is not provided.
|
139
|
+
# @return [Hashie::Mash] Repository info for the new repository
|
140
|
+
# @see http://developer.github.com/v3/repos/#create
|
52
141
|
def create_repository(name, options={})
|
53
142
|
organization = options.delete :organization
|
54
143
|
options.merge! :name => name
|
@@ -62,16 +151,36 @@ module Octokit
|
|
62
151
|
alias :create_repo :create_repository
|
63
152
|
alias :create :create_repository
|
64
153
|
|
154
|
+
# Delete repository
|
155
|
+
#
|
156
|
+
# Note: If OAuth is used, 'delete_repo' scope is required
|
157
|
+
#
|
158
|
+
# @see http://developer.github.com/v3/repos/#delete-a-repository
|
159
|
+
# @param repo [String, Hash, Repository] A GitHub repository
|
160
|
+
# @return [Boolean] `true` if repository was deleted
|
65
161
|
def delete_repository(repo, options={})
|
66
|
-
|
162
|
+
begin
|
163
|
+
delete "repos/#{Repository.new repo}", options, 3
|
164
|
+
return true
|
165
|
+
rescue Octokit::NotFound
|
166
|
+
return false
|
167
|
+
end
|
67
168
|
end
|
68
169
|
alias :delete_repo :delete_repository
|
69
170
|
|
171
|
+
# Hide a public repository
|
172
|
+
#
|
173
|
+
# @param repo [String, Hash, Repository] A GitHub repository
|
174
|
+
# @return [Hashie::Mash] Updated repository info
|
70
175
|
def set_private(repo, options={})
|
71
176
|
# GitHub Api for setting private updated to use private attr, rather than public
|
72
177
|
update_repository repo, options.merge({ :private => true })
|
73
178
|
end
|
74
179
|
|
180
|
+
# Unhide a private repository
|
181
|
+
#
|
182
|
+
# @param repo [String, Hash, Repository] A GitHub repository
|
183
|
+
# @return [Hashie::Mash] Updated repository info
|
75
184
|
def set_public(repo, options={})
|
76
185
|
# GitHub Api for setting private updated to use private attr, rather than public
|
77
186
|
update_repository repo, options.merge({ :private => false })
|
@@ -5,6 +5,7 @@ module Octokit
|
|
5
5
|
module Configuration
|
6
6
|
VALID_OPTIONS_KEYS = [
|
7
7
|
:adapter,
|
8
|
+
:faraday_config_block,
|
8
9
|
:api_version,
|
9
10
|
:api_endpoint,
|
10
11
|
:web_endpoint,
|
@@ -48,6 +49,10 @@ module Octokit
|
|
48
49
|
@web_endpoint = File.join(value, "")
|
49
50
|
end
|
50
51
|
|
52
|
+
def faraday_config(&block)
|
53
|
+
@faraday_config_block = block
|
54
|
+
end
|
55
|
+
|
51
56
|
def reset
|
52
57
|
self.adapter = DEFAULT_ADAPTER
|
53
58
|
self.api_version = DEFAULT_API_VERSION
|
data/lib/octokit/connection.rb
CHANGED
@@ -28,13 +28,19 @@ module Octokit
|
|
28
28
|
else
|
29
29
|
builder.request :url_encoded
|
30
30
|
end
|
31
|
+
|
31
32
|
builder.use Faraday::Response::RaiseOctokitError
|
33
|
+
|
32
34
|
unless raw
|
33
35
|
builder.use FaradayMiddleware::Mashify
|
34
36
|
builder.use FaradayMiddleware::ParseJson
|
35
37
|
end
|
38
|
+
|
39
|
+
faraday_config_block.call(builder) if faraday_config_block
|
40
|
+
|
36
41
|
builder.adapter *adapter
|
37
42
|
end
|
43
|
+
|
38
44
|
connection.basic_auth authentication[:login], authentication[:password] if authenticate and authenticated?
|
39
45
|
connection
|
40
46
|
end
|
data/lib/octokit/version.rb
CHANGED
data/octokit.gemspec
CHANGED
@@ -6,8 +6,8 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.add_dependency 'faraday', '~> 0.8'
|
7
7
|
gem.add_dependency 'faraday_middleware', '~> 0.8'
|
8
8
|
gem.add_dependency 'hashie', '~> 1.2'
|
9
|
+
gem.add_dependency 'json', '~> 1.7'
|
9
10
|
gem.add_dependency 'multi_json', '~> 1.3'
|
10
|
-
gem.add_development_dependency 'json'
|
11
11
|
gem.add_development_dependency 'maruku'
|
12
12
|
gem.add_development_dependency 'rake'
|
13
13
|
gem.add_development_dependency 'rspec'
|
@@ -32,4 +32,24 @@ describe Faraday::Response do
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
35
|
+
|
36
|
+
[
|
37
|
+
{:message => "Problems parsing JSON"},
|
38
|
+
{:error => "Body should be a JSON Hash"}
|
39
|
+
].each do |body|
|
40
|
+
context "when the response body contains an error message" do
|
41
|
+
|
42
|
+
before do
|
43
|
+
stub_get('https://api.github.com/users/sferik').
|
44
|
+
to_return(:status => 400, :body => body)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should raise an error with the error message" do
|
48
|
+
lambda do
|
49
|
+
@client.user('sferik')
|
50
|
+
end.should raise_error(Octokit::BadRequest, /#{body.values.first}/)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
35
55
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"updated_at": "2012-01-12T10:21:32Z",
|
3
|
+
"path": ".rspec",
|
4
|
+
"body": "Hey Eric,\r\n\r\nI think it's a terrible idea: for a number of reasons (dissections, etc.), test suite should stay deterministic IMO.\r\n",
|
5
|
+
"line": 1,
|
6
|
+
"user": {
|
7
|
+
"avatar_url": "https://secure.gravatar.com/avatar/c1607873b99845b2cd53f8634860d4d4?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png",
|
8
|
+
"login": "bbenezech",
|
9
|
+
"gravatar_id": "c1607873b99845b2cd53f8634860d4d4",
|
10
|
+
"id": 26794,
|
11
|
+
"url": "https://api.github.com/users/bbenezech"
|
12
|
+
},
|
13
|
+
"created_at": "2012-01-12T10:21:32Z",
|
14
|
+
"commit_id": "629e9fd9d4df25528e84d31afdc8ebeb0f56fbb3",
|
15
|
+
"position": 4,
|
16
|
+
"id": 860296,
|
17
|
+
"html_url": "https://github.com/sferik/rails_admin/commit/629e9fd9d4df25528e84d31afdc8ebeb0f56fbb3#commitcomment-860296",
|
18
|
+
"url": "https://api.github.com/repos/sferik/rails_admin/comments/860296"
|
19
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"updated_at": "2012-01-12T10:21:32Z",
|
3
|
+
"path": ".rspec",
|
4
|
+
"body": "Hey Eric,\r\n\r\nI think it's a terrible idea. The test suite should stay deterministic IMO.\r\n",
|
5
|
+
"line": 1,
|
6
|
+
"user": {
|
7
|
+
"avatar_url": "https://secure.gravatar.com/avatar/c1607873b99845b2cd53f8634860d4d4?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png",
|
8
|
+
"login": "bbenezech",
|
9
|
+
"gravatar_id": "c1607873b99845b2cd53f8634860d4d4",
|
10
|
+
"id": 26794,
|
11
|
+
"url": "https://api.github.com/users/bbenezech"
|
12
|
+
},
|
13
|
+
"created_at": "2012-01-12T10:21:32Z",
|
14
|
+
"commit_id": "629e9fd9d4df25528e84d31afdc8ebeb0f56fbb3",
|
15
|
+
"position": 4,
|
16
|
+
"id": 860296,
|
17
|
+
"html_url": "https://github.com/sferik/rails_admin/commit/629e9fd9d4df25528e84d31afdc8ebeb0f56fbb3#commitcomment-860296",
|
18
|
+
"url": "https://api.github.com/repos/sferik/rails_admin/comments/860296"
|
19
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"created_at": "2012-01-31T14:23:41Z",
|
4
|
+
"position": 5,
|
5
|
+
"original_commit_id": "2097821c7c5aa4dc02a2cc54d5ca51968b373f95",
|
6
|
+
"path": "lib/octokit/repository.rb",
|
7
|
+
"original_position": 5,
|
8
|
+
"commit_id": "2097821c7c5aa4dc02a2cc54d5ca51968b373f95",
|
9
|
+
"_links": {
|
10
|
+
"self": {
|
11
|
+
"href": "https://api.github.com/repos/pengwynn/octokit/pulls/comments/401530"
|
12
|
+
},
|
13
|
+
"html": {
|
14
|
+
"href": "https://github.com/pengwynn/octokit/pull/67#discussion_r401530"
|
15
|
+
},
|
16
|
+
"pull_request": {
|
17
|
+
"href": "https://api.github.com/repos/pengwynn/octokit/pulls/67"
|
18
|
+
}
|
19
|
+
},
|
20
|
+
"updated_at": "2012-01-31T14:23:41Z",
|
21
|
+
"user": {
|
22
|
+
"avatar_url": "https://secure.gravatar.com/avatar/dfb3948650131e4f0385c3328187cfca?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png",
|
23
|
+
"gravatar_id": "dfb3948650131e4f0385c3328187cfca",
|
24
|
+
"login": "ctshryock",
|
25
|
+
"url": "https://api.github.com/users/ctshryock",
|
26
|
+
"urls": {
|
27
|
+
"self": "https://api.github.com/users/ctshryock"
|
28
|
+
},
|
29
|
+
"id": 61721
|
30
|
+
},
|
31
|
+
"body": "This is causing a test to fail (`respository_spec.rb`, `\"should render url as string\"`). On line 15 of `configuration.rb` you add `github_url` as an option key, which is then added as to the `Client` in the `attr_accessor` block, but it's an instance method not a class method. ",
|
32
|
+
"url": "https://api.github.com/repos/pengwynn/octokit/pulls/comments/401530",
|
33
|
+
"id": 401530
|
34
|
+
}
|
35
|
+
]
|
@@ -0,0 +1,35 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"filename": "README.md",
|
4
|
+
"raw_url": "https://github.com/pengwynn/octokit/raw/55b0fffd7e73fc9e098beee486b31e0fba343e40/README.md",
|
5
|
+
"blob_url": "https://github.com/pengwynn/octokit/blob/55b0fffd7e73fc9e098beee486b31e0fba343e40/README.md",
|
6
|
+
"status": "modified",
|
7
|
+
"additions": 28,
|
8
|
+
"sha": "050957c6c397050ac809b4350971d15103cdea54",
|
9
|
+
"patch": "@@ -64,6 +64,34 @@ client = Octokit::Client.new(:login => \"me\", :oauth_token => \"oauth2token\")\n client.follow(\"sferik\")\n ```\n \n+## Rate Limiting and Conditional Requests\n+GitHub limits API requests to 5000 per hour.\n+\n+```ruby\n+client = Octokit::Client.new(:login => \"me\", :oauth_token => \"oauth2token\")\n+client.ratelimit_remaining # 5000\n+client.repositories\n+client.ratelimit_remaining # 4999\n+```\n+\n+You can make conditional requests which will only return data to you if there\n+have been changes since your last request. Pass either the `since` or `etag`\n+option to any API call to perform a conditional request, and immediately after\n+the request is complete the client will have the attributes `last_modified` and\n+`etag` populated to be used for the next identical API call.\n+\n+```ruby\n+client = Octokit::Client(:login => \"me\", :oauth_token => \"oauth2token\")\n+client.ratelimit_remaining # 5000\n+client.repositories # (Returns an array of repositories)\n+client.ratelimit_remaining # 4999\n+repos_last_modified = client.last_modified\n+\n+client.repositories(nil,\n+ :since => repos_last_modified) # nil\n+client.ratelimit_remaining # 4999\n+```\n+\n ## Using with GitHub Enterprise\n \n To use with [GitHub Enterprise](https://enterprise.github.com/), you'll need to",
|
10
|
+
"deletions": 0,
|
11
|
+
"changes": 28
|
12
|
+
},
|
13
|
+
{
|
14
|
+
"filename": "lib/octokit/client.rb",
|
15
|
+
"raw_url": "https://github.com/pengwynn/octokit/raw/55b0fffd7e73fc9e098beee486b31e0fba343e40/lib/octokit/client.rb",
|
16
|
+
"blob_url": "https://github.com/pengwynn/octokit/blob/55b0fffd7e73fc9e098beee486b31e0fba343e40/lib/octokit/client.rb",
|
17
|
+
"status": "modified",
|
18
|
+
"additions": 1,
|
19
|
+
"sha": "feb96c24ec0a8a0bedf8d55289693e1de59cec40",
|
20
|
+
"patch": "@@ -28,6 +28,7 @@\n module Octokit\n class Client\n attr_accessor(*Configuration::VALID_OPTIONS_KEYS)\n+ attr_accessor(:last_modified, :etag)\n \n def initialize(options={})\n options = Octokit.options.merge(options)",
|
21
|
+
"deletions": 0,
|
22
|
+
"changes": 1
|
23
|
+
},
|
24
|
+
{
|
25
|
+
"filename": "lib/octokit/request.rb",
|
26
|
+
"raw_url": "https://github.com/pengwynn/octokit/raw/55b0fffd7e73fc9e098beee486b31e0fba343e40/lib/octokit/request.rb",
|
27
|
+
"blob_url": "https://github.com/pengwynn/octokit/blob/55b0fffd7e73fc9e098beee486b31e0fba343e40/lib/octokit/request.rb",
|
28
|
+
"status": "modified",
|
29
|
+
"additions": 6,
|
30
|
+
"sha": "5af4a1f92333ea52d35475fdea108564f617a7eb",
|
31
|
+
"patch": "@@ -39,6 +39,9 @@ def ratelimit_remaining\n def request(method, path, options, version, authenticate, raw, force_urlencoded)\n path.sub(%r{^/}, '') #leading slash in path fails in github:enterprise\n response = connection(authenticate, raw, version, force_urlencoded).send(method) do |request|\n+ request.headers['If-Modified-Since'] = options.delete(:since) unless options[:since].nil?\n+ request.headers['If-None-Match'] = options.delete(:etag) unless options[:etag].nil?\n+\n case method\n when :delete, :get\n if auto_traversal && per_page.nil?\n@@ -58,6 +61,9 @@ def request(method, path, options, version, authenticate, raw, force_urlencoded)\n request.headers['Host'] = Octokit.request_host if Octokit.request_host\n end\n \n+ self.last_modified = response.headers['Last-Modified']\n+ self.etag = response.headers['ETag'].gsub('\"', '') unless response.headers['ETag'].nil?\n+\n if raw\n response\n elsif auto_traversal && ( next_url = links(response)[\"next\"] )",
|
32
|
+
"deletions": 0,
|
33
|
+
"changes": 6
|
34
|
+
}
|
35
|
+
]
|
@@ -78,6 +78,47 @@ describe Octokit::Client::Commits do
|
|
78
78
|
|
79
79
|
end
|
80
80
|
|
81
|
+
describe ".create_commit_comment" do
|
82
|
+
|
83
|
+
it "should create a commit comment" do
|
84
|
+
stub_post("/repos/sferik/rails_admin/commits/629e9fd9d4df25528e84d31afdc8ebeb0f56fbb3/comments").
|
85
|
+
with(:body => { :body => "Hey Eric,\r\n\r\nI think it's a terrible idea: for a number of reasons (dissections, etc.), test suite should stay deterministic IMO.\r\n", :commit_id => "629e9fd9d4df25528e84d31afdc8ebeb0f56fbb3", :line => 1, :path => ".rspec", :position => 4 },
|
86
|
+
:headers => { "Content-Type" => "application/json" }).
|
87
|
+
to_return(:body => fixture("v3/commit_comment_create.json"))
|
88
|
+
commit_comment = @client.create_commit_comment("sferik/rails_admin", "629e9fd9d4df25528e84d31afdc8ebeb0f56fbb3", "Hey Eric,\r\n\r\nI think it's a terrible idea: for a number of reasons (dissections, etc.), test suite should stay deterministic IMO.\r\n", ".rspec", 1, 4)
|
89
|
+
commit_comment.body.should == "Hey Eric,\r\n\r\nI think it's a terrible idea: for a number of reasons (dissections, etc.), test suite should stay deterministic IMO.\r\n"
|
90
|
+
commit_comment.commit_id.should == "629e9fd9d4df25528e84d31afdc8ebeb0f56fbb3"
|
91
|
+
commit_comment.path.should == ".rspec"
|
92
|
+
commit_comment.line.should == 1
|
93
|
+
commit_comment.position.should == 4
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
describe ".update_commit_comment" do
|
99
|
+
|
100
|
+
it "should update a commit comment" do
|
101
|
+
stub_patch("/repos/sferik/rails_admin/comments/860296").
|
102
|
+
with(:body => { :body => "Hey Eric,\r\n\r\nI think it's a terrible idea. The test suite should stay deterministic IMO.\r\n" },
|
103
|
+
:headers => { "Content-Type" => "application/json" }).
|
104
|
+
to_return(:body => fixture("v3/commit_comment_update.json"))
|
105
|
+
commit_comment = @client.update_commit_comment("sferik/rails_admin", "860296", "Hey Eric,\r\n\r\nI think it's a terrible idea. The test suite should stay deterministic IMO.\r\n")
|
106
|
+
commit_comment.body.should == "Hey Eric,\r\n\r\nI think it's a terrible idea. The test suite should stay deterministic IMO.\r\n"
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
describe ".delete_commit_comment" do
|
112
|
+
|
113
|
+
it "should delete a commit comment" do
|
114
|
+
stub_delete("/repos/sferik/rails_admin/comments/860296").
|
115
|
+
to_return(:status => 204, :body => "")
|
116
|
+
commit_comment = @client.delete_commit_comment("sferik/rails_admin", "860296")
|
117
|
+
commit_comment.should be_false
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
|
81
122
|
describe ".compare" do
|
82
123
|
|
83
124
|
it "should return a comparison" do
|
@@ -10,7 +10,7 @@ describe Octokit::Client::Gists do
|
|
10
10
|
|
11
11
|
describe ".public_gists" do
|
12
12
|
it "should return public gists" do
|
13
|
-
stub_get("/gists").to_return(:body => fixture("v3/public_gists.json"))
|
13
|
+
stub_get("/gists/public").to_return(:body => fixture("v3/public_gists.json"))
|
14
14
|
gists = @client.public_gists
|
15
15
|
gists.should_not be_empty
|
16
16
|
end
|
@@ -20,13 +20,20 @@ describe Octokit::Client::Issues do
|
|
20
20
|
|
21
21
|
describe ".list_issues" do
|
22
22
|
|
23
|
-
it "should return issues" do
|
23
|
+
it "should return issues for a repository" do
|
24
24
|
stub_get("/repos/sferik/rails_admin/issues").
|
25
25
|
to_return(:body => fixture("v3/issues.json"))
|
26
26
|
issues = @client.issues("sferik/rails_admin")
|
27
27
|
issues.first.number.should == 388
|
28
28
|
end
|
29
29
|
|
30
|
+
it "should return issues for the authenticated user" do
|
31
|
+
stub_get("/issues").
|
32
|
+
to_return(:body => fixture("v3/issues.json"))
|
33
|
+
issues = @client.issues
|
34
|
+
issues.first.number.should == 388
|
35
|
+
end
|
36
|
+
|
30
37
|
end
|
31
38
|
|
32
39
|
describe ".create_issue" do
|
@@ -27,7 +27,7 @@ describe Octokit::Client::Pulls do
|
|
27
27
|
with(:pull => {:base => "master", :head => "pengwynn:octokit", :issue => "15"}).
|
28
28
|
to_return(:body => fixture("v3/pull_created.json"))
|
29
29
|
pull = @client.create_pull_request_for_issue("pengwynn/octokit", "master", "pengwynn:octokit", "15")
|
30
|
-
pull.number.should == 15
|
30
|
+
pull.number.should == 15
|
31
31
|
end
|
32
32
|
|
33
33
|
end
|
@@ -49,7 +49,7 @@ describe Octokit::Client::Pulls do
|
|
49
49
|
stub_get("https://api.github.com/repos/pengwynn/octokit/pulls/67").
|
50
50
|
to_return(:body => fixture("v3/pull_request.json"))
|
51
51
|
pull = @client.pull("pengwynn/octokit", 67)
|
52
|
-
pull.number.should == 67
|
52
|
+
pull.number.should == 67
|
53
53
|
end
|
54
54
|
|
55
55
|
end
|
@@ -65,6 +65,17 @@ describe Octokit::Client::Pulls do
|
|
65
65
|
|
66
66
|
end
|
67
67
|
|
68
|
+
describe ".pull_request_comments" do
|
69
|
+
|
70
|
+
it "should return the comments for a pull request" do
|
71
|
+
stub_get("https://api.github.com/repos/pengwynn/octokit/pulls/67/comments").
|
72
|
+
to_return(:body => fixture("v3/pull_request_comments.json"))
|
73
|
+
commits = @client.pull_comments("pengwynn/octokit", 67)
|
74
|
+
commits.first["id"].should == 401530
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
68
79
|
describe ".merge_pull_request" do
|
69
80
|
|
70
81
|
it "should merge the pull request" do
|
@@ -76,4 +87,28 @@ describe Octokit::Client::Pulls do
|
|
76
87
|
|
77
88
|
end
|
78
89
|
|
90
|
+
describe ".pull_request_files" do
|
91
|
+
|
92
|
+
it "should list files for a pull request" do
|
93
|
+
stub_get("https://api.github.com/repos/pengwynn/octokit/pulls/142/files").
|
94
|
+
to_return(:body => fixture("v3/pull_request_files.json"))
|
95
|
+
|
96
|
+
files = @client.pull_request_files("pengwynn/octokit", 142)
|
97
|
+
file = files.first
|
98
|
+
file.filename.should == 'README.md'
|
99
|
+
file.additions.should == 28
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
describe ".pull_merged?" do
|
105
|
+
|
106
|
+
it "should see if the pull request has been merged" do
|
107
|
+
stub_get("https://api.github.com/repos/pengwynn/octokit/pulls/67/merged").
|
108
|
+
to_return(:status => 204)
|
109
|
+
merged = @client.pull_merged?("pengwynn/octokit", 67)
|
110
|
+
merged.should be_true
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
79
114
|
end
|
@@ -73,7 +73,7 @@ describe Octokit::Client::Repositories do
|
|
73
73
|
it "should star a repository" do
|
74
74
|
stub_put("/user/starred/sferik/rails_admin").
|
75
75
|
to_return(:status => 204)
|
76
|
-
@client.star("sferik/rails_admin").should
|
76
|
+
@client.star("sferik/rails_admin").should be_true
|
77
77
|
end
|
78
78
|
|
79
79
|
end
|
@@ -83,7 +83,7 @@ describe Octokit::Client::Repositories do
|
|
83
83
|
it "should unstar a repository" do
|
84
84
|
stub_delete("/user/starred/sferik/rails_admin").
|
85
85
|
to_return(:status => 204)
|
86
|
-
@client.unstar("sferik/rails_admin").should
|
86
|
+
@client.unstar("sferik/rails_admin").should be_true
|
87
87
|
end
|
88
88
|
|
89
89
|
end
|
@@ -93,7 +93,7 @@ describe Octokit::Client::Repositories do
|
|
93
93
|
it "should watch a repository" do
|
94
94
|
stub_put("/user/watched/sferik/rails_admin").
|
95
95
|
to_return(:status => 204)
|
96
|
-
@client.watch("sferik/rails_admin").should
|
96
|
+
@client.watch("sferik/rails_admin").should be_true
|
97
97
|
end
|
98
98
|
|
99
99
|
end
|
@@ -103,7 +103,7 @@ describe Octokit::Client::Repositories do
|
|
103
103
|
it "should unwatch a repository" do
|
104
104
|
stub_delete("/user/watched/sferik/rails_admin").
|
105
105
|
to_return(:status => 204)
|
106
|
-
@client.unwatch("sferik/rails_admin").should
|
106
|
+
@client.unwatch("sferik/rails_admin").should be_true
|
107
107
|
end
|
108
108
|
|
109
109
|
end
|
@@ -146,7 +146,7 @@ describe Octokit::Client::Repositories do
|
|
146
146
|
stub_delete("/repos/sferik/rails_admin").
|
147
147
|
to_return(:status => 204, :body => "")
|
148
148
|
result = @client.delete_repository("sferik/rails_admin")
|
149
|
-
result.should
|
149
|
+
result.should be_true
|
150
150
|
end
|
151
151
|
|
152
152
|
end
|
data/spec/octokit/client_spec.rb
CHANGED
@@ -10,6 +10,19 @@ describe Octokit::Client do
|
|
10
10
|
}.should_not raise_exception
|
11
11
|
end
|
12
12
|
|
13
|
+
it 'should configure faraday from faraday_config_block' do
|
14
|
+
mw_evaluated = false
|
15
|
+
Octokit.configure do |c|
|
16
|
+
c.faraday_config { |f| mw_evaluated = true }
|
17
|
+
end
|
18
|
+
stub_request(:get, "https://api.github.com/rate_limit").
|
19
|
+
to_return(:status => 200, :body => '', :headers =>
|
20
|
+
{ 'X-RateLimit-Limit' => 5000, 'X-RateLimit-Remaining' => 5000})
|
21
|
+
client = Octokit::Client.new()
|
22
|
+
client.rate_limit
|
23
|
+
mw_evaluated.should be_true
|
24
|
+
end
|
25
|
+
|
13
26
|
|
14
27
|
describe "auto_traversal" do
|
15
28
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octokit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.17.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-
|
14
|
+
date: 2012-10-08 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: addressable
|
@@ -78,13 +78,13 @@ dependencies:
|
|
78
78
|
- !ruby/object:Gem::Version
|
79
79
|
version: '1.2'
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
|
-
name:
|
81
|
+
name: json
|
82
82
|
requirement: !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
86
86
|
- !ruby/object:Gem::Version
|
87
|
-
version: '1.
|
87
|
+
version: '1.7'
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
90
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -92,23 +92,23 @@ dependencies:
|
|
92
92
|
requirements:
|
93
93
|
- - ~>
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: '1.
|
95
|
+
version: '1.7'
|
96
96
|
- !ruby/object:Gem::Dependency
|
97
|
-
name:
|
97
|
+
name: multi_json
|
98
98
|
requirement: !ruby/object:Gem::Requirement
|
99
99
|
none: false
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ~>
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
104
|
-
type: :
|
103
|
+
version: '1.3'
|
104
|
+
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
none: false
|
108
108
|
requirements:
|
109
|
-
- -
|
109
|
+
- - ~>
|
110
110
|
- !ruby/object:Gem::Version
|
111
|
-
version: '
|
111
|
+
version: '1.3'
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
113
|
name: maruku
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
@@ -270,6 +270,8 @@ files:
|
|
270
270
|
- spec/fixtures/v3/comments.json
|
271
271
|
- spec/fixtures/v3/commit.json
|
272
272
|
- spec/fixtures/v3/commit_comment.json
|
273
|
+
- spec/fixtures/v3/commit_comment_create.json
|
274
|
+
- spec/fixtures/v3/commit_comment_update.json
|
273
275
|
- spec/fixtures/v3/commit_comments.json
|
274
276
|
- spec/fixtures/v3/commit_create.json
|
275
277
|
- spec/fixtures/v3/commits.json
|
@@ -315,7 +317,9 @@ files:
|
|
315
317
|
- spec/fixtures/v3/public_keys.json
|
316
318
|
- spec/fixtures/v3/pull_created.json
|
317
319
|
- spec/fixtures/v3/pull_request.json
|
320
|
+
- spec/fixtures/v3/pull_request_comments.json
|
318
321
|
- spec/fixtures/v3/pull_request_commits.json
|
322
|
+
- spec/fixtures/v3/pull_request_files.json
|
319
323
|
- spec/fixtures/v3/pull_request_merged.json
|
320
324
|
- spec/fixtures/v3/pull_requests.json
|
321
325
|
- spec/fixtures/v3/readme.json
|
@@ -408,6 +412,8 @@ test_files:
|
|
408
412
|
- spec/fixtures/v3/comments.json
|
409
413
|
- spec/fixtures/v3/commit.json
|
410
414
|
- spec/fixtures/v3/commit_comment.json
|
415
|
+
- spec/fixtures/v3/commit_comment_create.json
|
416
|
+
- spec/fixtures/v3/commit_comment_update.json
|
411
417
|
- spec/fixtures/v3/commit_comments.json
|
412
418
|
- spec/fixtures/v3/commit_create.json
|
413
419
|
- spec/fixtures/v3/commits.json
|
@@ -453,7 +459,9 @@ test_files:
|
|
453
459
|
- spec/fixtures/v3/public_keys.json
|
454
460
|
- spec/fixtures/v3/pull_created.json
|
455
461
|
- spec/fixtures/v3/pull_request.json
|
462
|
+
- spec/fixtures/v3/pull_request_comments.json
|
456
463
|
- spec/fixtures/v3/pull_request_commits.json
|
464
|
+
- spec/fixtures/v3/pull_request_files.json
|
457
465
|
- spec/fixtures/v3/pull_request_merged.json
|
458
466
|
- spec/fixtures/v3/pull_requests.json
|
459
467
|
- spec/fixtures/v3/readme.json
|