vx-service_connector 0.2.9 → 0.2.10

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: 2b29bb50c4760278782ac338ebb324aa59b8b703
4
- data.tar.gz: 2d57da49c1545e966b01e4cbcf8f442d3d70a0b5
3
+ metadata.gz: 4fe7297908d5f6f62244ac09397f3ee2572ad017
4
+ data.tar.gz: 517726f7dfdd075141cb82e4b8c7883e4ddef0a6
5
5
  SHA512:
6
- metadata.gz: fdca12195da6fb696117464e28fd4694452c2cc7ca12f72f11471daf7412094f807cd7013137c19a25f07c6da976bd3e93372b32bfb7fd8c1605789cd01a37c5
7
- data.tar.gz: 67b699e32a94ea31093d8e75b54d20a4eefd9e187f642c19f14fe32758f38eeae4425fbe18b4c1b23ad97834bd5427e297f5ceadb6ff6399fa364aa4c9ec7c5e
6
+ metadata.gz: 5aac67c77fe3aac17f022ccaa6a34633bf5b59f8e7d018dafa40a312e2c16e89f06f13e68364221cfe4e4dbc76ce9fa70ad7ceccd7fb1b813751b2fa4323311b
7
+ data.tar.gz: 360693cf3463286d3989c36d6db6a511c663abb60cea3df138d91ed08808f08d64f61d1b1254b6a77e1230122827e1352d84e441bb9639bc1eceb8abca7ca3d7
@@ -6,12 +6,14 @@ module Vx
6
6
  Commits = Struct.new(:session, :repo) do
7
7
  def last(options = {})
8
8
  begin
9
- commit = session.commit(repo.full_name, 'HEAD')
9
+ project = session.repository(repo.full_name)
10
+ branch = project.default_branch || 'master'
11
+ commit = session.commit(repo.full_name, branch)
10
12
  Model::Payload.from_hash(
11
13
  skip: false,
12
14
  pull_request?: false,
13
- branch: 'HEAD',
14
- branch_label: 'HEAD',
15
+ branch: branch,
16
+ branch_label: branch,
15
17
  sha: commit.sha,
16
18
  message: commit.commit.message,
17
19
  author: commit.commit.author.name,
@@ -5,12 +5,14 @@ module Vx
5
5
 
6
6
  def last(options = {})
7
7
  begin
8
- commit = session.get "/projects/#{repo.id}/repository/commits/HEAD"
8
+ project = session.get "/projects/#{repo.id}"
9
+ branch = project.default_branch || "master"
10
+ commit = session.get "/projects/#{repo.id}/repository/commits/#{branch}"
9
11
  Model::Payload.from_hash(
10
12
  skip: false,
11
13
  pull_request?: false,
12
- branch: 'HEAD',
13
- branch_label: 'HEAD',
14
+ branch: branch,
15
+ branch_label: branch,
14
16
  sha: commit.id,
15
17
  message: commit.title,
16
18
  author: commit.author_name,
@@ -1,5 +1,5 @@
1
1
  module Vx
2
2
  module ServiceConnector
3
- VERSION = "0.2.9"
3
+ VERSION = "0.2.10"
4
4
  end
5
5
  end
@@ -0,0 +1,48 @@
1
+ {
2
+ "id": 1296269,
3
+ "owner": {
4
+ "login": "octocat",
5
+ "id": 1,
6
+ "avatar_url": "https://github.com/images/error/octocat_happy.gif",
7
+ "gravatar_id": "somehexcode",
8
+ "url": "https://api.github.com/users/octocat",
9
+ "html_url": "https://github.com/octocat",
10
+ "followers_url": "https://api.github.com/users/octocat/followers",
11
+ "following_url": "https://api.github.com/users/octocat/following{/other_user}",
12
+ "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
13
+ "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
14
+ "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
15
+ "organizations_url": "https://api.github.com/users/octocat/orgs",
16
+ "repos_url": "https://api.github.com/users/octocat/repos",
17
+ "events_url": "https://api.github.com/users/octocat/events{/privacy}",
18
+ "received_events_url": "https://api.github.com/users/octocat/received_events",
19
+ "type": "User",
20
+ "site_admin": false
21
+ },
22
+ "name": "Hello-World",
23
+ "full_name": "octocat/user",
24
+ "description": "This your first repo!",
25
+ "private": false,
26
+ "fork": true,
27
+ "url": "https://api.github.com/repos/octocat/Hello-World",
28
+ "html_url": "https://github.com/octocat/Hello-World",
29
+ "clone_url": "https://github.com/octocat/Hello-World.git",
30
+ "git_url": "git://github.com/octocat/Hello-World.git",
31
+ "ssh_url": "git@github.com:octocat/Hello-World.git",
32
+ "svn_url": "https://svn.github.com/octocat/Hello-World",
33
+ "mirror_url": "git://git.example.com/octocat/Hello-World",
34
+ "homepage": "https://github.com",
35
+ "language": null,
36
+ "forks_count": 9,
37
+ "stargazers_count": 80,
38
+ "watchers_count": 80,
39
+ "size": 108,
40
+ "default_branch": "master",
41
+ "master_branch": "master",
42
+ "open_issues_count": 0,
43
+ "pushed_at": "2011-01-26T19:06:43Z",
44
+ "created_at": "2011-01-26T19:01:12Z",
45
+ "updated_at": "2011-01-26T19:14:43Z",
46
+ "permissions": { "admin": true, "push": true, "pull": true}
47
+ }
48
+
@@ -17,14 +17,15 @@ describe Vx::ServiceConnector::Github do
17
17
  let(:commits) { github.commits(repo) }
18
18
 
19
19
  it "should return payload for last commit" do
20
- mock_get_commit repo.full_name, 'HEAD'
20
+ mock_repo
21
+ mock_get_commit repo.full_name, 'master'
21
22
  c = commits.last
22
23
  expect(c).to be
23
24
  expect(c.message).to eq "Fix all the bugs"
24
25
  expect(c.skip).to be_false
25
26
  expect(c.pull_request?).to be_false
26
- expect(c.branch).to eq 'HEAD'
27
- expect(c.branch_label).to eq 'HEAD'
27
+ expect(c.branch).to eq 'master'
28
+ expect(c.branch_label).to eq 'master'
28
29
  expect(c.sha).to eq '6dcb09b5b57875f334f61aebed695e2e4193db5e'
29
30
  expect(c.author).to eq "Monalisa Octocat"
30
31
  expect(c.author_email).to eq "support@github.com"
@@ -21,14 +21,15 @@ require 'spec_helper'
21
21
  let(:commits) { gitlab.commits(repo) }
22
22
 
23
23
  it "should return payload for last commit" do
24
- mock_get_commit repo.id, 'HEAD'
24
+ mock_repo
25
+ mock_get_commit repo.id, 'master'
25
26
  c = commits.last
26
27
  expect(c).to be
27
28
  expect(c.message).to eq "Replace sanitize with escape once"
28
29
  expect(c.skip).to be_false
29
30
  expect(c.pull_request?).to be_false
30
- expect(c.branch).to eq 'HEAD'
31
- expect(c.branch_label).to eq 'HEAD'
31
+ expect(c.branch).to eq 'master'
32
+ expect(c.branch_label).to eq 'master'
32
33
  expect(c.sha).to eq '2dd0fdf94c7d0a74921e178b3b5229e60ce5d03e'
33
34
  expect(c.author).to eq "Dmitriy Zaporozhets"
34
35
  expect(c.author_email).to eq "dzaporozhets@sphereconsultinginc.com"
data/spec/spec_helper.rb CHANGED
@@ -18,7 +18,7 @@ ActiveSupport::Notifications.subscribe "request.faraday" do |name, started, fini
18
18
  method: payload[:method],
19
19
  url: payload[:url].to_s,
20
20
  status: payload[:status],
21
- response_headers: payload[:response_headers].map{|k,v| "#{k}: #{v}" }.join("\n"),
21
+ response_headers: (payload[:response_headers] || []).map{|k,v| "#{k}: #{v}" }.join("\n"),
22
22
  request_headers: payload[:request_headers].map{|k,v| "#{k}: #{v}" }.join("\n")
23
23
  }
24
24
  pp env
@@ -48,6 +48,10 @@ module GithubWebMocks
48
48
  mock_get "https://api.github.com/user/repos?per_page=100", "user_repos"
49
49
  end
50
50
 
51
+ def mock_repo
52
+ mock_get "https://api.github.com/repos/full/name", "user_repo"
53
+ end
54
+
51
55
  def mock_org_repos
52
56
  mock_get "https://api.github.com/orgs/github/repos?per_page=100", "org_repos"
53
57
  end
@@ -4,6 +4,10 @@ module GitlabWebMocks
4
4
  mock_get "projects?per_page=30", 'projects'
5
5
  end
6
6
 
7
+ def mock_repo
8
+ mock_get "projects/1", 'project'
9
+ end
10
+
7
11
  def mock_deploy_keys
8
12
  mock_get "projects/1/keys", 'deploy_keys'
9
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vx-service_connector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Galinsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-09 00:00:00.000000000 Z
11
+ date: 2014-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit
@@ -158,6 +158,7 @@ files:
158
158
  - spec/fixtures/github/payload/pull_request.json
159
159
  - spec/fixtures/github/payload/push.json
160
160
  - spec/fixtures/github/payload/push_tag.json
161
+ - spec/fixtures/github/user_repo.json
161
162
  - spec/fixtures/github/user_repos.json
162
163
  - spec/fixtures/gitlab_v6/branch.json
163
164
  - spec/fixtures/gitlab_v6/commit.json
@@ -226,6 +227,7 @@ test_files:
226
227
  - spec/fixtures/github/payload/pull_request.json
227
228
  - spec/fixtures/github/payload/push.json
228
229
  - spec/fixtures/github/payload/push_tag.json
230
+ - spec/fixtures/github/user_repo.json
229
231
  - spec/fixtures/github/user_repos.json
230
232
  - spec/fixtures/gitlab_v6/branch.json
231
233
  - spec/fixtures/gitlab_v6/commit.json