hookup 1.2.3 → 1.2.4
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.markdown +6 -0
- data/hookup.gemspec +1 -1
- data/lib/hookup.rb +30 -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: 21d8368abed9ca30e0bf5b42f4a9940dc4a168a3
|
4
|
+
data.tar.gz: ff0246d9aa5d3e003e60c63238d052934814f13c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc6771c38811c794949497c737921954978e668280f7943cb1a97102afe3bf55114c13976b427961f3d68e9e1c806c52d0b158e185c5b87f4cbc88fa520ccbc2
|
7
|
+
data.tar.gz: 75e885ad88596ba381bec73023938d3b9105eb673569dde15bf677384ec7e6b1845b98c7b4c7f53690a0a74131e98b618367a36e58e65c86e90a4c8b2e9cd543
|
data/README.markdown
CHANGED
@@ -48,6 +48,12 @@ Each time there's a conflict in `db/schema.rb` on the
|
|
48
48
|
`Rails::Schema.define` line, hookup resolves it in favor of the newer of
|
49
49
|
the two versions.
|
50
50
|
|
51
|
+
### Skip Hookup
|
52
|
+
|
53
|
+
Set the `SKIP_HOOKUP` environment variable to skip hookup.
|
54
|
+
|
55
|
+
SKIP_HOOKUP=1 git checkout master
|
56
|
+
|
51
57
|
ChangeLog
|
52
58
|
---------
|
53
59
|
|
data/hookup.gemspec
CHANGED
data/lib/hookup.rb
CHANGED
@@ -36,13 +36,17 @@ class Hookup
|
|
36
36
|
def git_dir
|
37
37
|
unless @git_dir
|
38
38
|
@git_dir = %x{git rev-parse --git-dir}.chomp
|
39
|
-
raise Error
|
39
|
+
raise Error unless $?.success?
|
40
40
|
end
|
41
41
|
@git_dir
|
42
42
|
end
|
43
43
|
|
44
|
+
def post_checkout_file
|
45
|
+
File.join(git_dir, 'hooks', 'post-checkout')
|
46
|
+
end
|
47
|
+
|
44
48
|
def install
|
45
|
-
append(
|
49
|
+
append(post_checkout_file, 0777) do |body, f|
|
46
50
|
f.puts "#!/bin/bash" unless body
|
47
51
|
f.puts %(hookup post-checkout "$@") if body !~ /hookup/
|
48
52
|
end
|
@@ -57,6 +61,14 @@ class Hookup
|
|
57
61
|
puts "Hooked up!"
|
58
62
|
end
|
59
63
|
|
64
|
+
def remove
|
65
|
+
body = IO.readlines(post_checkout_file)
|
66
|
+
body.reject! { |item| item =~ /hookup/ }
|
67
|
+
File.open(post_checkout_file, 'w') { |file| file.puts body.join }
|
68
|
+
|
69
|
+
puts "Hookup removed!"
|
70
|
+
end
|
71
|
+
|
60
72
|
def append(file, *args)
|
61
73
|
Dir.mkdir(File.dirname(file)) unless File.directory?(File.dirname(file))
|
62
74
|
body = File.read(file) if File.exist?(file)
|
@@ -82,6 +94,12 @@ class Hookup
|
|
82
94
|
File.join(working_dir, env['HOOKUP_SCHEMA_DIR'])
|
83
95
|
end
|
84
96
|
|
97
|
+
def possible_schemas
|
98
|
+
%w(development_structure.sql schema.rb structure.sql).map do |file|
|
99
|
+
File.join schema_dir, file
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
85
103
|
def working_dir
|
86
104
|
env['HOOKUP_WORKING_DIR'] || '.'
|
87
105
|
end
|
@@ -146,7 +164,7 @@ class Hookup
|
|
146
164
|
end
|
147
165
|
|
148
166
|
def migrate
|
149
|
-
schemas =
|
167
|
+
schemas = possible_schemas.select do |schema|
|
150
168
|
status = %x{git diff --name-status #{old} #{new} -- #{schema}}.chomp
|
151
169
|
rake 'db:create' if status =~ /^A/
|
152
170
|
status !~ /^D/ && !status.empty?
|
@@ -211,14 +229,19 @@ class Hookup
|
|
211
229
|
def resolve_schema(a, o, b, marker_size = 7)
|
212
230
|
system 'git', 'merge-file', "--marker-size=#{marker_size}", a, o, b
|
213
231
|
body = File.read(a)
|
214
|
-
|
215
|
-
|
216
|
-
"#{asd}(:version => #{[$1, $2].max}) do"
|
217
|
-
end
|
232
|
+
resolve_schema_version body, ":version =>"
|
233
|
+
resolve_schema_version body, "version:"
|
218
234
|
File.open(a, 'w') { |f| f.write(body) }
|
219
235
|
if body.include?('<' * marker_size.to_i)
|
220
236
|
raise Failure, 'Failed to automatically resolve schema conflict'
|
221
237
|
end
|
222
238
|
end
|
223
239
|
|
240
|
+
def resolve_schema_version(body, version)
|
241
|
+
asd = "ActiveRecord::Schema.define"
|
242
|
+
body.sub!(/^<+ .*\n#{asd}\(#{version} (\d+)\) do\n=+\n#{asd}\(#{version} (\d+)\) do\n>+ .*/) do
|
243
|
+
"#{asd}(#{version} #{[$1, $2].max}) do"
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
224
247
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hookup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Pope
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Automatically bundle and migrate your Rails app when switching branches,
|
14
14
|
merging upstream changes, and bisecting.
|
@@ -46,7 +46,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
46
46
|
version: '0'
|
47
47
|
requirements: []
|
48
48
|
rubyforge_project: hookup
|
49
|
-
rubygems_version: 2.0
|
49
|
+
rubygems_version: 2.3.0
|
50
50
|
signing_key:
|
51
51
|
specification_version: 4
|
52
52
|
summary: Automate the bundle/migration tedium of Rails with Git hooks
|