stash_core_api 0.1.5 → 0.1.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 92dde081a8989016a1f691b15c6583a5dcf7e53c
4
- data.tar.gz: 7176dcc1f42ead488c88c3a14742d027c03ae396
2
+ SHA256:
3
+ metadata.gz: eefa96b5608f5e886bec64e6bbecad120094e799c74c9e8c324ed58314174836
4
+ data.tar.gz: 729a6906231d22ccefbd8b7573eb64e8a08a7c08a7f2d20198bcb9c667813b08
5
5
  SHA512:
6
- metadata.gz: 19106b18a6ff58aee5af85949b7ec5ad4ff58bf82b5147060e61d2b6519d80c4aff2c247b5f7338e939104787f124e93c18b762812d76bb841b7af7983b88629
7
- data.tar.gz: d119a2e94eceb9c28c806d8a4510b4079d6ee913bff34b29e3e445e5b519491a8e373fbc9192314329db334bdbecd935fcce85b342125865e9c10cfe416a4312
6
+ metadata.gz: b0c1cff131d164f24fb2e5b863385f1862e329cdac4f06ce89e5f80f3dcf23c879b1d75777c3869fc05048c622f42af34fb26f7ed582953b3ae48fa2ab2d557d
7
+ data.tar.gz: 2effd106f6e9b8ea1623f524568d6f77dffa18b1af8756140f58a0774e6c54b97ffa9377965b6f6c075979169761917d81e9ca944d6f283ebccff78d807139b0
@@ -1,5 +1,6 @@
1
1
  require 'stash_core_api/commits'
2
2
  require 'stash_core_api/pull_requests'
3
+ require 'stash_core_api/compare'
3
4
 
4
5
  module StashCoreAPI
5
6
  # All methods have been separated into modules and
@@ -7,4 +8,5 @@ module StashCoreAPI
7
8
  # https://developer.atlassian.com/static/rest/stash/3.9.2/stash-rest.html.
8
9
  include StashCoreAPI::Commits
9
10
  include StashCoreAPI::PullRequests
11
+ include StashCoreAPI::Compare
10
12
  end
@@ -30,5 +30,15 @@ module StashCoreAPI
30
30
  end
31
31
  perform_get(endpoint)
32
32
  end
33
+
34
+ # @see https://docs.atlassian.com/DAC/rest/stash/3.9.2/stash-rest.html#idp1729008
35
+ #
36
+ # @param limit [Integer] the maximum number of commits to return
37
+ # Stash defaults to 25
38
+ def commit_changes(commit_id, limit: nil)
39
+ endpoint = "/commits/#{commit_id}/changes"
40
+ endpoint = "#{endpoint}?limit=#{limit}" if limit
41
+ perform_get(endpoint)
42
+ end
33
43
  end
34
44
  end
@@ -0,0 +1,29 @@
1
+ require 'stash_core_api/utils'
2
+
3
+ module StashCoreAPI
4
+ # Interfaces with compare endpoints of Stash CoreAPI API
5
+ module Compare
6
+ include StashCoreAPI::Utils
7
+
8
+ # @see https://docs.atlassian.com/DAC/rest/stash/3.9.2/stash-rest.html#idp3045184
9
+ #
10
+ # @param from [String] the source commit (can be a partial/full changeset
11
+ # id or qualified/unqualified ref name)
12
+ # @param to [String] the target commit (can be a partial/full changeset
13
+ # id or qualified/unqualified ref name)
14
+ # @param fromRepo [String] an optional parameter specifying the source
15
+ # repository containing the source changeset if that changeset is not
16
+ # present in the current repository; the repository can be specified
17
+ # by either its ID fromRepo=42 or by its project key plus its repo slug
18
+ # separated by a slash: fromRepo=projectKey/repoSlug
19
+ # @param limit [Integer] the maximum number of commits to return
20
+ # Stash defaults to 25
21
+ def compare_changes(from_commit, to_commit, from_repo: nil, limit: nil)
22
+ endpoint = "/compare/changes?from=#{from_commit}&to=#{to_commit}"
23
+ endpoint = "#{endpoint}&fromRepo=#{from_repo}" if from_repo
24
+ endpoint = "#{endpoint}&limit=#{limit}" if limit
25
+ perform_get(endpoint)
26
+ end
27
+ end
28
+ end
29
+
@@ -2,5 +2,5 @@
2
2
 
3
3
  # StashCoreAPI module
4
4
  module StashCoreAPI
5
- VERSION = '0.1.5'
5
+ VERSION = '0.1.6'
6
6
  end
@@ -0,0 +1,2 @@
1
+ {"errors":[{"context":null,"message":"Commit \"083f66ba3c6\" does not exist in this repository","exceptionName":"com.atlassian.bitbucket.NoSuchObjectException"}]}
2
+
@@ -0,0 +1 @@
1
+ {"errors":[{"context":null,"message":"Object \"c\" does not exist in this repository","exceptionName":"com.atlassian.bitbucket.NoSuchObjectException"}]}
@@ -59,4 +59,24 @@ RSpec.describe StashCoreAPI::Client do
59
59
  end
60
60
  end
61
61
  end
62
+
63
+ describe '#commit_changes' do
64
+ it 'should hit the approprate stash api with the given options' do
65
+ endpoint = "/commits/083f66ba3c6/changes?limit=1"
66
+ expect(client).to receive(:perform_get).with(endpoint)
67
+ client.commit_changes('083f66ba3c6', limit: 1)
68
+ end
69
+
70
+ it 'should raise an error when the commit is not valid' do
71
+ endpoint = "/#{base_path(client)}/commits/083f66ba3c6/changes"
72
+ stub_get(client, endpoint).to_return(
73
+ status: 404,
74
+ body: fixture('commit_changes_bad_sha.json'),
75
+ headers: { 'Content-Type' => 'application/json' }
76
+ )
77
+ expect { client.commit_changes('083f66ba3c6') }.to raise_error(
78
+ StashCoreAPI::Error::NotFound, 'Commit "083f66ba3c6" does not exist in this repository'
79
+ )
80
+ end
81
+ end
62
82
  end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe StashCoreAPI::Client do
4
+ let(:client) do
5
+ StashCoreAPI::Client.new(
6
+ user: 'user',
7
+ pass: 'pass',
8
+ project: 'project',
9
+ repository: 'repository',
10
+ stash_url: 'https://stash.com',
11
+ )
12
+ end
13
+
14
+ describe '#compare' do
15
+ describe '#changes' do
16
+ it 'should hit the approprate stash api with the given options' do
17
+ endpoint = "/compare/changes?from=a&to=b&fromRepo=c&limit=1"
18
+ expect(client).to receive(:perform_get).with(endpoint)
19
+ changes = client.compare_changes('a', 'b', from_repo: 'c', limit: 1)
20
+ end
21
+
22
+ it 'should raise an error when the range is not valid' do
23
+ endpoint = "/#{base_path(client)}/compare/changes?from=c&to=d"
24
+ stub_get(client, endpoint).to_return(
25
+ status: 404,
26
+ body: fixture('compare_changes_bad_range.json'),
27
+ headers: { 'Content-Type' => 'application/json' }
28
+ )
29
+ expect { client.compare_changes('c', 'd') }.to raise_error(
30
+ StashCoreAPI::Error::NotFound, 'Object "c" does not exist in this repository'
31
+ )
32
+ end
33
+ end
34
+ end
35
+ end
36
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stash_core_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alyssa Pohahau
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-11 00:00:00.000000000 Z
11
+ date: 2019-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -113,6 +113,7 @@ files:
113
113
  - lib/stash_core_api/api.rb
114
114
  - lib/stash_core_api/client.rb
115
115
  - lib/stash_core_api/commits.rb
116
+ - lib/stash_core_api/compare.rb
116
117
  - lib/stash_core_api/error.rb
117
118
  - lib/stash_core_api/pull_requests.rb
118
119
  - lib/stash_core_api/request.rb
@@ -120,14 +121,17 @@ files:
120
121
  - lib/stash_core_api/version.rb
121
122
  - spec/fixtures/can_merge.json
122
123
  - spec/fixtures/cannot_merge.json
124
+ - spec/fixtures/commit_changes_bad_sha.json
123
125
  - spec/fixtures/commits.json
124
126
  - spec/fixtures/commits_with_limit.json
125
127
  - spec/fixtures/commits_with_with_count.json
128
+ - spec/fixtures/compare_changes_bad_range.json
126
129
  - spec/fixtures/info.json
127
130
  - spec/fixtures/unauthorized_error.json
128
131
  - spec/spec_helper.rb
129
132
  - spec/stash_core_api/client_spec.rb
130
133
  - spec/stash_core_api/commits_spec.rb
134
+ - spec/stash_core_api/compare_spec.rb
131
135
  - spec/stash_core_api/error_spec.rb
132
136
  - spec/stash_core_api/pull_requests_spec.rb
133
137
  - spec/stash_core_api/request_spec.rb
@@ -152,22 +156,24 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
156
  - !ruby/object:Gem::Version
153
157
  version: '0'
154
158
  requirements: []
155
- rubyforge_project:
156
- rubygems_version: 2.6.12
159
+ rubygems_version: 3.0.3
157
160
  signing_key:
158
161
  specification_version: 4
159
162
  summary: Atlassian Stash Core REST API Client
160
163
  test_files:
161
164
  - spec/fixtures/can_merge.json
162
165
  - spec/fixtures/cannot_merge.json
166
+ - spec/fixtures/commit_changes_bad_sha.json
163
167
  - spec/fixtures/commits.json
164
168
  - spec/fixtures/commits_with_limit.json
165
169
  - spec/fixtures/commits_with_with_count.json
170
+ - spec/fixtures/compare_changes_bad_range.json
166
171
  - spec/fixtures/info.json
167
172
  - spec/fixtures/unauthorized_error.json
168
173
  - spec/spec_helper.rb
169
174
  - spec/stash_core_api/client_spec.rb
170
175
  - spec/stash_core_api/commits_spec.rb
176
+ - spec/stash_core_api/compare_spec.rb
171
177
  - spec/stash_core_api/error_spec.rb
172
178
  - spec/stash_core_api/pull_requests_spec.rb
173
179
  - spec/stash_core_api/request_spec.rb