git-merge-structure-sql 1.1.1 → 1.1.2
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/README.md +5 -0
- data/lib/git-merge-structure-sql.rb +54 -30
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45fa3f60e8db64b7a23134411c828fe3a2282c0460de038c4a4797053c3e0fd0
|
4
|
+
data.tar.gz: 3b2fed60a95223f78e75054594e368ef672aa57a44726ef8f34f142add0aa677
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77f0237b83a0d37ab7c699d4d88f68288cfc658e13778ab2995aedb30e2e0c17c53f95b1ca3992d8bc5af006eb6e46b0086261a5539e00f604cd7f372d4ffdd4
|
7
|
+
data.tar.gz: b18704eb043e4cbe1039a0dfd9adfa8c1853f58f5deec99e917cc9c1728cc55bd1b23b2f56770b5386047ceb18d160266493dcc2023375c23ada3986e966a7a5
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -30,6 +30,11 @@ This adds necessary settings to your `~/.gitconfig` or
|
|
30
30
|
`$XDG_CONFIG_HOME/git/config` and the default gitattributes(5) file to
|
31
31
|
enable the merge driver for structure.sql files.
|
32
32
|
|
33
|
+
If you want to enable this driver only in the current git directory,
|
34
|
+
run this:
|
35
|
+
|
36
|
+
$ git-merge-structure-sql --install=local
|
37
|
+
|
33
38
|
## Usage
|
34
39
|
|
35
40
|
Once enabled, Git should call this driver as necessary when it needs
|
@@ -33,7 +33,7 @@
|
|
33
33
|
#
|
34
34
|
|
35
35
|
class StructureSqlMergeDriver
|
36
|
-
VERSION = '1.1.
|
36
|
+
VERSION = '1.1.2'
|
37
37
|
VARIANTS = []
|
38
38
|
|
39
39
|
module Default # This covers PostgreSQL, SQLite and newer MySQL formats.
|
@@ -154,49 +154,73 @@ class StructureSqlMergeDriver
|
|
154
154
|
opts.summary_indent = ''
|
155
155
|
opts.summary_width = 24
|
156
156
|
|
157
|
-
opts.on('--install',
|
158
|
-
"Enable this merge driver in Git") { |val|
|
159
|
-
install = val
|
157
|
+
opts.on('--install[={global|local}]',
|
158
|
+
"Enable this merge driver in Git (default: global)") { |val|
|
159
|
+
case install = val&.to_sym || :global
|
160
|
+
when :global, :local
|
161
|
+
# ok
|
162
|
+
else
|
163
|
+
raise OptionParser::InvalidArgument, "--install=#{val}: unknown argument"
|
164
|
+
end
|
160
165
|
}
|
161
166
|
}
|
162
167
|
|
163
168
|
files = opts.order(argv)
|
164
169
|
|
165
170
|
if install
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
171
|
+
global = install == :global
|
172
|
+
|
173
|
+
git_config = ["git", "config", *("--global" if global)]
|
174
|
+
|
175
|
+
config_file = `GIT_EDITOR=echo #{git_config.shelljoin} -e 2>/dev/null`.chomp
|
176
|
+
|
177
|
+
puts "#{config_file}: Adding the \"#{driver_name}\" driver definition"
|
178
|
+
|
179
|
+
system!(
|
180
|
+
*git_config,
|
181
|
+
"merge.#{driver_name}.name",
|
182
|
+
"Rails structure.sql merge driver"
|
183
|
+
)
|
184
|
+
system!(
|
185
|
+
*git_config,
|
186
|
+
"merge.#{driver_name}.driver",
|
187
|
+
"#{myname.shellescape} %A %O %B"
|
188
|
+
)
|
189
|
+
|
178
190
|
attributes_file =
|
179
|
-
if
|
180
|
-
|
191
|
+
if global
|
192
|
+
filename = `git config --global core.attributesfile`.chomp
|
193
|
+
|
194
|
+
if $?.success?
|
195
|
+
File.expand_path(filename)
|
196
|
+
else
|
197
|
+
[
|
198
|
+
[File.join(ENV['XDG_CONFIG_HOME'] || '~/.config', 'git'), 'attributes'],
|
199
|
+
['~', '.gitattributes']
|
200
|
+
].find { |dir, file|
|
201
|
+
if File.directory?(File.expand_path(dir))
|
202
|
+
system!(*%W[
|
203
|
+
git config --global core.attributesfile #{File.join(dir, file)}
|
204
|
+
])
|
205
|
+
break File.expand_path(file, dir)
|
206
|
+
end
|
207
|
+
} or raise "don't you have home?"
|
208
|
+
end
|
181
209
|
else
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
])
|
190
|
-
break File.expand_path(file, dir)
|
191
|
-
end
|
192
|
-
} or raise "don't you have home?"
|
210
|
+
git_dir = `git rev-parse --git-dir`.chomp
|
211
|
+
|
212
|
+
if $?.success?
|
213
|
+
File.expand_path(File.join('info', 'attributes'), git_dir)
|
214
|
+
else
|
215
|
+
raise "not in a git directory"
|
216
|
+
end
|
193
217
|
end
|
194
218
|
|
195
219
|
File.open(attributes_file, 'a+') { |f|
|
196
220
|
pattern = /^\s*structure.sql\s+(?:\S+\s+)*merge=#{Regexp.quote(driver_name)}(?:\s|$)/
|
197
221
|
break if f.any? { |line| pattern === line }
|
198
222
|
|
199
|
-
puts "
|
223
|
+
puts "#{attributes_file}: Registering the \"#{driver_name}\" driver for structure.sql"
|
200
224
|
f.puts if f.pos > 0
|
201
225
|
f.puts "structure.sql merge=#{driver_name}"
|
202
226
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-merge-structure-sql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akinori MUSHA
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04-
|
11
|
+
date: 2021-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|