magnum-payload 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +1 -10
- data/Rakefile +12 -3
- data/lib/magnum/payload/base.rb +2 -0
- data/lib/magnum/payload/beanstalk.rb +5 -0
- data/lib/magnum/payload/gitlab.rb +1 -3
- data/lib/magnum/payload/version.rb +1 -1
- data/spec/fixtures/beanstalk/git_branch_delete.json +20 -0
- data/spec/payload/base_spec.rb +57 -22
- data/spec/payload/beanstalk_spec.rb +8 -0
- data/spec/payload/bitbucket_spec.rb +58 -50
- data/spec/payload/github_spec.rb +8 -2
- data/spec/payload/message_parser_spec.rb +30 -27
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8f355e4af0da303d451c791184ef2db4ea963cf
|
4
|
+
data.tar.gz: ba6b8d1a4d1af1d9148fbf9ae99b95d4c1b7466d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44f535e0fb242a222eb22eb11bf876c1a71acee4bebcf8fd39346da76879beda8ea443a8847c88bceabb76f43f3560b02462c0f0dd09f790587dee74c586266d
|
7
|
+
data.tar.gz: d95b1dab33bf627bbf07c27d137bf50da1485baf99c9d849cf517a5a22541d61c5c1743fc36aafdbc4e0cafe2c196bbb9eb049fb2abb1f10bfdd017b48303d9a
|
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2013-2014
|
3
|
+
Copyright (c) 2013-2014 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
@@ -91,17 +91,8 @@ To execute test suite run:
|
|
91
91
|
rake test
|
92
92
|
```
|
93
93
|
|
94
|
-
## Contact
|
95
|
-
|
96
|
-
Magnum CI
|
97
|
-
|
98
|
-
- [https://magnum-ci.com](https://magnum-ci.com)
|
99
|
-
- [https://github.com/magnumci](https://github.com/magnumci)
|
100
|
-
- [https://twitter.com/ci_magnum](https://twitter.com/ci_magnum)
|
101
|
-
- [support@magnum-ci.com](mailto:support@magnum-ci.com)
|
102
|
-
|
103
94
|
## License
|
104
95
|
|
105
96
|
The MIT License (MIT)
|
106
97
|
|
107
|
-
Copyright (c) 2013-2014
|
98
|
+
Copyright (c) 2013-2014 Magnum CI
|
data/Rakefile
CHANGED
@@ -1,10 +1,19 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "bundler"
|
2
|
+
require "bundler/gem_tasks"
|
3
3
|
require "rspec/core/rake_task"
|
4
4
|
|
5
5
|
RSpec::Core::RakeTask.new(:test) do |t|
|
6
|
-
t.pattern =
|
6
|
+
t.pattern = "spec/**/*_spec.rb"
|
7
7
|
t.verbose = false
|
8
8
|
end
|
9
9
|
|
10
|
+
task :console do
|
11
|
+
require "irb"
|
12
|
+
require "irb/completion"
|
13
|
+
require "magnum/payload"
|
14
|
+
|
15
|
+
ARGV.clear
|
16
|
+
IRB.start
|
17
|
+
end
|
18
|
+
|
10
19
|
task :default => :test
|
data/lib/magnum/payload/base.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
module Magnum
|
2
2
|
class Payload::Gitlab < Payload::Base
|
3
|
-
ZERO_SHA = /\A[0]{40}\z/
|
4
|
-
|
5
3
|
def parse!
|
6
4
|
assign_payload unless skip_payload?
|
7
5
|
end
|
@@ -32,7 +30,7 @@ module Magnum
|
|
32
30
|
end
|
33
31
|
|
34
32
|
def deleted?
|
35
|
-
data.before !~
|
33
|
+
data.before !~ GIT_ZERO_SHA && data.after =~ GIT_ZERO_SHA
|
36
34
|
end
|
37
35
|
end
|
38
36
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"branch": "feature-13914-activation-via-password-reset",
|
3
|
+
"ref": "refs/heads/feature-13914-activation-via-password-reset",
|
4
|
+
"before": "ad027019cdfd4a78e622feb87fb2c56627911d36",
|
5
|
+
"after": "0000000000000000000000000000000000000000",
|
6
|
+
"uri": "git@company.git.beanstalkapp.com:/repo.git",
|
7
|
+
"pusher_id": 12345,
|
8
|
+
"pusher_name": "John Doe",
|
9
|
+
"repository": {
|
10
|
+
"name": "repo",
|
11
|
+
"url": "http://company.beanstalkapp.com/repo",
|
12
|
+
"private": true,
|
13
|
+
"owner": {
|
14
|
+
"name": "John Doe",
|
15
|
+
"email": "owner@email.com"
|
16
|
+
}
|
17
|
+
},
|
18
|
+
"push_is_too_large": false,
|
19
|
+
"commits": []
|
20
|
+
}
|
data/spec/payload/base_spec.rb
CHANGED
@@ -1,59 +1,63 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Magnum::Payload::Base do
|
4
4
|
let(:base) { described_class }
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
describe "#new" do
|
7
|
+
before do
|
8
|
+
Magnum::Payload::Base.any_instance.stub(:parse!)
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
-
it 'assigns raw data attribute' do
|
11
|
+
it "assigns raw data attribute" do
|
12
12
|
Magnum::Payload::Base.any_instance.stub(:parse_payload)
|
13
13
|
|
14
14
|
payload = base.new("raw data")
|
15
|
-
payload.raw_data.
|
15
|
+
expect(payload.raw_data).to eq "raw data"
|
16
16
|
end
|
17
17
|
|
18
|
-
it
|
19
|
-
payload = base.new({
|
20
|
-
payload.data.
|
18
|
+
it "assigns data attribute" do
|
19
|
+
payload = base.new({"foo" => "bar"})
|
20
|
+
expect(payload.data).to be_a Hashr
|
21
21
|
end
|
22
22
|
|
23
|
-
it
|
23
|
+
it "accepts a string" do
|
24
24
|
payload = base.new('{"foo":"bar"}')
|
25
|
-
|
26
|
-
payload.data.
|
25
|
+
|
26
|
+
expect(payload.data).to be_a Hashr
|
27
|
+
expect(payload.data.foo).to eq "bar"
|
27
28
|
end
|
28
29
|
|
29
|
-
it
|
30
|
-
payload = base.new({
|
31
|
-
|
32
|
-
payload.data.
|
30
|
+
it "accepts a hash" do
|
31
|
+
payload = base.new({"foo" => "bar"})
|
32
|
+
|
33
|
+
expect(payload.data).to be_a Hashr
|
34
|
+
expect(payload.data.foo).to eq "bar"
|
33
35
|
end
|
34
36
|
|
35
|
-
it
|
37
|
+
it "raises error on invalid input type" do
|
36
38
|
expect { base.new(nil) }.to raise_error "String or Hash required"
|
37
39
|
end
|
38
40
|
|
39
|
-
it
|
41
|
+
it "raises error on invalid json" do
|
40
42
|
expect { base.new("invalid json") }.
|
41
43
|
to raise_error Magnum::Payload::ParseError, "Valid JSON required"
|
42
44
|
end
|
43
45
|
end
|
44
46
|
|
45
|
-
describe
|
47
|
+
describe "#skip" do
|
46
48
|
before do
|
49
|
+
Magnum::Payload::Base.any_instance.stub(:parse!)
|
47
50
|
Magnum::Payload::Base.any_instance.stub(:parse_payload)
|
48
51
|
end
|
49
52
|
|
50
|
-
it
|
51
|
-
base.new(
|
53
|
+
it "returns false" do
|
54
|
+
expect(base.new("data").skip).to be_false
|
52
55
|
end
|
53
56
|
end
|
54
57
|
|
55
58
|
describe "#skip?" do
|
56
59
|
before do
|
60
|
+
Magnum::Payload::Base.any_instance.stub(:parse!)
|
57
61
|
Magnum::Payload::Base.any_instance.stub(:parse_payload)
|
58
62
|
Magnum::Payload::Base.any_instance.stub(:skip) { true }
|
59
63
|
end
|
@@ -62,4 +66,35 @@ describe Magnum::Payload::Base do
|
|
62
66
|
expect(base.new("data").skip?).to be_true
|
63
67
|
end
|
64
68
|
end
|
69
|
+
|
70
|
+
describe "#parse!" do
|
71
|
+
it "raises error" do
|
72
|
+
expect { described_class.new("foo" => "bar").parse! }.
|
73
|
+
to raise_error "Not implemented in base class"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "#attributes_hash" do
|
78
|
+
let(:hash) { described_class.new("foo" => "bar").attributes_hash }
|
79
|
+
|
80
|
+
before do
|
81
|
+
Magnum::Payload::Base.any_instance.stub(:parse!)
|
82
|
+
end
|
83
|
+
|
84
|
+
it "returns payload hash" do
|
85
|
+
expect(hash).to be_a Hash
|
86
|
+
end
|
87
|
+
|
88
|
+
it "it includes attributes" do
|
89
|
+
expect(hash.keys).to eq [
|
90
|
+
"commit",
|
91
|
+
"branch",
|
92
|
+
"author",
|
93
|
+
"committer",
|
94
|
+
"message",
|
95
|
+
"commit_url",
|
96
|
+
"compare_url"
|
97
|
+
]
|
98
|
+
end
|
99
|
+
end
|
65
100
|
end
|
@@ -46,6 +46,14 @@ describe Magnum::Payload::Beanstalk do
|
|
46
46
|
expect(payload.test).to be_true
|
47
47
|
end
|
48
48
|
end
|
49
|
+
|
50
|
+
context "when deleted branch" do
|
51
|
+
let(:data) { fixture "beanstalk/git_branch_delete.json" }
|
52
|
+
|
53
|
+
it "sets skip to true" do
|
54
|
+
expect(payload.skip).to be_true
|
55
|
+
end
|
56
|
+
end
|
49
57
|
end
|
50
58
|
|
51
59
|
context "with svn payload" do
|
@@ -1,103 +1,111 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Magnum::Payload::Bitbucket do
|
4
|
-
let(:data)
|
5
|
-
let(:payload) {
|
4
|
+
let(:data) { fixture("bitbucket/git.json") }
|
5
|
+
let(:payload) { described_class.new(data) }
|
6
6
|
|
7
|
-
describe
|
8
|
-
context
|
9
|
-
let(:data) { fixture(
|
7
|
+
describe "#parse!" do
|
8
|
+
context "with git payload" do
|
9
|
+
let(:data) { fixture("bitbucket/git.json") }
|
10
10
|
|
11
|
-
it
|
12
|
-
payload.commit.
|
11
|
+
it "sets commit SHA" do
|
12
|
+
expect(payload.commit).to eq "f15566c42759198fd32a70963d2509f3f8309586"
|
13
13
|
end
|
14
14
|
|
15
|
-
it
|
16
|
-
payload.branch.
|
15
|
+
it "sets commit branch" do
|
16
|
+
expect(payload.branch).to eq "master"
|
17
17
|
end
|
18
18
|
|
19
|
-
it
|
20
|
-
payload.message.
|
19
|
+
it "sets commit message" do
|
20
|
+
expect(payload.message).to eq "Commit Sat Jan 19 18:42:40 CST 2013"
|
21
21
|
end
|
22
22
|
|
23
|
-
it
|
24
|
-
payload.committer.
|
25
|
-
|
23
|
+
it "sets committer name" do
|
24
|
+
expect(payload.committer).to eq nil
|
25
|
+
end
|
26
|
+
|
27
|
+
it "sets committer email" do
|
28
|
+
expect(payload.committer_email).to eq nil
|
29
|
+
end
|
26
30
|
|
27
|
-
|
28
|
-
payload.
|
31
|
+
it "sets author name" do
|
32
|
+
expect(payload.author).to eq "Dan Sosedoff"
|
29
33
|
end
|
30
34
|
|
31
|
-
it
|
32
|
-
payload.
|
35
|
+
it "sets author email" do
|
36
|
+
expect(payload.author_email).to eq "dan.sosedoff@gmail.com"
|
33
37
|
end
|
34
38
|
|
35
|
-
it
|
36
|
-
payload.
|
39
|
+
it "sets commit view url" do
|
40
|
+
expect(payload.commit_url).to eq "https://bitbucket.org/sosedoff/test1/commits/f15566c42759198fd32a70963d2509f3f8309586"
|
41
|
+
end
|
42
|
+
|
43
|
+
it "sets compare url" do
|
44
|
+
expect(payload.compare_url).to eq "https://bitbucket.org/sosedoff/test1/compare/e15c6013c0f6232153e53b003b97da51d338da3a..f15566c42759198fd32a70963d2509f3f8309586"
|
37
45
|
end
|
38
46
|
|
39
47
|
context "that does not have commits" do
|
40
48
|
let(:data) { fixture("bitbucket/git_no_commits.json") }
|
41
49
|
|
42
50
|
it "raises PayloadError exception" do
|
43
|
-
expect {
|
51
|
+
expect { described_class.new(data) }.
|
44
52
|
to raise_error Magnum::Payload::PayloadError, "Payload has no commits"
|
45
53
|
end
|
46
54
|
end
|
47
55
|
end
|
48
56
|
|
49
|
-
context
|
50
|
-
let(:data) { fixture(
|
57
|
+
context "with mercurial payload" do
|
58
|
+
let(:data) { fixture("bitbucket/hg.json") }
|
51
59
|
|
52
|
-
it
|
53
|
-
payload.commit.
|
60
|
+
it "sets commit SHA" do
|
61
|
+
expect(payload.commit).to eq 4
|
54
62
|
end
|
55
63
|
|
56
|
-
it
|
57
|
-
payload.branch.
|
64
|
+
it "sets commit branch" do
|
65
|
+
expect(payload.branch).to eq "default"
|
58
66
|
end
|
59
67
|
|
60
|
-
it
|
61
|
-
payload.message.
|
68
|
+
it "sets commit message" do
|
69
|
+
expect(payload.message).to eq "Commit 2"
|
62
70
|
end
|
63
71
|
|
64
|
-
it
|
65
|
-
payload.
|
66
|
-
|
72
|
+
it "sets author name" do
|
73
|
+
payload.author.should eq "Dan Sosedoff"
|
74
|
+
end
|
67
75
|
|
68
|
-
|
69
|
-
payload.author_email.
|
76
|
+
it "sets author email" do
|
77
|
+
expect(payload.author_email).to eq "dan.sosedoff@gmail.com"
|
70
78
|
end
|
71
79
|
|
72
|
-
it
|
73
|
-
payload.commit_url.
|
80
|
+
it "sets commit view url" do
|
81
|
+
expect(payload.commit_url).to eq "https://bitbucket.org/sosedoff/mercurial-test/commits/4"
|
74
82
|
end
|
75
83
|
|
76
|
-
it
|
77
|
-
payload.compare_url.
|
84
|
+
it "sets compare url" do
|
85
|
+
expect(payload.compare_url).to eq "https://bitbucket.org/sosedoff/mercurial-test/compare/3..4"
|
78
86
|
end
|
79
87
|
end
|
80
88
|
end
|
81
89
|
|
82
|
-
describe
|
83
|
-
it
|
84
|
-
payload.site_url.
|
90
|
+
describe "#site_url" do
|
91
|
+
it "returns website url without a path" do
|
92
|
+
expect(payload.site_url).to eq "https://bitbucket.org"
|
85
93
|
end
|
86
94
|
end
|
87
95
|
|
88
|
-
describe
|
89
|
-
it
|
90
|
-
payload.repo_url.
|
96
|
+
describe "#repo_url" do
|
97
|
+
it "return relative repository path" do
|
98
|
+
expect(payload.repo_url).to eq "/sosedoff/test1/"
|
91
99
|
end
|
92
100
|
end
|
93
101
|
|
94
|
-
describe
|
95
|
-
it
|
96
|
-
payload.make_url.
|
102
|
+
describe "#make_url" do
|
103
|
+
it "returns a full url to the repository" do
|
104
|
+
expect(payload.make_url).to eq "https://bitbucket.org/sosedoff/test1/"
|
97
105
|
end
|
98
106
|
|
99
|
-
it
|
100
|
-
payload.make_url(
|
107
|
+
it "returns a full url to the repository action" do
|
108
|
+
expect(payload.make_url("commits/1234")).to eq "https://bitbucket.org/sosedoff/test1/commits/1234"
|
101
109
|
end
|
102
110
|
end
|
103
111
|
end
|
data/spec/payload/github_spec.rb
CHANGED
@@ -17,13 +17,19 @@ describe Magnum::Payload::Github do
|
|
17
17
|
expect(payload.message).to eq "Remove jruby from test matrix"
|
18
18
|
end
|
19
19
|
|
20
|
-
it "sets author" do
|
20
|
+
it "sets author name" do
|
21
21
|
expect(payload.committer).to eq "Dan Sosedoff"
|
22
|
+
end
|
23
|
+
|
24
|
+
it "sets author email" do
|
22
25
|
expect(payload.committer_email).to eq "dan.sosedoff@gmail.com"
|
23
26
|
end
|
24
27
|
|
25
|
-
it "sets committer" do
|
28
|
+
it "sets committer name" do
|
26
29
|
expect(payload.author).to eq "Dan Sosedoff"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "sets committer email" do
|
27
33
|
expect(payload.author_email).to eq "dan.sosedoff@gmail.com"
|
28
34
|
end
|
29
35
|
|
@@ -3,41 +3,44 @@ require "spec_helper"
|
|
3
3
|
describe Magnum::Payload::MessageParser do
|
4
4
|
let(:subject) { TestMessageParser.new }
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
expect(subject.skip_message?).to be_true
|
10
|
-
end
|
11
|
-
|
12
|
-
it "returns true when message contains 'ci skip'" do
|
13
|
-
subject.stub(:message).and_return("Commit message [ci skip]")
|
14
|
-
expect(subject.skip_message?).to be_true
|
15
|
-
end
|
6
|
+
before do
|
7
|
+
subject.stub(:message) { message }
|
8
|
+
end
|
16
9
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
10
|
+
describe "#skip_message?" do
|
11
|
+
context "when no skip points" do
|
12
|
+
let(:message) { "Commit message" }
|
21
13
|
|
22
|
-
|
23
|
-
|
24
|
-
|
14
|
+
it "returns false" do
|
15
|
+
expect(subject.skip_message?).to be_false
|
16
|
+
end
|
25
17
|
end
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
18
|
+
|
19
|
+
["[ci-skip]", "[ci skip]", "[skip ci]", "[skip-ci]"].each do |val|
|
20
|
+
context "when message contains #{val}" do
|
21
|
+
let(:message) { val }
|
22
|
+
|
23
|
+
it "returns true" do
|
24
|
+
expect(subject.skip_message?).to be_true
|
25
|
+
end
|
26
|
+
end
|
30
27
|
end
|
31
28
|
|
32
29
|
context "with multi-line message" do
|
33
|
-
|
34
|
-
|
35
|
-
|
30
|
+
context "when first line is a skip" do
|
31
|
+
let(:message) { "Commit message [skip-ci]\nCommit comments" }
|
32
|
+
|
33
|
+
it "returns true" do
|
34
|
+
expect(subject.skip_message?).to be_true
|
35
|
+
end
|
36
36
|
end
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
context "when first lie is not a skip" do
|
39
|
+
let(:message) { "Commit message\nLets skip [ci-skip]" }
|
40
|
+
|
41
|
+
it "returns false" do
|
42
|
+
expect(subject.skip_message?).to be_false
|
43
|
+
end
|
41
44
|
end
|
42
45
|
end
|
43
46
|
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.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Sosedoff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -106,6 +106,7 @@ files:
|
|
106
106
|
- lib/magnum/payload/version.rb
|
107
107
|
- magnum-payload.gemspec
|
108
108
|
- spec/fixtures/beanstalk/git.json
|
109
|
+
- spec/fixtures/beanstalk/git_branch_delete.json
|
109
110
|
- spec/fixtures/beanstalk/hg.json
|
110
111
|
- spec/fixtures/beanstalk/svn.json
|
111
112
|
- spec/fixtures/bitbucket/git.json
|
@@ -156,6 +157,7 @@ specification_version: 4
|
|
156
157
|
summary: Code payload parser
|
157
158
|
test_files:
|
158
159
|
- spec/fixtures/beanstalk/git.json
|
160
|
+
- spec/fixtures/beanstalk/git_branch_delete.json
|
159
161
|
- spec/fixtures/beanstalk/hg.json
|
160
162
|
- spec/fixtures/beanstalk/svn.json
|
161
163
|
- spec/fixtures/bitbucket/git.json
|