stash-api 1.1.28.0 → 1.1.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/lib/stash-api/client.rb +9 -14
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZmJkMGFkMDdkMjFiNjNmOTc2ZDkxOTY0MTJiMWNlZDI5YmY1MDEwMw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OThiYjFkYWI2OTE2ZjlmZDY0ZDMxYzVmNjZmYmNmMzI4NDk3YTAwNA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NGY2NmVlMzE0ZWZjYTZlMjQxN2Q0NTgwNzY4NmZhMjliNmI0ZTA2ZTQ2MTJl
|
10
|
+
NTdkMmZhMTMxNzUxM2E3YjE4YzViMmUwOGU2NGMyMzNhZTcyM2M5NTVlMDY1
|
11
|
+
NzA1Y2VhZjkwNTM1ZDk2ZGYxMTgwYjNhMWZmZGZkZGUyYjE2OTQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MTcxZjg4ZTc2ZDJhZjgwNjEzMDZkNTliMzIxNGJhODBjOWVlYTRkM2QxMmZh
|
14
|
+
MGZjMDVmMzY1YjhiZDViZDA3MGNhZTQ2NjYzNGE4NDgzNjg1YTUxODU3NDBm
|
15
|
+
MzJhYWIwOGNkNDQzZTg3ODU2MGMwYTg0NzRlOWFjODU1YTQxZWQ=
|
data/lib/stash-api/client.rb
CHANGED
@@ -16,14 +16,11 @@ module Stash
|
|
16
16
|
|
17
17
|
match = remote_origin_url.match(/(ssh|https?):\/\/([^@]*@)?(?<server>[^\:\/]*)[^\/]*\/(scm\/)?(?<project>[^\/].*)\/(?<repository_name>[^\/]*)\.git$/)
|
18
18
|
raise "Remote origin cannot be inferred from the url: #{remote_origin_url}. Run `git remote add origin URL` to add an origin." if !match
|
19
|
-
@server = match[:server]
|
20
|
-
@project = match[:project]
|
21
|
-
@repository_name = match[:repository_name]
|
22
19
|
|
23
|
-
@remote_api_url = File.join("https://#{
|
24
|
-
@branch_permissions_url = File.join("https://#{
|
25
|
-
@branchring_model_url = File.join("https://#{
|
26
|
-
@pull_request_settings = File.join("https://#{
|
20
|
+
@remote_api_url = File.join("https://#{match[:server]}", 'rest', 'api', '1.0', 'projects', match[:project], 'repos', match[:repository_name])
|
21
|
+
@branch_permissions_url = File.join("https://#{match[:server]}", 'rest', 'branch-permissions', '2.0', 'projects', match[:project], 'repos', match[:repository_name], 'restrictions')
|
22
|
+
@branchring_model_url = File.join("https://#{match[:server]}", 'rest', 'branch-utils', '1.0', 'projects', match[:project], 'repos', match[:repository_name])
|
23
|
+
@pull_request_settings = File.join("https://#{match[:server]}", 'rest', 'pullrequest-settings', '1.0', 'projects', match[:project], 'repos', match[:repository_name])
|
27
24
|
|
28
25
|
repository_information = nil
|
29
26
|
RestClient::Request.new(
|
@@ -35,14 +32,13 @@ module Stash
|
|
35
32
|
repository_information = JSON.parse(response.body)
|
36
33
|
raise "Could not retrieve repository information - #{JSON::pretty_generate(repository_information)}" if !response.code.to_s.match(/^2\d{2}$/)
|
37
34
|
end
|
38
|
-
@ssh_url = repository_information['links']['clone'].select{|link| link['name'].match(/^ssh$/i)}.first['href']
|
39
35
|
|
40
36
|
#If the repository is a fork, use it's forked source to get this information
|
41
|
-
if repository_information['origin'] && config[:follow_fork]
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
37
|
+
repository_information = repository_information['origin'] if repository_information['origin'] && config[:follow_fork]
|
38
|
+
puts JSON::pretty_generate(repository_information)
|
39
|
+
@project = repository_information['project']['key']
|
40
|
+
@repository_name = repository_information['slug']
|
41
|
+
@ssh_url = repository_information['links']['clone'].select{|link| link['name'].match(/^ssh$/i)}.first['href']
|
46
42
|
end
|
47
43
|
|
48
44
|
SETTINGS_HOOKS_URL = File.join('settings', 'hooks')
|
@@ -61,7 +57,6 @@ module Stash
|
|
61
57
|
raise "Could not configure hook: #{hook} - #{JSON::pretty_generate(JSON::parse(response.body))}" if !response.code.to_s.match(/^2\d{2}$/)
|
62
58
|
end
|
63
59
|
end
|
64
|
-
|
65
60
|
RestClient::Request.new(
|
66
61
|
:method => :put,
|
67
62
|
:url => URI::encode("#{File.join(@remote_api_url, SETTINGS_HOOKS_URL)}/#{hook}/enabled"),
|