depl 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/depl +1 -1
- data/lib/depl/main.rb +29 -14
- data/lib/depl/version.rb +1 -1
- data/spec/depl/main_spec.rb +17 -15
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15687a80e9ac8e4666c3ac6903173add2ba28096
|
4
|
+
data.tar.gz: bfe44d5ac3a5cd481166ff4baa7d5745fdb893da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5997fee34089fab8c49049b9a5aad8907821e9539df276c42d45971cd68bccf54ee88d529a54631dfb1125e6f97223ca5fc3bbc8f13f4cf50151ad3b76894df5
|
7
|
+
data.tar.gz: 8e45fee13a66726ae29438e49c15a14712ffd5b4e11e990f728990d7fe37cc4a2b359b71452f75f800399cdbfe8ca153452843c28daad5628f632e604e10e2a6
|
data/bin/depl
CHANGED
data/lib/depl/main.rb
CHANGED
@@ -23,12 +23,25 @@ module Depl
|
|
23
23
|
@config[:prefix] || "deploy-"
|
24
24
|
end
|
25
25
|
|
26
|
+
def origin
|
27
|
+
@config[:origin] || "origin"
|
28
|
+
end
|
29
|
+
|
26
30
|
def deploy_branch
|
27
|
-
|
31
|
+
[prefix, environment].join('')
|
32
|
+
end
|
33
|
+
|
34
|
+
def tag_name
|
35
|
+
date = Time.now.strftime('%Y-%m-%d-%H-%M-%S')
|
36
|
+
[prefix, environment, '-', date].join('')
|
37
|
+
end
|
38
|
+
|
39
|
+
def tag_release
|
40
|
+
execute("git tag -a '#{tag_name}' #{local_sha}")
|
28
41
|
end
|
29
42
|
|
30
|
-
def
|
31
|
-
execute("git push --force origin #{local_sha}:refs/heads/#{deploy_branch}")
|
43
|
+
def advance_branch_pointer
|
44
|
+
execute("git push --follow-tags --force #{origin} #{local_sha}:refs/heads/#{deploy_branch}")
|
32
45
|
end
|
33
46
|
|
34
47
|
def run!
|
@@ -36,7 +49,8 @@ module Depl
|
|
36
49
|
`#{@config['before_hook']}`
|
37
50
|
end
|
38
51
|
|
39
|
-
|
52
|
+
tag_release
|
53
|
+
advance_branch_pointer
|
40
54
|
|
41
55
|
if @config['after_hook']
|
42
56
|
`#{@config['after_hook']}`
|
@@ -44,32 +58,32 @@ module Depl
|
|
44
58
|
end
|
45
59
|
|
46
60
|
def remote_sha
|
47
|
-
`git fetch origin`
|
48
|
-
sha = execute("git rev-parse -q --verify origin/#{deploy_branch}")
|
49
|
-
sha
|
61
|
+
`git fetch #{origin}`
|
62
|
+
sha = execute("git rev-parse -q --verify #{origin}/#{deploy_branch}")
|
63
|
+
sha && sha.chomp || raise("missing remote sha for #{origin}/#{deploy_branch}")
|
50
64
|
end
|
51
65
|
|
52
|
-
def up_to_date
|
66
|
+
def up_to_date?
|
53
67
|
local_sha == remote_sha
|
54
68
|
end
|
55
69
|
|
56
70
|
def local_sha
|
57
71
|
rev = @options[:rev] || @config[:branch] || 'head'
|
58
|
-
sha = execute("git rev-parse -q --verify #{rev}")
|
59
|
-
sha
|
72
|
+
sha = execute("git rev-parse -q --verify #{rev}")
|
73
|
+
sha && sha.chomp || raise("missing local sha: #{rev}")
|
60
74
|
end
|
61
75
|
|
62
76
|
def diff
|
63
|
-
execute "git log --pretty=format:' %h %<(20)%an %ar\t %s'
|
77
|
+
execute "git log --pretty=format:' %h %<(20)%an %ar\t %s' #{remote_sha}..#{local_sha}"
|
64
78
|
end
|
65
79
|
|
66
80
|
def reverse_diff
|
67
|
-
execute "git log --pretty=format:' %h %<(20)%an %ar\t %s'
|
81
|
+
execute "git log --pretty=format:' %h %<(20)%an %ar\t %s' #{local_sha}..#{remote_sha}"
|
68
82
|
end
|
69
83
|
|
70
84
|
def older_local_sha
|
71
85
|
return false unless remote_sha
|
72
|
-
execute("git merge-base --is-ancestor #{local_sha} #{remote_sha}")
|
86
|
+
!!execute("git merge-base --is-ancestor #{local_sha} #{remote_sha}")
|
73
87
|
end
|
74
88
|
|
75
89
|
def commit_count
|
@@ -79,7 +93,8 @@ module Depl
|
|
79
93
|
protected
|
80
94
|
|
81
95
|
def execute(cmd)
|
82
|
-
`#{cmd}`
|
96
|
+
output = `#{cmd}`
|
97
|
+
$?.exitstatus == 0 && output
|
83
98
|
end
|
84
99
|
end
|
85
100
|
end
|
data/lib/depl/version.rb
CHANGED
data/spec/depl/main_spec.rb
CHANGED
@@ -13,38 +13,40 @@ describe Depl::Main do
|
|
13
13
|
|
14
14
|
describe '#diff' do
|
15
15
|
it 'uses git to find the commits between two shas' do
|
16
|
-
deploy.
|
17
|
-
deploy.
|
16
|
+
expect(deploy).to receive(:remote_sha).and_return("remote")
|
17
|
+
expect(deploy).to receive(:local_sha).and_return("local")
|
18
18
|
|
19
|
-
cmd = "git log --pretty=format:' %h %<(20)%an %ar\t %s'
|
20
|
-
deploy.
|
19
|
+
cmd = "git log --pretty=format:' %h %<(20)%an %ar\t %s' remote..local"
|
20
|
+
expect(deploy).to receive(:execute).with(cmd)
|
21
21
|
|
22
22
|
deploy.diff
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
describe '#
|
26
|
+
describe '#advance_branch_pointer' do
|
27
27
|
it 'pushes a sha to the origin' do
|
28
|
-
deploy.
|
28
|
+
expect(deploy).to receive(:local_sha).and_return("12345")
|
29
29
|
|
30
|
-
cmd = "git push --force origin 12345:refs/heads/deploy-production"
|
31
|
-
deploy.
|
30
|
+
cmd = "git push --follow-tags --force origin 12345:refs/heads/deploy-production"
|
31
|
+
expect(deploy).to receive(:execute).with(cmd)
|
32
32
|
|
33
|
-
deploy.
|
33
|
+
deploy.advance_branch_pointer
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
describe '#up_to_date' do
|
38
38
|
it 'returns true when shas match' do
|
39
|
-
deploy.
|
40
|
-
deploy.
|
41
|
-
|
39
|
+
expect(deploy).to receive(:remote_sha).and_return("same")
|
40
|
+
expect(deploy).to receive(:local_sha).and_return("same")
|
41
|
+
|
42
|
+
expect(deploy.up_to_date?).to be true
|
42
43
|
end
|
43
44
|
|
44
45
|
it 'returns true when shas differ' do
|
45
|
-
deploy.
|
46
|
-
deploy.
|
47
|
-
|
46
|
+
expect(deploy).to receive(:remote_sha).and_return("remote")
|
47
|
+
expect(deploy).to receive(:local_sha).and_return("local")
|
48
|
+
|
49
|
+
expect(deploy.up_to_date?).to be false
|
48
50
|
end
|
49
51
|
end
|
50
52
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: depl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Nutt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: highline
|
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
95
|
version: '0'
|
96
96
|
requirements: []
|
97
97
|
rubyforge_project:
|
98
|
-
rubygems_version: 2.
|
98
|
+
rubygems_version: 2.6.8
|
99
99
|
signing_key:
|
100
100
|
specification_version: 4
|
101
101
|
summary: Writes project deployment hash to s3 file
|