hookup 1.2.3 → 1.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 70820867b9752ec2ecbc3ab1401c0e216e01b2f9
4
- data.tar.gz: abe373824ef50ab0c41cbaf53d27faa64a5c30e5
3
+ metadata.gz: 21d8368abed9ca30e0bf5b42f4a9940dc4a168a3
4
+ data.tar.gz: ff0246d9aa5d3e003e60c63238d052934814f13c
5
5
  SHA512:
6
- metadata.gz: 627629152cb201179573371eef16f8c547c8f0577d414ac41385955c5ff090d33e05660c1812caec19fa58d5aed85435a4fb84596dadfbde29cd008c8ab3c342
7
- data.tar.gz: 1431da32d144716b13c5fbed4f90b93d4b0bb1892f81b2d30e0d814ad3bebf9b44c0a13f40b0d82003395c6d85902a4d4833386c897e77bb4d814c464d9f364e
6
+ metadata.gz: fc6771c38811c794949497c737921954978e668280f7943cb1a97102afe3bf55114c13976b427961f3d68e9e1c806c52d0b158e185c5b87f4cbc88fa520ccbc2
7
+ data.tar.gz: 75e885ad88596ba381bec73023938d3b9105eb673569dde15bf677384ec7e6b1845b98c7b4c7f53690a0a74131e98b618367a36e58e65c86e90a4c8b2e9cd543
@@ -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
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "hookup"
5
- s.version = "1.2.3"
5
+ s.version = "1.2.4"
6
6
  s.platform = Gem::Platform::RUBY
7
7
  s.authors = ["Tim Pope"]
8
8
  s.email = ["code@tp"+'ope.net']
@@ -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, dir unless $?.success?
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(File.join(git_dir, 'hooks', 'post-checkout'), 0777) do |body, f|
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 = %W(#{schema_dir}/schema.rb #{schema_dir}/development_structure.sql).select do |schema|
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
- asd = "ActiveRecord::Schema.define"
215
- x = body.sub!(/^<+ .*\n#{asd}\(:version => (\d+)\) do\n=+\n#{asd}\(:version => (\d+)\) do\n>+ .*/) do
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.3
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: 2013-11-20 00:00:00.000000000 Z
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.3
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