magnum-payload 0.5.0 → 0.6.0

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: 185e19da5e951d271a1474cfadcab726a57e0370
4
- data.tar.gz: 1cced0a213ba0e6c07e878bcef747b9d0794e654
3
+ metadata.gz: d2c1a54e2979c17350a1c0c3f410c5fe0bd28ba3
4
+ data.tar.gz: 0b832f9769b72e3caa76aa1710a48e7027e8afd9
5
5
  SHA512:
6
- metadata.gz: 6f967feb19ea407b6f35e8fb4cf5c543532dfaed69f4dd909bdd1fdad1305f6750330d7041d3a8bbcc8b1356f88858787cbb6ce63a6cc2435561f79f94da2747
7
- data.tar.gz: 6616c61e359656c503b2d94c01680968f4c9af4003b9a920f8db06fa4f40ab47699a737147fb240bb33f8f91173a98ea5fc833213a9aa467ea2fbc3197b52868
6
+ metadata.gz: 14d63b4d65cad27467d15db6d237e2f1ea99d1751c403de4bbe355a2f369bb15c2bb06c0fcee53e0a2118ca0f362ab7580330af32b465052cac35bafff2c65b7
7
+ data.tar.gz: a7f0a458b2f1fbfb3e93a5d5b79a638e1e63774dd5ec557bc204c34ac577030470ddf45d9424f357001ba5614813b3852990ca1a57f92794a1ac54bfd0cc6b09
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2013-2014 Magnum CI
3
+ Copyright (c) 2013-2015 Magnum CI
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
data/README.md CHANGED
@@ -103,4 +103,4 @@ rake test
103
103
 
104
104
  The MIT License (MIT)
105
105
 
106
- Copyright (c) 2013-2014 Magnum CI
106
+ Copyright (c) 2013-2015 Magnum CI
@@ -1,6 +1,10 @@
1
1
  module Magnum
2
2
  class Payload::Bitbucket < Payload::Base
3
3
  def parse!
4
+ if data.push && data.push.changes
5
+ return parse_new_payload
6
+ end
7
+
4
8
  if data.commits.nil? || data.commits.empty?
5
9
  raise Magnum::Payload::PayloadError, "Payload has no commits"
6
10
  end
@@ -53,5 +57,22 @@ module Magnum
53
57
  rev_end = revision
54
58
  @compare_url = make_url("compare/#{rev_start}..#{rev_end}")
55
59
  end
60
+
61
+ def parse_new_payload
62
+ changes = Hashr.new(data.push.changes[0])
63
+ commit = changes[:new]
64
+ author = parse_author(commit.target.author.raw)
65
+
66
+ @branch = commit.name
67
+ @commit = commit.target[:hash]
68
+ @message = commit.target[:message].to_s.strip
69
+ @author = author.name
70
+ @author_email = author.email
71
+ @commit_url = commit.target.links.html.href
72
+
73
+ if changes.links.html
74
+ @compare_url = changes.links.html.href
75
+ end
76
+ end
56
77
  end
57
78
  end
@@ -1,5 +1,5 @@
1
1
  module Magnum
2
2
  module Payload
3
- VERSION = "0.5.0"
3
+ VERSION = "0.6.0"
4
4
  end
5
5
  end
@@ -0,0 +1,186 @@
1
+ {
2
+ "push": {
3
+ "changes": [
4
+ {
5
+ "old": {
6
+ "type": "branch",
7
+ "target": {
8
+ "date": "2015-06-18T17:32:38+00:00",
9
+ "type": "commit",
10
+ "author": {
11
+ "user": {
12
+ "type": "user",
13
+ "uuid": "{uuid}",
14
+ "username": "sosedoff",
15
+ "display_name": "Dan Sosedoff",
16
+ "links": {
17
+ "html": {
18
+ "href": "https://bitbucket.org/sosedoff"
19
+ },
20
+ "self": {
21
+ "href": "https://bitbucket.org/api/2.0/users/sosedoff"
22
+ },
23
+ "avatar": {
24
+ "href": "https://bitbucket.org/account/sosedoff/avatar/32/"
25
+ }
26
+ }
27
+ },
28
+ "raw": "Dan Sosedoff <dan.sosedoff@gmail.com>"
29
+ },
30
+ "message": "Initial\n",
31
+ "links": {
32
+ "html": {
33
+ "href": "https://bitbucket.org/sosedoff/test-bitbucket-repo/commits/4da3ecc3e168597d1485ea5c84cee859ebfde5b4"
34
+ },
35
+ "self": {
36
+ "href": "https://bitbucket.org/api/2.0/repositories/sosedoff/test-bitbucket-repo/commit/4da3ecc3e168597d1485ea5c84cee859ebfde5b4"
37
+ }
38
+ },
39
+ "hash": "4da3ecc3e168597d1485ea5c84cee859ebfde5b4",
40
+ "parents": []
41
+ },
42
+ "name": "master",
43
+ "links": {
44
+ "html": {
45
+ "href": "https://bitbucket.org/sosedoff/test-bitbucket-repo/branch/master"
46
+ },
47
+ "commits": {
48
+ "href": "https://bitbucket.org/api/2.0/repositories/sosedoff/test-bitbucket-repo/commits/master"
49
+ },
50
+ "self": {
51
+ "href": "https://bitbucket.org/api/2.0/repositories/sosedoff/test-bitbucket-repo/refs/branches/master"
52
+ }
53
+ }
54
+ },
55
+ "closed": false,
56
+ "links": {
57
+ "html": {
58
+ "href": "https://bitbucket.org/sosedoff/test-bitbucket-repo/branches/compare/9a8349584a87d4760519beb30de938bcf56739f5..4da3ecc3e168597d1485ea5c84cee859ebfde5b4"
59
+ },
60
+ "commits": {
61
+ "href": "https://bitbucket.org/api/2.0/repositories/sosedoff/test-bitbucket-repo/commits?include=9a8349584a87d4760519beb30de938bcf56739f5exclude=4da3ecc3e168597d1485ea5c84cee859ebfde5b4"
62
+ },
63
+ "diff": {
64
+ "href": "https://bitbucket.org/api/2.0/repositories/sosedoff/test-bitbucket-repo/diff/9a8349584a87d4760519beb30de938bcf56739f5..4da3ecc3e168597d1485ea5c84cee859ebfde5b4"
65
+ }
66
+ },
67
+ "forced": false,
68
+ "new": {
69
+ "type": "branch",
70
+ "target": {
71
+ "date": "2015-06-18T17:33:43+00:00",
72
+ "type": "commit",
73
+ "author": {
74
+ "user": {
75
+ "type": "user",
76
+ "uuid": "{uuid}",
77
+ "username": "sosedoff",
78
+ "display_name": "Dan Sosedoff",
79
+ "links": {
80
+ "html": {
81
+ "href": "https://bitbucket.org/sosedoff"
82
+ },
83
+ "self": {
84
+ "href": "https://bitbucket.org/api/2.0/users/sosedoff"
85
+ },
86
+ "avatar": {
87
+ "href": "https://bitbucket.org/account/sosedoff/avatar/32/"
88
+ }
89
+ }
90
+ },
91
+ "raw": "Dan Sosedoff <dan.sosedoff@gmail.com>"
92
+ },
93
+ "message": "Update\n",
94
+ "links": {
95
+ "html": {
96
+ "href": "https://bitbucket.org/sosedoff/test-bitbucket-repo/commits/9a8349584a87d4760519beb30de938bcf56739f5"
97
+ },
98
+ "self": {
99
+ "href": "https://bitbucket.org/api/2.0/repositories/sosedoff/test-bitbucket-repo/commit/9a8349584a87d4760519beb30de938bcf56739f5"
100
+ }
101
+ },
102
+ "hash": "9a8349584a87d4760519beb30de938bcf56739f5",
103
+ "parents": [
104
+ {
105
+ "type": "commit",
106
+ "links": {
107
+ "html": {
108
+ "href": "https://bitbucket.org/sosedoff/test-bitbucket-repo/commits/4da3ecc3e168597d1485ea5c84cee859ebfde5b4"
109
+ },
110
+ "self": {
111
+ "href": "https://bitbucket.org/api/2.0/repositories/sosedoff/test-bitbucket-repo/commit/4da3ecc3e168597d1485ea5c84cee859ebfde5b4"
112
+ }
113
+ },
114
+ "hash": "4da3ecc3e168597d1485ea5c84cee859ebfde5b4"
115
+ }
116
+ ]
117
+ },
118
+ "name": "master",
119
+ "links": {
120
+ "html": {
121
+ "href": "https://bitbucket.org/sosedoff/test-bitbucket-repo/branch/master"
122
+ },
123
+ "commits": {
124
+ "href": "https://bitbucket.org/api/2.0/repositories/sosedoff/test-bitbucket-repo/commits/master"
125
+ },
126
+ "self": {
127
+ "href": "https://bitbucket.org/api/2.0/repositories/sosedoff/test-bitbucket-repo/refs/branches/master"
128
+ }
129
+ }
130
+ },
131
+ "created": false
132
+ }
133
+ ]
134
+ },
135
+ "actor": {
136
+ "type": "user",
137
+ "uuid": "{uuid}",
138
+ "username": "sosedoff",
139
+ "display_name": "Dan Sosedoff",
140
+ "links": {
141
+ "html": {
142
+ "href": "https://bitbucket.org/sosedoff"
143
+ },
144
+ "self": {
145
+ "href": "https://bitbucket.org/api/2.0/users/sosedoff"
146
+ },
147
+ "avatar": {
148
+ "href": "https://bitbucket.org/account/sosedoff/avatar/32/"
149
+ }
150
+ }
151
+ },
152
+ "repository": {
153
+ "full_name": "sosedoff/test-bitbucket-repo",
154
+ "type": "repository",
155
+ "name": "test-bitbucket-repo",
156
+ "uuid": "{uuid}",
157
+ "links": {
158
+ "html": {
159
+ "href": "https://bitbucket.org/sosedoff/test-bitbucket-repo"
160
+ },
161
+ "self": {
162
+ "href": "https://bitbucket.org/api/2.0/repositories/sosedoff/test-bitbucket-repo"
163
+ },
164
+ "avatar": {
165
+ "href": "https://bitbucket.org/sosedoff/test-bitbucket-repo/avatar/16/"
166
+ }
167
+ },
168
+ "owner": {
169
+ "type": "user",
170
+ "uuid": "{uuid}",
171
+ "username": "sosedoff",
172
+ "display_name": "Dan Sosedoff",
173
+ "links": {
174
+ "html": {
175
+ "href": "https://bitbucket.org/sosedoff"
176
+ },
177
+ "self": {
178
+ "href": "https://bitbucket.org/api/2.0/users/sosedoff"
179
+ },
180
+ "avatar": {
181
+ "href": "https://bitbucket.org/account/sosedoff/avatar/32/"
182
+ }
183
+ }
184
+ }
185
+ }
186
+ }
@@ -8,80 +8,54 @@ describe Magnum::Payload::Bitbucket do
8
8
  context "with git payload" do
9
9
  let(:data) { fixture("bitbucket/git.json") }
10
10
 
11
- it "sets commit SHA" do
11
+ it "parses payload" do
12
12
  expect(payload.commit).to eq "f15566c42759198fd32a70963d2509f3f8309586"
13
- end
14
-
15
- it "sets commit branch" do
16
13
  expect(payload.branch).to eq "master"
17
- end
18
-
19
- it "sets commit message" do
20
14
  expect(payload.message).to eq "Commit Sat Jan 19 18:42:40 CST 2013"
21
- end
22
-
23
- it "sets committer name" do
24
15
  expect(payload.committer).to eq nil
25
- end
26
-
27
- it "sets committer email" do
28
16
  expect(payload.committer_email).to eq nil
29
- end
30
-
31
- it "sets author name" do
32
17
  expect(payload.author).to eq "Dan Sosedoff"
33
- end
34
-
35
- it "sets author email" do
36
18
  expect(payload.author_email).to eq "dan.sosedoff@gmail.com"
37
- end
38
-
39
- it "sets commit view url" do
40
19
  expect(payload.commit_url).to eq "https://bitbucket.org/sosedoff/test1/commits/f15566c42759198fd32a70963d2509f3f8309586"
41
- end
42
-
43
- it "sets compare url" do
44
20
  expect(payload.compare_url).to eq "https://bitbucket.org/sosedoff/test1/compare/e15c6013c0f6232153e53b003b97da51d338da3a..f15566c42759198fd32a70963d2509f3f8309586"
45
21
  end
46
22
 
47
- context "that does not have commits" do
23
+ context "when no commits" do
48
24
  let(:data) { fixture("bitbucket/git_no_commits.json") }
49
25
 
50
- it "raises PayloadError exception" do
26
+ it "raises an exception" do
51
27
  expect { described_class.new(data) }.
52
28
  to raise_error Magnum::Payload::PayloadError, "Payload has no commits"
53
29
  end
54
30
  end
55
31
  end
56
32
 
33
+ context "with new git payload" do
34
+ let(:data) { fixture "bitbucket/git_new.json" }
35
+
36
+ it "parses payload" do
37
+ expect(payload.commit).to eq "9a8349584a87d4760519beb30de938bcf56739f5"
38
+ expect(payload.branch).to eq "master"
39
+ expect(payload.message).to eq "Update"
40
+ expect(payload.committer).to eq nil
41
+ expect(payload.committer_email).to eq nil
42
+ expect(payload.author).to eq "Dan Sosedoff"
43
+ expect(payload.author_email).to eq "dan.sosedoff@gmail.com"
44
+ expect(payload.commit_url).to eq "https://bitbucket.org/sosedoff/test-bitbucket-repo/commits/9a8349584a87d4760519beb30de938bcf56739f5"
45
+ expect(payload.compare_url).to eq "https://bitbucket.org/sosedoff/test-bitbucket-repo/branches/compare/9a8349584a87d4760519beb30de938bcf56739f5..4da3ecc3e168597d1485ea5c84cee859ebfde5b4"
46
+ end
47
+ end
48
+
57
49
  context "with mercurial payload" do
58
50
  let(:data) { fixture("bitbucket/hg.json") }
59
51
 
60
- it "sets commit SHA" do
52
+ it "parses payload" do
61
53
  expect(payload.commit).to eq 4
62
- end
63
-
64
- it "sets commit branch" do
65
54
  expect(payload.branch).to eq "default"
66
- end
67
-
68
- it "sets commit message" do
69
55
  expect(payload.message).to eq "Commit 2"
70
- end
71
-
72
- it "sets author name" do
73
- payload.author.should eq "Dan Sosedoff"
74
- end
75
-
76
- it "sets author email" do
56
+ expect(payload.author).to eq "Dan Sosedoff"
77
57
  expect(payload.author_email).to eq "dan.sosedoff@gmail.com"
78
- end
79
-
80
- it "sets commit view url" do
81
58
  expect(payload.commit_url).to eq "https://bitbucket.org/sosedoff/mercurial-test/commits/4"
82
- end
83
-
84
- it "sets compare url" do
85
59
  expect(payload.compare_url).to eq "https://bitbucket.org/sosedoff/mercurial-test/compare/3..4"
86
60
  end
87
61
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magnum-payload
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Sosedoff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-13 00:00:00.000000000 Z
11
+ date: 2015-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -111,6 +111,7 @@ files:
111
111
  - spec/fixtures/beanstalk/hg.json
112
112
  - spec/fixtures/beanstalk/svn.json
113
113
  - spec/fixtures/bitbucket/git.json
114
+ - spec/fixtures/bitbucket/git_new.json
114
115
  - spec/fixtures/bitbucket/git_no_commits.json
115
116
  - spec/fixtures/bitbucket/hg.json
116
117
  - spec/fixtures/github.json
@@ -163,6 +164,7 @@ test_files:
163
164
  - spec/fixtures/beanstalk/hg.json
164
165
  - spec/fixtures/beanstalk/svn.json
165
166
  - spec/fixtures/bitbucket/git.json
167
+ - spec/fixtures/bitbucket/git_new.json
166
168
  - spec/fixtures/bitbucket/git_no_commits.json
167
169
  - spec/fixtures/bitbucket/hg.json
168
170
  - spec/fixtures/github.json