git-semaphore 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13b7eef8a26a58b07b06925868300f1697cb6951
4
- data.tar.gz: 89d801f35cc42f2bb01885452dce1cddd1b8df2b
3
+ metadata.gz: d7e775e83a005ec30c5625d2857223a42cb1186c
4
+ data.tar.gz: a5007fe61d02498243beb875dcc482c93f4b3dea
5
5
  SHA512:
6
- metadata.gz: f7215ee3c9d64ef9257209420d97d38e124019e2722fdad8ecb54c1841c3be2881f33fe7cfada5c0de770cb2548181456c54895e6a3fed9c905c57906307a160
7
- data.tar.gz: 4f42b187ead55bd9615d15baaa1c84c64626c52438fbedabcce99cc9e70e524739354665b8c4ef17b24cb5ef0dc27dc844fc98c9593e1dfd688f9b38cf8a3e31
6
+ metadata.gz: 21e1cf278b62a570c112c69163866e90e1629a140b3f47e6ac4be25f0c7b4b3e57664f00b43a792be1279b17c0b4abe135a48818ddc809fbbe447ae8eee41871
7
+ data.tar.gz: ecf9201131e0e8e82709a830fa0e2835043e6a61511d15d8866c89d5dabc0bfc0b3a78f604b4cdd3c84d54cda821bffb9e35a06f98b35c7339098d682834bb38
data/bin/git-semaphore CHANGED
@@ -18,6 +18,7 @@ options = Trollop::options do
18
18
  opt :branches, 'List all semaphore.app branches for current project', :short => nil, :default => false
19
19
  opt :status, 'List the semaphore.app status for the given branch', :short => nil, :default => false
20
20
  opt :'commit-status', 'Check commit status', :default => false
21
+ opt :'rebuild-last-revision', 'Rebuild last revision', :default => false
21
22
 
22
23
  opt :'working-dir', 'Print working dir', :short => 'w', :default => false
23
24
  opt :'project-name', 'Print project name', :short => 'p', :default => false
@@ -42,6 +43,11 @@ if !app.validate
42
43
  end
43
44
  end
44
45
 
46
+ if options[:'rebuild-last-revision']
47
+ puts app.rebuild_last_revision
48
+ exit 0
49
+ end
50
+
45
51
  if options[:'commit-status']
46
52
  puts app.commit_status
47
53
  exit 0
@@ -0,0 +1,55 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://semaphoreapp.com/api/v1/projects/649e584dc507ca4b73e1374d3125ef0b567a949c/89/build?auth_token=Yds3w6o26FLfJTnVK2y9
6
+ body:
7
+ encoding: UTF-8
8
+ string: auth_token=Yds3w6o26FLfJTnVK2y9
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - '*/*'
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Content-Type:
22
+ - application/json; charset=utf-8
23
+ Transfer-Encoding:
24
+ - chunked
25
+ Connection:
26
+ - keep-alive
27
+ Status:
28
+ - '200'
29
+ X-Powered-By:
30
+ - Phusion Passenger (mod_rails/mod_rack) 3.0.14
31
+ Strict-Transport-Security:
32
+ - max-age=31536000
33
+ X-Ua-Compatible:
34
+ - IE=Edge,chrome=1
35
+ Cache-Control:
36
+ - no-cache
37
+ Set-Cookie:
38
+ - _semaphoreappdotcom_session=BAh7BkkiD3Nlc3Npb25faWQGOgZFRkkiJTM4NGFhMzNmMzBlMWYwZWNjZGY1YTVmOTZmM2EwZGM5BjsAVA%3D%3D--221d375194d03282702a20d5dd5be5520e5eccca;
39
+ path=/; secure; HttpOnly
40
+ X-Request-Id:
41
+ - 7ca89a2918f9ed99308b0969f52d04b8
42
+ X-Runtime:
43
+ - '0.005673'
44
+ Date:
45
+ - Thu, 18 Dec 2014 09:38:06 GMT
46
+ X-Rack-Cache:
47
+ - invalidate, pass
48
+ Server:
49
+ - nginx/1.2.2 + Phusion Passenger 3.0.14 (mod_rails/mod_rack)
50
+ body:
51
+ encoding: UTF-8
52
+ string: ! '{"commits":[{"id":"dummy_commit","url":"https://github.com/company/dummy_project/commit/dummy_commit","author_name":"Dude","author_email":"dude@company.co.uk","message":"Spiky spike","timestamp":"2014-07-23T09:52:55Z"},{"id":"foobar","url":"https://github.com/company/dummy_project/commit/foobar","author_name":"Dude","author_email":"dude@company.co.uk","message":"Merge branch \"master\" into dumy-branch","timestamp":"2014-07-25T15:33:05Z"},{"id":"dummy_commit4","url":"https://github.com/company/dummy_project/commit/dummy_commit4","author_name":"Dude","author_email":"dude@company.co.uk","message":"Move letter-opener to production gem","timestamp":"2014-07-28T07:32:28Z"},{"id":"dummy_commit2","url":"https://github.com/company/dummy_project/commit/dummy_commit2","author_name":"Dude","author_email":"dude@company.co.uk","message":"Merge branch \"master\" into dumy-branch","timestamp":"2014-07-30T07:25:37Z"},{"id":"dummy_commit3","url":"https://github.com/company/dummy_project/commit/dummy_commit3","author_name":"Dude","author_email":"dude@company.co.uk","message":"Merge branch \"master\" into dumy-branch","timestamp":"2014-08-04T10:08:26Z"},{"id":"dummy_commit5","url":"https://github.com/company/dummy_project/commit/dummy_commit5","author_name":"Dude","author_email":"dude@company.co.uk","message":"Merge branch \"master\" into dumy-branch\n\nConflicts:\n\tGemfile","timestamp":"2014-12-18T09:05:53Z"}],"project_name":"dummy_project","branch_name":"dumy-branch","number":4,"result":null,"created_at":"2014-12-18T09:44:11Z","updated_at":"2014-12-18T09:44:11Z","started_at":null,"finished_at":null,"html_url":"https://semaphoreapp.com/company/dummy_project/branches/dumy-branch/builds/4","build_log_url":"https://semaphoreapp.com/api/v1/projects/dummy_project/313010/builds/4/log?auth_token=Yds3w6o26FLfJTnVK2y9","build_info_url":"https://semaphoreapp.com/api/v1/projects/dummy_project/313010/builds/4?auth_token=Yds3w6o26FLfJTnVK2y9"}'
53
+ http_version:
54
+ recorded_at: Thu, 18 Dec 2014 09:38:06 GMT
55
+ recorded_with: VCR 2.9.3
@@ -71,6 +71,6 @@ http_interactions:
71
71
  "timestamp": "2012-07-04T18:14:08Z"
72
72
  }
73
73
  }'
74
- http_version:
74
+ http_version:
75
75
  recorded_at: Sat, 20 Oct 2012 12:15:25 GMT
76
76
  recorded_with: VCR 2.2.5
@@ -8,19 +8,21 @@ Feature: Help Me I've Got Versionitis
8
8
  And the banner should include the version
9
9
  And the banner should document that this app takes options
10
10
  And the following options should be documented:
11
- | --version, -v: |
12
- | --help, -h: |
13
- | --working-dir, -w: |
14
- | --project-name, -p: |
15
- | --branch-name, -b: |
16
- | --check-auth, -x: |
17
- | --check-project, -y: |
18
- | --check-branch, -z: |
19
- | --env-config, -e: |
20
- | --git-config, -g: |
21
- | --projects, -r: |
22
- | --branches, -a: |
23
- | --status, -s: |
11
+ | --version, -v: |
12
+ | --help, -h: |
13
+ | --working-dir, -w: |
14
+ | --project-name, -p: |
15
+ | --branch-name, -b: |
16
+ | --check-auth, -x: |
17
+ | --check-project, -y: |
18
+ | --check-branch, -z: |
19
+ | --env-config, -e: |
20
+ | --git-config, -g: |
21
+ | --projects, -r: |
22
+ | --branches, -a: |
23
+ | --status, -s: |
24
+ | --commit-status, -c: |
25
+ | --rebuild-last-revision, -u: |
24
26
 
25
27
  Scenario: get the version of the main script
26
28
 
@@ -20,3 +20,10 @@ Feature: Show Me What You've Got
20
20
  Given I am an authenticated user on semaphoreapp.com
21
21
  And get the build status of one of the branches for one of my projects via their API
22
22
  Then the JSON should be a hash
23
+
24
+ @vcr_api_rebuild_last_revision
25
+ Scenario: Rebuild last revision
26
+
27
+ Given I am an authenticated user on semaphoreapp.com
28
+ And request to rebuild the last revision of one of the branches for one of my projects via their API
29
+ Then the JSON should be a hash
@@ -16,6 +16,10 @@ Given /^get the build status of one of the branches for one of my projects via t
16
16
  @response = Git::Semaphore::Api.get_response Git::Semaphore::Api.status_uri(@project, @branch, @auth_token)
17
17
  end
18
18
 
19
+ Given /^request to rebuild the last revision of one of the branches for one of my projects via their API$/ do
20
+ @response = Git::Semaphore::Api.get_response Git::Semaphore::Api.last_revision_uri(@project, @branch, @auth_token), :post
21
+ end
22
+
19
23
  def last_json
20
24
  @response.body
21
25
  end
@@ -10,4 +10,5 @@ VCR.cucumber_tags do |t|
10
10
  t.tag '@vcr_api_projects'
11
11
  t.tag '@vcr_api_branches'
12
12
  t.tag '@vcr_api_status'
13
+ t.tag '@vcr_api_rebuild_last_revision'
13
14
  end
@@ -11,45 +11,49 @@ module Git
11
11
  SEMAPHORE_API_URI = '/api/v1'
12
12
 
13
13
  def self.projects_uri auth_token
14
- URI::HTTPS.build(
15
- :host => SEMAPHORE_API_HOST,
16
- :path => File.join(SEMAPHORE_API_URI, 'projects'),
17
- :query => "auth_token=#{auth_token}"
18
- )
14
+ request_uri(auth_token, :path => File.join(SEMAPHORE_API_URI, 'projects'))
19
15
  end
20
16
 
21
17
  def self.branches_uri project_hash_id, auth_token
22
- URI::HTTPS.build(
23
- :host => SEMAPHORE_API_HOST,
24
- :path => File.join(SEMAPHORE_API_URI, 'projects', project_hash_id, 'branches'),
25
- :query => "auth_token=#{auth_token}"
26
- )
18
+ request_uri(auth_token, :path => File.join(SEMAPHORE_API_URI, 'projects', project_hash_id, 'branches'))
27
19
  end
28
20
 
29
21
  def self.status_uri project_hash_id, branch_id, auth_token
30
- URI::HTTPS.build(
31
- :host => SEMAPHORE_API_HOST,
32
- :path => File.join(SEMAPHORE_API_URI, 'projects', project_hash_id, branch_id, 'status'),
33
- :query => "auth_token=#{auth_token}"
34
- )
22
+ request_uri(auth_token, :path => File.join(SEMAPHORE_API_URI, 'projects', project_hash_id, branch_id, 'status'))
35
23
  end
36
24
 
37
25
  def self.history_uri project_hash_id, branch_id, auth_token
38
- URI::HTTPS.build(
39
- :host => SEMAPHORE_API_HOST,
40
- :path => File.join(SEMAPHORE_API_URI, 'projects', project_hash_id, branch_id),
41
- :query => "auth_token=#{auth_token}"
42
- )
26
+ request_uri(auth_token, :path => File.join(SEMAPHORE_API_URI, 'projects', project_hash_id, branch_id))
27
+ end
28
+
29
+ def self.last_revision_uri project_hash_id, branch_id, auth_token
30
+ request_uri(auth_token, :path => File.join(SEMAPHORE_API_URI, 'projects', project_hash_id, branch_id, 'build'))
43
31
  end
44
32
 
45
33
  # helper functions
46
34
 
47
- def self.get_response uri
35
+ def self.get_response uri, action=:get
48
36
  ::Net::HTTP.start(uri.host, uri.port, :use_ssl => (uri.scheme == 'https'), :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |net_http|
49
- net_http.get(uri.request_uri)
37
+ case action
38
+ when :get
39
+ net_http.get uri.request_uri
40
+ when :post
41
+ net_http.post uri.request_uri, uri.query
42
+ else
43
+ raise 'Unsupported action'
44
+ end
50
45
  end
51
46
  end
52
47
 
48
+ def self.request_uri auth_token, options={}
49
+ URI::HTTPS.build(
50
+ { :host => SEMAPHORE_API_HOST,
51
+ :query => "auth_token=#{auth_token}"
52
+ }.merge(options)
53
+ )
54
+ end
55
+ private_class_method(:request_uri)
56
+
53
57
  end
54
58
  end
55
59
  end
@@ -85,6 +85,11 @@ class Git::Semaphore::App
85
85
  build = builds.detect { |b| b['commit']['id'] == commit }
86
86
  end
87
87
 
88
+ def rebuild_last_revision
89
+ uri = Git::Semaphore::Api.last_revision_uri(project_hash_id, branch_id, auth_token)
90
+ Git::Semaphore::Api.get_response(uri, :post).body
91
+ end
92
+
88
93
  private
89
94
 
90
95
  def project_hash_for project_name
@@ -1,5 +1,5 @@
1
1
  module Git
2
2
  module Semaphore
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-semaphore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Vandenberk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-16 00:00:00.000000000 Z
11
+ date: 2014-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: grit
@@ -298,6 +298,7 @@ files:
298
298
  - features/cassettes/cucumber_tags/api_projects.json
299
299
  - features/cassettes/cucumber_tags/vcr_api_branches.yml
300
300
  - features/cassettes/cucumber_tags/vcr_api_projects.yml
301
+ - features/cassettes/cucumber_tags/vcr_api_rebuild_last_revision.yml
301
302
  - features/cassettes/cucumber_tags/vcr_api_status.yml
302
303
  - features/coming_soon.feature
303
304
  - features/env_config.feature
@@ -350,6 +351,7 @@ test_files:
350
351
  - features/cassettes/cucumber_tags/api_projects.json
351
352
  - features/cassettes/cucumber_tags/vcr_api_branches.yml
352
353
  - features/cassettes/cucumber_tags/vcr_api_projects.yml
354
+ - features/cassettes/cucumber_tags/vcr_api_rebuild_last_revision.yml
353
355
  - features/cassettes/cucumber_tags/vcr_api_status.yml
354
356
  - features/coming_soon.feature
355
357
  - features/env_config.feature