migration_investigation 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/README.md +4 -0
- data/lib/migration_investigation.rb +7 -6
- data/lib/migration_investigation/version.rb +1 -1
- data/spec/migration_investigation_spec.rb +48 -7
- 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: db343e9aa4896c11604706e41c4edc07fafe6575
|
4
|
+
data.tar.gz: eaeb8cc77fed174079ed9f10c22f7b7344ae6d87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5be35dec195cdd849bb44b208ce33221de745226e64a0b9e3addb5cd7aa0725e66b736c20398f46324d2b8fd6ed18f74ce12239d03d9f9c8bcb4550f5f1390f0
|
7
|
+
data.tar.gz: fe69836f7d5ed7502ea801c8fa8a7e200ba3665619e9848b305fab9274e8bc5217d48b77a763042afefa8071d8721fb9338a176a2388f454df2259e410373f82
|
data/README.md
CHANGED
@@ -32,6 +32,10 @@ parameter:
|
|
32
32
|
|
33
33
|
$ MigrationInvestigation.pending_migrations? "staging", "abc123", additional_paths: ["db/seed.rb", "app/foo.txt"]
|
34
34
|
|
35
|
+
You can also add a pattern for migrations to ignore:
|
36
|
+
|
37
|
+
$ MigrationInvestigation.pending_migrations? "staging", "abc123", skip_filepath_pattern: /\d_online_/
|
38
|
+
|
35
39
|
## Contributing
|
36
40
|
|
37
41
|
1. Fork it
|
@@ -6,7 +6,7 @@ module MigrationInvestigation
|
|
6
6
|
old_sha = latest_stage_sha stage
|
7
7
|
return true if old_sha.nil?
|
8
8
|
|
9
|
-
change_count(old_sha, new_sha, build_interesting_paths(options)) != 0
|
9
|
+
change_count(old_sha, new_sha, build_interesting_paths(options.fetch(:additional_paths, [])), options[:skip_filepath_pattern]) != 0
|
10
10
|
end
|
11
11
|
|
12
12
|
private
|
@@ -16,14 +16,15 @@ module MigrationInvestigation
|
|
16
16
|
latest_tag.sha if latest_tag
|
17
17
|
end
|
18
18
|
|
19
|
-
def change_count(old_sha, new_sha, interesting_paths)
|
20
|
-
|
21
|
-
changes
|
19
|
+
def change_count(old_sha, new_sha, interesting_paths, skip_filepath_pattern)
|
20
|
+
cmd = "git diff --name-only #{old_sha} #{new_sha} #{interesting_paths.join(" ")}"
|
21
|
+
changes = `#{cmd}`
|
22
|
+
changes.split("\n").reject { |l| l.length == 0 }.reject { |l| skip_filepath_pattern && l =~ skip_filepath_pattern }.length
|
22
23
|
end
|
23
24
|
|
24
|
-
def build_interesting_paths(
|
25
|
+
def build_interesting_paths(additional_paths)
|
25
26
|
interesting_paths = ["db/migrate/"]
|
26
|
-
interesting_paths <<
|
27
|
+
interesting_paths << additional_paths
|
27
28
|
interesting_paths.flatten
|
28
29
|
end
|
29
30
|
end
|
@@ -21,37 +21,78 @@ describe MigrationInvestigation do
|
|
21
21
|
subject { MigrationInvestigation.pending_migrations? stage, new_sha }
|
22
22
|
|
23
23
|
before do
|
24
|
-
allow(MigrationInvestigation).to receive(:`).with("git diff --name-only #{old_sha} #{new_sha} db/migrate/
|
24
|
+
allow(MigrationInvestigation).to receive(:`).with("git diff --name-only #{old_sha} #{new_sha} db/migrate/").and_return(git_diff)
|
25
25
|
end
|
26
26
|
|
27
27
|
context "when there are migrations changed between the last tag for the given change, and the new SHA" do
|
28
|
-
let(:git_diff)
|
28
|
+
let(:git_diff) do
|
29
|
+
<<~GITDIFF
|
30
|
+
db/migrate/121345_foo_migration.rb
|
31
|
+
db/migrate/121345_bar_migration.rb
|
32
|
+
db/migrate/121345_baz_migration.rb
|
33
|
+
GITDIFF
|
34
|
+
end
|
29
35
|
|
30
36
|
it { is_expected.to be_truthy }
|
31
37
|
end
|
32
38
|
|
33
39
|
context "when there are no migrations changes between the last tag for the given change, and the new SHA" do
|
34
|
-
let(:git_diff) { "
|
40
|
+
let(:git_diff) { "\n" }
|
35
41
|
|
36
42
|
it { is_expected.to be_falsy }
|
37
43
|
end
|
38
44
|
end
|
39
45
|
|
46
|
+
context "when an uptime pattern is provided" do
|
47
|
+
subject { MigrationInvestigation.pending_migrations? stage, new_sha, skip_filepath_pattern: /\d_online_/}
|
48
|
+
|
49
|
+
before do
|
50
|
+
allow(MigrationInvestigation).to receive(:`).with("git diff --name-only #{old_sha} #{new_sha} db/migrate/").and_return(git_diff)
|
51
|
+
end
|
52
|
+
|
53
|
+
context "when only online migrations exist" do
|
54
|
+
let(:git_diff) do
|
55
|
+
<<~GITDIFF
|
56
|
+
db/migrate/121345_online_bar_migration.rb
|
57
|
+
db/migrate/121345_online_baz_migration.rb
|
58
|
+
GITDIFF
|
59
|
+
end
|
60
|
+
|
61
|
+
it { is_expected.to be_falsy }
|
62
|
+
end
|
63
|
+
|
64
|
+
context "when there are some offline migrations" do
|
65
|
+
let(:git_diff) do
|
66
|
+
<<~GITDIFF
|
67
|
+
db/migrate/121345_foo_migration.rb
|
68
|
+
db/migrate/121345_bar_migration.rb
|
69
|
+
db/migrate/121345_online_baz_migration.rb
|
70
|
+
GITDIFF
|
71
|
+
end
|
72
|
+
|
73
|
+
it { is_expected.to be_truthy }
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
40
77
|
context "when additional paths are passed in" do
|
41
|
-
subject { MigrationInvestigation.pending_migrations? stage, new_sha, additional_paths: ["app/foo.rb"]
|
78
|
+
subject { MigrationInvestigation.pending_migrations? stage, new_sha, additional_paths: ["app/foo.rb"] }
|
42
79
|
|
43
80
|
before do
|
44
|
-
allow(MigrationInvestigation).to receive(:`).with("git diff --name-only #{old_sha} #{new_sha} db/migrate/ app/foo.rb
|
81
|
+
allow(MigrationInvestigation).to receive(:`).with("git diff --name-only #{old_sha} #{new_sha} db/migrate/ app/foo.rb").and_return(git_diff)
|
45
82
|
end
|
46
83
|
|
47
84
|
context "when there are changes between the last tag for the given change, and the new SHA" do
|
48
|
-
let(:git_diff)
|
85
|
+
let(:git_diff) do
|
86
|
+
<<~GITDIFF
|
87
|
+
app/foo.rb
|
88
|
+
GITDIFF
|
89
|
+
end
|
49
90
|
|
50
91
|
it { is_expected.to be_truthy }
|
51
92
|
end
|
52
93
|
|
53
94
|
context "when there are no changes between the last tag for the given change, and the new SHA" do
|
54
|
-
let(:git_diff) { "
|
95
|
+
let(:git_diff) { "\n" }
|
55
96
|
|
56
97
|
it { is_expected.to be_falsy }
|
57
98
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: migration_investigation
|
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
|
- Brent Wheeldon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: auto_tagger
|
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
77
|
version: '0'
|
78
78
|
requirements: []
|
79
79
|
rubyforge_project:
|
80
|
-
rubygems_version: 2.
|
80
|
+
rubygems_version: 2.5.1
|
81
81
|
signing_key:
|
82
82
|
specification_version: 4
|
83
83
|
summary: Checks whether migrations, or other parts of your repo, have any changes.
|