reenhanced_bitbucket_api 0.3.0 → 0.3.1
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 +4 -4
- data/lib/bitbucket_rest_api/api.rb +1 -1
- data/lib/bitbucket_rest_api/client/repos/pull_requests/comments.rb +11 -9
- data/lib/bitbucket_rest_api/client/repos/pull_requests.rb +46 -52
- data/lib/bitbucket_rest_api/configuration.rb +1 -0
- data/lib/bitbucket_rest_api/middleware.rb +3 -3
- data/lib/bitbucket_rest_api/pagination.rb +3 -4
- data/lib/bitbucket_rest_api/version.rb +1 -1
- metadata +3 -4
- data/lib/bitbucket_rest_api/client/repos/pull_requests/activity.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2178492c596e3ffcfb3b03ef8e73b137953f901
|
4
|
+
data.tar.gz: cd635c715d33fe9253d3a568b935102fd029f99d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d22c626f262033048a2343df7ac90d418b4b8a04d5101b24cd5c65494aa186dd1660ede36b21e69bbf49ff6990d0bcc5c31b39c960cb26c2b6d541903dc6c3a3
|
7
|
+
data.tar.gz: c89b629dcdaa899a8bf3de1cf9c5a55afe695e14d113bc889dc59d1669b484662ecd84fea237532c03fc7c263ce81c21baaca964889e9e49ef26fdcd226172d4
|
@@ -58,7 +58,7 @@ module BitBucket
|
|
58
58
|
options = BitBucket.configuration.fetch.merge(options)
|
59
59
|
self.current_options = options
|
60
60
|
if self.class.instance_variable_get('@version') == '2.0'
|
61
|
-
options[:endpoint] = BitBucket.
|
61
|
+
options[:endpoint] = BitBucket.endpoint_v2
|
62
62
|
end
|
63
63
|
BitBucket.configuration.property_names.each do |key|
|
64
64
|
send("#{key}=", options[key])
|
@@ -10,10 +10,11 @@ module BitBucket
|
|
10
10
|
# bitbucket = BitBucket.new
|
11
11
|
# bitbucket.repos.pull_requests.comments.all 'user-name', 'repo-name', 'pull-request-id'
|
12
12
|
#
|
13
|
-
def list(
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
def list(*args)
|
14
|
+
arguments(args, required: [:user, :repo, :pull_request_id])
|
15
|
+
user = arguments.user
|
16
|
+
repo = arguments.repo
|
17
|
+
pull_request_id = arguments.pull_request_id
|
17
18
|
|
18
19
|
response = get_request("/repositories/#{user}/#{repo.downcase}/pullrequests/#{pull_request_id}/comments")
|
19
20
|
return response unless block_given?
|
@@ -27,11 +28,12 @@ module BitBucket
|
|
27
28
|
# @bitbucket = BitBucket.new
|
28
29
|
# @bitbucket.repos.pull_requests.comments.get 'user-name', 'repo-name', 'pull-request-id')
|
29
30
|
#
|
30
|
-
def get(
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
def get(*args)
|
32
|
+
arguments(args, required: [:user, :repo, :pull_request_id, :comment_id])
|
33
|
+
user = arguments.user
|
34
|
+
repo = arguments.repo
|
35
|
+
pull_request_id = arguments.pull_request_id
|
36
|
+
comment_id = arguments.comment_id
|
35
37
|
|
36
38
|
get_request("/repositories/#{user}/#{repo.downcase}/pullrequests/#{pull_request_id}/comments/#{comment_id}")
|
37
39
|
end
|
@@ -6,8 +6,12 @@ module BitBucket
|
|
6
6
|
# Load all the modules after initializing Repos to avoid superclass mismatch
|
7
7
|
require_all 'bitbucket_rest_api/client/repos/pull_requests',
|
8
8
|
'comments',
|
9
|
-
'commits'
|
10
|
-
|
9
|
+
'commits'
|
10
|
+
|
11
|
+
REQUIRED_PULL_REQUEST_OPTIONS = %w[
|
12
|
+
title
|
13
|
+
source
|
14
|
+
]
|
11
15
|
|
12
16
|
VALID_PULL_REQUEST_PARAM_NAMES = %w[
|
13
17
|
title
|
@@ -34,17 +38,16 @@ module BitBucket
|
|
34
38
|
# <tt>:state</tt> - Optional - State of the pull request (OPEN, MERGED, DECLINED)
|
35
39
|
#
|
36
40
|
def list(*args)
|
37
|
-
args
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
assert_values VALID_PULL_REQUEST_STATE_VALUES
|
42
|
-
end.params
|
41
|
+
arguments(args, required: [:user, :repo], optional: [:state])
|
42
|
+
params = arguments.params
|
43
|
+
user = arguments.user
|
44
|
+
repo = arguments.repo
|
43
45
|
|
46
|
+
params['state'] ||= 'OPEN'
|
44
47
|
# Bitbucket requires the state to be all caps or it returns all
|
45
|
-
params['state']
|
48
|
+
params['state'] = params['state'].upcase
|
46
49
|
|
47
|
-
response = get_request("/repositories/#{
|
50
|
+
response = get_request("/repositories/#{user}/#{repo}/pullrequests/", params)
|
48
51
|
|
49
52
|
return response unless block_given?
|
50
53
|
response.each { |el| yield el }
|
@@ -57,14 +60,10 @@ module BitBucket
|
|
57
60
|
# bitbucket = BitBucket.new
|
58
61
|
# bitbucket.repos.pull_requests.find 'user-name', 'repo-name', 'pull-request-id'
|
59
62
|
#
|
60
|
-
def get(
|
61
|
-
|
62
|
-
_validate_user_repo_params(user, repo) unless user? && repo?
|
63
|
-
_validate_presence_of pull_request_id
|
63
|
+
def get(*args)
|
64
|
+
arguments(args, required: [:user, :repo, :pull_request_id])
|
64
65
|
|
65
|
-
|
66
|
-
|
67
|
-
get_request("/repositories/#{user}/#{repo.downcase}/pullrequests/#{pull_request_id}", params)
|
66
|
+
get_request("/repositories/#{arguments.user}/#{arguments.repo.downcase}/pullrequests/#{arguments.pull_request_id}", arguments.params)
|
68
67
|
end
|
69
68
|
|
70
69
|
alias :find :get
|
@@ -82,8 +81,8 @@ module BitBucket
|
|
82
81
|
# * <tt>[{ "username": "accountname" }]</tt>
|
83
82
|
#
|
84
83
|
# = Examples
|
85
|
-
# bitbucket = BitBucket.new
|
86
|
-
# bitbucket.repos.pull_requests.create
|
84
|
+
# bitbucket = BitBucket.new
|
85
|
+
# bitbucket.repos.pull_requests.create 'user-name', 'repo-name',
|
87
86
|
# "title" => "Fixes a bug",
|
88
87
|
# "description" => "Fixes not being able to see anything.",
|
89
88
|
# "source" => { "branch" => { "name" => "bug-fixes" } },
|
@@ -91,15 +90,13 @@ module BitBucket
|
|
91
90
|
# "reviewers" => [ { "username" => "octocat" } ],
|
92
91
|
# "close_source_branch" => true
|
93
92
|
#
|
94
|
-
def create(
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
filter! VALID_PULL_REQUEST_PARAM_NAMES , params
|
100
|
-
assert_required_keys(%w[ title source ], params)
|
93
|
+
def create(*args)
|
94
|
+
arguments(args, required: [:user, :repo]) do
|
95
|
+
permit VALID_PULL_REQUEST_PARAM_NAMES
|
96
|
+
assert_required REQUIRED_PULL_REQUEST_OPTIONS
|
97
|
+
end
|
101
98
|
|
102
|
-
post_request("/repositories/#{user}/#{repo.downcase}/pullrequests
|
99
|
+
post_request("/repositories/#{arguments.user}/#{arguments.repo.downcase}/pullrequests", arguments.params)
|
103
100
|
end
|
104
101
|
|
105
102
|
# Edit a pull request
|
@@ -121,13 +118,17 @@ module BitBucket
|
|
121
118
|
# "reviewers" => [ { "username" => "octocat" } ],
|
122
119
|
# "close_source_branch" => true
|
123
120
|
#
|
124
|
-
def update(
|
125
|
-
|
126
|
-
|
127
|
-
|
121
|
+
def update(*args)
|
122
|
+
arguments(args, required: [:user, :repo, :pull_request_id]) do
|
123
|
+
permit VALID_PULL_REQUEST_PARAM_NAMES
|
124
|
+
end
|
125
|
+
|
126
|
+
user = arguments.user
|
127
|
+
repo = arguments.repo
|
128
|
+
pull_request_id = arguments.pull_request_id
|
128
129
|
|
129
130
|
# BitBucket will drop any data if it is not included, so we have to check for pre-existing data
|
130
|
-
existing_pull = get(
|
131
|
+
existing_pull = get(user, repo, pull_request_id)
|
131
132
|
existing_pull_data = {
|
132
133
|
'title' => existing_pull.title,
|
133
134
|
'description' => existing_pull.description,
|
@@ -137,10 +138,7 @@ module BitBucket
|
|
137
138
|
'reviewers' => existing_pull.reviewers,
|
138
139
|
'close_source_branch' => existing_pull.close_source_branch
|
139
140
|
}
|
140
|
-
params = normalize!(existing_pull_data).merge!(normalize!(params))
|
141
|
-
|
142
|
-
filter! VALID_PULL_REQUEST_PARAM_NAMES.reject{|param| param == 'source'}, params
|
143
|
-
assert_required_keys(%w[ title ], params)
|
141
|
+
params = normalize!(existing_pull_data).merge!(normalize!(arguments.params))
|
144
142
|
|
145
143
|
put_request("/repositories/#{user}/#{repo.downcase}/pullrequests/#{pull_request_id}/", params)
|
146
144
|
end
|
@@ -153,11 +151,9 @@ module BitBucket
|
|
153
151
|
# bitbucket.repos.pull_requests.reject 'user-name', 'repo-name', 'pull-request-id'
|
154
152
|
#
|
155
153
|
def decline(user_name, repo_name, pull_request_id)
|
156
|
-
|
157
|
-
_validate_user_repo_params(user, repo) unless user? && repo?
|
158
|
-
_validate_presence_of pull_request_id
|
154
|
+
arguments(args, required: [:user, :repo, :pull_request_id])
|
159
155
|
|
160
|
-
post_request("/repositories/#{user}/#{repo}/pullrequests/#{pull_request_id}/decline")
|
156
|
+
post_request("/repositories/#{arguments.user}/#{arguments.repo}/pullrequests/#{arguments.pull_request_id}/decline")
|
161
157
|
end
|
162
158
|
alias :reject :decline
|
163
159
|
|
@@ -168,11 +164,9 @@ module BitBucket
|
|
168
164
|
# bitbucket.repos.pull_requests.approve 'user-name', 'repo-name', 'pull-request-id'
|
169
165
|
#
|
170
166
|
def approve(user_name, repo_name, pull_request_id)
|
171
|
-
|
172
|
-
_validate_user_repo_params(user, repo) unless user? && repo?
|
173
|
-
_validate_presence_of pull_request_id
|
167
|
+
arguments(args, required: [:user, :repo, :pull_request_id])
|
174
168
|
|
175
|
-
post_request("/repositories/#{user}/#{repo}/pullrequests/#{pull_request_id}/approve")
|
169
|
+
post_request("/repositories/#{arguments.user}/#{arguments.repo}/pullrequests/#{arguments.pull_request_id}/approve")
|
176
170
|
end
|
177
171
|
|
178
172
|
# Get the diff for a pull request
|
@@ -182,11 +176,9 @@ module BitBucket
|
|
182
176
|
# bitbucket.repos.pull_requests.diff 'user-name', 'repo-name', 'pull-request-id'
|
183
177
|
#
|
184
178
|
def diff(user_name, repo_name, pull_request_id)
|
185
|
-
|
186
|
-
_validate_user_repo_params(user, repo) unless user? && repo?
|
187
|
-
_validate_presence_of pull_request_id
|
179
|
+
arguments(args, required: [:user, :repo, :pull_request_id])
|
188
180
|
|
189
|
-
get_request("/repositories/#{user}/#{repo}/pullrequests/#{pull_request_id}/diff")
|
181
|
+
get_request("/repositories/#{arguments.user}/#{arguments.repo}/pullrequests/#{arguments.pull_request_id}/diff")
|
190
182
|
end
|
191
183
|
|
192
184
|
# Get a log of all activity for a pull request
|
@@ -195,11 +187,13 @@ module BitBucket
|
|
195
187
|
# bitbucket = BitBucket.new
|
196
188
|
# bitbucket.repos.pull_requests.activity 'user-name', 'repo-name'
|
197
189
|
#
|
198
|
-
def activity(
|
199
|
-
|
200
|
-
|
190
|
+
def activity(*args)
|
191
|
+
arguments(args, required: [:user, :repo, :pull_request_id])
|
192
|
+
|
193
|
+
response = get_request("/repositories/#{arguments.user}/#{arguments.repo}/pullrequests/#{arguments.pull_request_id}/activity")
|
201
194
|
|
202
|
-
|
195
|
+
return response unless block_given?
|
196
|
+
response.each { |el| yield el }
|
203
197
|
end
|
204
198
|
end # Repos::PullRequests
|
205
199
|
end # BitBucket
|
@@ -32,6 +32,7 @@ module BitBucket
|
|
32
32
|
|
33
33
|
# The endpoint used to connect to BitBucket if none is set, in the event that BitBucket is ever available on location
|
34
34
|
property :endpoint, default: 'https://bitbucket.org/api/1.0'.freeze
|
35
|
+
property :endpoint_v2, default: 'https://api.bitbucket.org/2.0'.freeze
|
35
36
|
|
36
37
|
# The value sent in the http header for 'User-Agent' if none is set
|
37
38
|
property :user_agent, default: "BitBucket Ruby Gem #{BitBucket::VERSION::STRING}".freeze
|
@@ -11,11 +11,11 @@ module BitBucket
|
|
11
11
|
def self.default(options = {})
|
12
12
|
api = options[:api]
|
13
13
|
proc do |builder|
|
14
|
-
builder.use
|
14
|
+
builder.use BitBucket::Request::Jsonize
|
15
15
|
builder.use Faraday::Request::UrlEncoded
|
16
|
-
builder.use
|
16
|
+
builder.use Faraday::Request::Multipart
|
17
|
+
builder.use BitBucket::Request::OAuth, {:consumer_key => api.client_id, :consumer_secret => api.client_secret, :token => api.oauth_token, :token_secret => api.oauth_secret} if api.client_id? and api.client_secret?
|
17
18
|
builder.use BitBucket::Request::BasicAuth, api.authentication if api.basic_authed?
|
18
|
-
builder.use FaradayMiddleware::EncodeJson
|
19
19
|
|
20
20
|
builder.use Faraday::Response::Logger if ENV['DEBUG']
|
21
21
|
#builder.use BitBucket::Response::Helpers
|
@@ -1,5 +1,4 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
3
2
|
module BitBucket
|
4
3
|
|
5
4
|
# A module that decorates response with pagination helpers
|
@@ -7,7 +6,7 @@ module BitBucket
|
|
7
6
|
include BitBucket::Constants
|
8
7
|
|
9
8
|
def paginated?
|
10
|
-
body.is_a?(Hash) and body[PARAM_PAGE].nil?
|
9
|
+
body.is_a?(Hash) and !body[PARAM_PAGE].nil?
|
11
10
|
end
|
12
11
|
|
13
12
|
# Return page links
|
@@ -22,10 +21,10 @@ module BitBucket
|
|
22
21
|
# instances or just per given request.
|
23
22
|
#
|
24
23
|
def auto_paginate(auto=false)
|
25
|
-
if (current_api.auto_pagination? || auto)
|
24
|
+
if paginated? and (current_api.auto_pagination? || auto)
|
26
25
|
resources_bodies = []
|
27
26
|
each_page do |resource|
|
28
|
-
if resource.body.respond_to?(:values)
|
27
|
+
if resource.body.respond_to?(:values) and resource.body[:values]
|
29
28
|
resources_bodies += resource.body[:values].collect {|value| ::Hashie::Mash.new(value) }
|
30
29
|
else
|
31
30
|
resources_bodies += Array(resource.body)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reenhanced_bitbucket_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Cochran
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-03-
|
12
|
+
date: 2015-03-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hashie
|
@@ -158,7 +158,6 @@ files:
|
|
158
158
|
- lib/bitbucket_rest_api/client/repos/following.rb
|
159
159
|
- lib/bitbucket_rest_api/client/repos/keys.rb
|
160
160
|
- lib/bitbucket_rest_api/client/repos/pull_requests.rb
|
161
|
-
- lib/bitbucket_rest_api/client/repos/pull_requests/activity.rb
|
162
161
|
- lib/bitbucket_rest_api/client/repos/pull_requests/comments.rb
|
163
162
|
- lib/bitbucket_rest_api/client/repos/pull_requests/commits.rb
|
164
163
|
- lib/bitbucket_rest_api/client/repos/services.rb
|
@@ -239,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
239
238
|
version: '0'
|
240
239
|
requirements: []
|
241
240
|
rubyforge_project:
|
242
|
-
rubygems_version: 2.4.
|
241
|
+
rubygems_version: 2.4.6
|
243
242
|
signing_key:
|
244
243
|
specification_version: 4
|
245
244
|
summary: Ruby wrapper for the BitBucket API supporting OAuth and Basic Authentication
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module BitBucket
|
4
|
-
class Client::Repos::PullRequests::Activity < API
|
5
|
-
@version = '2.0'
|
6
|
-
|
7
|
-
# Get the activity for a pull request
|
8
|
-
#
|
9
|
-
# = Examples
|
10
|
-
# bitbucket = BitBucket.new
|
11
|
-
# bitbucket.repos.pull_requests.activity 'user-name', 'repo-name', 'pull-request-id'
|
12
|
-
#
|
13
|
-
def list(user_name, repo_name, pull_request_id)
|
14
|
-
_update_user_repo_params(user_name, repo_name)
|
15
|
-
_validate_user_repo_params(user, repo) unless user? && repo?
|
16
|
-
_validate_presence_of pull_request_id
|
17
|
-
|
18
|
-
get_request("/repositories/#{user}/#{repo}/pullrequests/#{pull_request_id}/activity")
|
19
|
-
end
|
20
|
-
alias :all :list
|
21
|
-
end
|
22
|
-
end
|