stash-api 1.1.23.0 → 1.1.24.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +8 -8
  2. data/lib/stash-api/client.rb +14 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzgyY2I2NGFjZGFiY2M4NTExYjBjOGY2ODc3ZDMyODk0ZDllMTgyYw==
4
+ ZTdmYWQyNDMzNmUyYmU0ZmQzYTRjNDljNWQ4MWMwY2I0YTIyZjgyNw==
5
5
  data.tar.gz: !binary |-
6
- ZWRhMGY4ZDIxYzliZWY5YTI2MTM3ODkzMjYzZjFkYzEyMzgxYWY5Mg==
6
+ M2UzNDQwNDQ1ZGU1OTA1NDZmNzk0NjcyNTUwYmRkNWJmYzM5OWZiYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NTU1ZTFhYjA0M2Q3ODM1ODhlYmMzYmJhNGI0NWQwNjE3OWFkYmJhOGRmNjkw
10
- MTYxNGMyMjE1MmYxMzljMDE1MTQwNzFjMjQzODk0Mjk2YmRkZWY0NGIyNjlj
11
- YzM5YmZkNDhkOWE4OWZmZjA3YzUyNjE4MzBlZDRhMTljNzZlNjA=
9
+ MjI0YTIyMzU1YzI5MTYyOGU1ZjY5ZDM4YTA2MTViNWEwYzIwYTA5NDQ2M2Jh
10
+ NTBiN2MyMmQ1ZDBhZjQ5YThiZWRkM2FhMTk2ZmY2Zjc4YzM5NWRiMzYyZjEz
11
+ ZjM2MjMyMTJjNjRjZTE1OGM0MWU3MzVmY2FmZmVlMGNjNjdlOTg=
12
12
  data.tar.gz: !binary |-
13
- ZTY4ZmU2NjY3Yjc3NTQ3YTBiNDYyMzBmZmFhMzMyMThmYTI5NzAyZWU5ZDg2
14
- ZGE0MjhhYzMzNjg0OTg0MzIyOWJiN2ViOTFiY2Q2ZjU2OGZiZGU5ODZjMGY1
15
- NmIzZWMyYzRmOGU3MGVlNTE4YzgwY2YzOTQ5MjFmZmQ5ZWFmNjM=
13
+ Yjk4YWM5NDc3ZjFlMDAxNjNjMTMwOGQ5OTMwYWJlNTNhOWM0NGVlNTdhYTZl
14
+ NTA4ZGE1ZTllZTA0ZjMzYThkNWRiZTg4MjYxYTQ3OTQ3MTRmYjAxMTkzYTQ4
15
+ YTgwM2M3NmExZjk5ZjFjZDIwMzAyMzI0ZmI1YWY5YmUwMmYyOTY=
@@ -3,7 +3,7 @@ require 'rest-client'
3
3
 
4
4
  module Stash
5
5
  class Client
6
- attr_accessor :server, :project, :repository_name
6
+ attr_accessor :server, :project, :repository_name, :ssh_url
7
7
 
8
8
  def initialize(username, password, config = {:follow_fork => true, :url => nil, :verify_ssl => true})
9
9
  raise 'API username must be specified' if !username
@@ -25,12 +25,24 @@ module Stash
25
25
  @branchring_model_url = File.join("https://#{@server}", 'rest', 'branch-utils', '1.0', 'projects', @project, 'repos', @repository_name)
26
26
  @pull_request_settings = File.join("https://#{@server}", 'rest', 'pullrequest-settings', '1.0', 'projects', @project, 'repos', @repository_name)
27
27
  json = RestClient::Resource.new(@remote_api_url, {:user => @username, :password => @password, :verify_ssl => config[:verify_ssl]}).get
28
- repository_information = JSON::pretty_generate(JSON.parse(json))
28
+
29
+ repository_information = nil
30
+ RestClient::Request.new(
31
+ :method => :get,
32
+ :url => URI::encode(@remote_api_url),
33
+ :user => @username,
34
+ :password => @password,
35
+ :headers => { :accept => :json, :content_type => :json }).execute do |response, request, result|
36
+ raise "Could not retrieve repository information - #{JSON::pretty_generate(JSON::parse(response.body))}" if !response.code.to_s.match(/^2\d{2}$/)
37
+ repository_information = JSON::pretty_generate(JSON.parse(json))
38
+ end
39
+ @ssh_url = repository_information['links']['clone'].select{|link| link['name'].match(/^ssh$/i)}.first['href']
29
40
 
30
41
  #If the repository is a fork, use it's forked source to get this information
31
42
  if repository_information['origin'] && config[:follow_fork]
32
43
  @project = repository_information['origin']['project']['key']
33
44
  @repository_name = repository_information['origin']['slug']
45
+ @ssh_url = repository_information['origin']['links']['clone'].select{|link| link['name'].match(/^ssh$/i)}.first['href']
34
46
  end
35
47
  end
36
48
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stash-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.23.0
4
+ version: 1.1.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Warren Parad
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-02 00:00:00.000000000 Z
11
+ date: 2015-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler