heroku_hatchet 3.0.6 → 3.1.0
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/CHANGELOG.md +4 -0
- data/bin/hatchet +52 -4
- data/hatchet.json +5 -2
- data/hatchet.lock +15 -0
- data/lib/hatchet/version.rb +1 -1
- data/test/hatchet/lock_test.rb +9 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7705d38debbab89dedc8a49709edc3622dd8e3c24c019a11b1709c7bd9224977
|
4
|
+
data.tar.gz: c2cc84b1898f3c6401f3549339f25c44a985ef71bd870faea736f9d0e5155d1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfb9317a73bce407d199e2f87b210bd014b86e102d5de04a3f0a95e1aad4871a6b789ebe0e3e322e2eb140797a42ed9b5b81d0b3e109850bb056110b99f3129c
|
7
|
+
data.tar.gz: e7c68939dfff5a7d28754a16a6934cc1a2a5821424df408487632dfa62fcab1e38a5eb23527fdceadf63d64c72ff3a3455c72568504211c3ebfaec2b59175d81
|
data/CHANGELOG.md
CHANGED
data/bin/hatchet
CHANGED
@@ -14,14 +14,17 @@ require 'hatchet'
|
|
14
14
|
require 'thor'
|
15
15
|
require 'threaded'
|
16
16
|
require 'date'
|
17
|
+
require 'yaml'
|
17
18
|
|
18
19
|
class HatchetCLI < Thor
|
19
20
|
desc "install", "installs repos defined in 'hatchet.json'"
|
20
21
|
def install
|
21
22
|
warn_dot_ignore!
|
23
|
+
lock_hash = YAML.safe_load(File.read('hatchet.lock')).to_h
|
22
24
|
puts "Installing repos for hatchet"
|
23
25
|
dirs.map do |directory, git_repo|
|
24
26
|
Threaded.later do
|
27
|
+
commit = lock_hash.fetch(directory) { raise "expected #{directory} to be locked but it is not, please run `hatchet lock` and commit the results"}
|
25
28
|
directory = File.expand_path(directory)
|
26
29
|
if Dir[directory].present?
|
27
30
|
puts "== pulling '#{git_repo}' into '#{directory}'\n"
|
@@ -30,10 +33,33 @@ class HatchetCLI < Thor
|
|
30
33
|
puts "== cloning '#{git_repo}' into '#{directory}'\n"
|
31
34
|
clone(directory, git_repo)
|
32
35
|
end
|
36
|
+
checkout_commit(directory, commit)
|
33
37
|
end
|
34
38
|
end.map(&:join)
|
35
39
|
end
|
36
40
|
|
41
|
+
desc "locks to specific git commits", "updates hatchet.lock"
|
42
|
+
def lock
|
43
|
+
lock_hash = {}
|
44
|
+
dirs.map do |directory, git_repo|
|
45
|
+
Threaded.later do
|
46
|
+
puts "== locking #{directory}"
|
47
|
+
unless Dir.exist?(directory)
|
48
|
+
raise "Bad git repo #{git_repo.inspect}" if bad_repo?(git_repo)
|
49
|
+
clone(directory, git_repo, quiet: false)
|
50
|
+
end
|
51
|
+
|
52
|
+
commit = commit_at_directory(directory)
|
53
|
+
lock_hash[directory] = commit
|
54
|
+
end
|
55
|
+
end.map(&:join)
|
56
|
+
|
57
|
+
lock_hash = lock_hash.sort
|
58
|
+
File.open('hatchet.lock', 'w') {|f| f << lock_hash.to_yaml }
|
59
|
+
|
60
|
+
puts "Done!"
|
61
|
+
end
|
62
|
+
|
37
63
|
desc "list", "lists all repos and their destination listed in hatchet.json"
|
38
64
|
def list
|
39
65
|
repos.each do |repo, directory|
|
@@ -59,6 +85,11 @@ class HatchetCLI < Thor
|
|
59
85
|
|
60
86
|
private
|
61
87
|
|
88
|
+
def bad_repo?(url)
|
89
|
+
`git ls-remote --exit-code -h "#{url}"`
|
90
|
+
$? != 0
|
91
|
+
end
|
92
|
+
|
62
93
|
def warn_dot_ignore!
|
63
94
|
return false unless File.exist?('.gitignore')
|
64
95
|
|
@@ -80,14 +111,22 @@ class HatchetCLI < Thor
|
|
80
111
|
config.dirs
|
81
112
|
end
|
82
113
|
|
83
|
-
def
|
84
|
-
|
114
|
+
def checkout_commit(directory, commit)
|
115
|
+
cmd("cd #{directory} && git reset --hard #{commit}")
|
116
|
+
end
|
117
|
+
|
118
|
+
def commit_at_directory(directory)
|
119
|
+
cmd("cd #{directory} && git log -n1 --pretty=format:%H").strip
|
85
120
|
end
|
86
121
|
|
87
|
-
def
|
122
|
+
def pull(path, git_repo, commit: false)
|
123
|
+
cmd("cd #{path} && git pull --rebase #{git_repo} master --quiet")
|
124
|
+
end
|
125
|
+
|
126
|
+
def clone(path, git_repo, quiet: true)
|
88
127
|
path = File.join(path, '..') # up one dir to prevent repos/codetriage/codetriage/#...
|
89
128
|
FileUtils.mkdir_p(path)
|
90
|
-
|
129
|
+
cmd("cd #{path} && git clone #{git_repo} --quiet", quiet: quiet)
|
91
130
|
end
|
92
131
|
|
93
132
|
def bundle_exec
|
@@ -99,6 +138,15 @@ class HatchetCLI < Thor
|
|
99
138
|
yield
|
100
139
|
end
|
101
140
|
end
|
141
|
+
|
142
|
+
def cmd(command, let_fail: false, stdin: nil, quiet: true)
|
143
|
+
command = "printf '#{stdin}' | #{command}" if stdin
|
144
|
+
puts "Running: #{command}" unless quiet
|
145
|
+
result = `#{command}`
|
146
|
+
return result if let_fail
|
147
|
+
raise "Command #{command} failed:\n#{result}" unless $?.success?
|
148
|
+
return result
|
149
|
+
end
|
102
150
|
end
|
103
151
|
|
104
152
|
HatchetCLI.start(ARGV)
|
data/hatchet.json
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
{
|
2
|
-
"hatchet": {
|
2
|
+
"hatchet": {
|
3
|
+
"directory": "test/fixtures"
|
4
|
+
},
|
3
5
|
"rails3": ["sharpstone/rails3_mri_193"],
|
4
6
|
"rails2": ["sharpstone/rails2blog"],
|
5
7
|
"bundler": ["sharpstone/no_lockfile"],
|
@@ -7,5 +9,6 @@
|
|
7
9
|
"ci": [
|
8
10
|
"sharpstone/rails5_ruby_schema_format",
|
9
11
|
"sharpstone/rails5_ci_fails_no_database"
|
10
|
-
|
12
|
+
],
|
13
|
+
"lock": ["sharpstone/lock_fail"]
|
11
14
|
}
|
data/hatchet.lock
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
- - test/fixtures/repos/bundler/no_lockfile
|
3
|
+
- 1947ce9a9c276d5df1c323b2ad78d1d85c7ab4c0
|
4
|
+
- - test/fixtures/repos/ci/rails5_ci_fails_no_database
|
5
|
+
- 3044f05febdfbbe656f0f5113cf5968ca07e34fd
|
6
|
+
- - test/fixtures/repos/ci/rails5_ruby_schema_format
|
7
|
+
- 3e63c3e13f435cf4ab11265e9abd161cc28cc552
|
8
|
+
- - test/fixtures/repos/default/default_ruby
|
9
|
+
- da748a59340be8b950e7bbbfb32077eb67d70c3c
|
10
|
+
- - test/fixtures/repos/lock/lock_fail
|
11
|
+
- da748a59340be8b950e7bbbfb32077eb67d70c3c
|
12
|
+
- - test/fixtures/repos/rails2/rails2blog
|
13
|
+
- b37357a498ae5e8429f5601c5ab9524021dc2aaa
|
14
|
+
- - test/fixtures/repos/rails3/rails3_mri_193
|
15
|
+
- 88c5d0d067cfd11e4452633994a85b04627ae8c7
|
data/lib/hatchet/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heroku_hatchet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Schneeman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03
|
11
|
+
date: 2018-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: platform-api
|
@@ -196,6 +196,7 @@ files:
|
|
196
196
|
- bin/hatchet
|
197
197
|
- hatchet.gemspec
|
198
198
|
- hatchet.json
|
199
|
+
- hatchet.lock
|
199
200
|
- lib/hatchet.rb
|
200
201
|
- lib/hatchet/anvil_app.rb
|
201
202
|
- lib/hatchet/app.rb
|
@@ -218,6 +219,7 @@ files:
|
|
218
219
|
- test/hatchet/git_test.rb
|
219
220
|
- test/hatchet/heroku_api_test.rb
|
220
221
|
- test/hatchet/labs_test.rb
|
222
|
+
- test/hatchet/lock_test.rb
|
221
223
|
- test/hatchet/multi_cmd_runner_test.rb
|
222
224
|
- test/test_helper.rb
|
223
225
|
homepage: https://github.com/heroku/hatchet
|
@@ -258,5 +260,6 @@ test_files:
|
|
258
260
|
- test/hatchet/git_test.rb
|
259
261
|
- test/hatchet/heroku_api_test.rb
|
260
262
|
- test/hatchet/labs_test.rb
|
263
|
+
- test/hatchet/lock_test.rb
|
261
264
|
- test/hatchet/multi_cmd_runner_test.rb
|
262
265
|
- test/test_helper.rb
|