git-etc: remove all code.
I've given up on this; too many edge cases. If someone else wants to pick it up then send me a message and I'll walk you through the approach.
This commit is contained in:
parent
d9d2443d5d
commit
a28b57d3fb
@ -169,10 +169,7 @@ class Formula
|
||||
# generally we don't want var stuff inside the keg
|
||||
def var; HOMEBREW_PREFIX+'var' end
|
||||
|
||||
def bash_completion
|
||||
etc = ENV['HOMEBREW_GIT_ETC'] ? self.etc : prefix+'etc'
|
||||
etc+'bash_completion.d'
|
||||
end
|
||||
def bash_completion; prefix+'etc/bash_completion.d' end
|
||||
def zsh_completion; share+'zsh/site-functions' end
|
||||
|
||||
# for storing etc, var files for later copying from bottles
|
||||
|
@ -73,76 +73,6 @@ class FormulaInstaller
|
||||
raise
|
||||
end
|
||||
|
||||
def git_etc_preinstall
|
||||
return unless quiet_system 'git', '--version'
|
||||
|
||||
etc = HOMEBREW_PREFIX+'etc'
|
||||
etc.cd do
|
||||
quiet_system 'git', 'init' unless (etc+'.git').directory?
|
||||
quiet_system 'git', 'checkout', '-B', "#{f.name}-preinstall"
|
||||
unless quiet_system 'git', 'diff', '--exit-code', 'HEAD'
|
||||
system 'git', 'add', '--all', '.'
|
||||
system 'git', 'commit', '-m', "#{f.name}-#{f.version}: preinstall"
|
||||
end
|
||||
|
||||
unless quiet_system 'git', 'rev-parse', 'master'
|
||||
quiet_system 'git', 'branch', 'master'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def git_etc_postinstall
|
||||
return unless quiet_system 'git', '--version'
|
||||
|
||||
preinstall_branch = "#{f.name}-preinstall"
|
||||
default_branch = "#{f.name}-default"
|
||||
merged = false
|
||||
f.etc.mkpath
|
||||
f.etc.cd do
|
||||
if quiet_system 'git', 'diff', '--exit-code', preinstall_branch
|
||||
quiet_system 'git', 'branch', default_branch
|
||||
quiet_system 'git', 'branch', '-D', preinstall_branch
|
||||
elsif not quiet_system 'git', 'rev-parse', default_branch
|
||||
quiet_system 'git', 'checkout', '-B', default_branch
|
||||
quiet_system 'git', 'add', '--all', '.'
|
||||
system 'git', 'commit', '-m', "#{f.name}-#{f.version}: default"
|
||||
quiet_system 'git', 'branch', '-D', preinstall_branch
|
||||
else
|
||||
previous_default_branch = `git rev-parse #{default_branch}`.strip
|
||||
quiet_system 'git', 'checkout', '-B', default_branch
|
||||
quiet_system 'git', 'add', '--all', '.'
|
||||
system 'git', 'commit', '-m', "#{f.name}-#{f.version}: default"
|
||||
|
||||
default_unchanged = quiet_system('git', 'diff', '--exit-code', \
|
||||
previous_default_branch)
|
||||
|
||||
if default_unchanged
|
||||
system 'git', 'reset', '--hard', previous_default_branch
|
||||
end
|
||||
|
||||
quiet_system 'git', 'checkout', 'master'
|
||||
quiet_system 'git', 'reset', '--hard', preinstall_branch
|
||||
|
||||
unless default_unchanged
|
||||
merge_ff = quiet_system 'git', 'merge', '--ff-only', '--no-edit',
|
||||
'-X', 'ours', default_branch
|
||||
unless merge_ff
|
||||
merged = true
|
||||
system 'git', 'merge', '--no-ff', '--no-edit',
|
||||
'-X', 'ours', default_branch
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if merged
|
||||
ohai "Configuration Files"
|
||||
puts "Your configuration files for #{f.name} in etc were merged:"
|
||||
puts "To reverse this merge: git reset --hard #{preinstall_branch}"
|
||||
puts "To restore defaults: git reset --hard #{default_branch}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def build_bottle_preinstall
|
||||
@etc_var_glob ||= "#{HOMEBREW_PREFIX}/{etc,var}/**/*"
|
||||
@etc_var_preinstall = Dir[@etc_var_glob]
|
||||
@ -183,8 +113,6 @@ class FormulaInstaller
|
||||
|
||||
@@attempted << f
|
||||
|
||||
git_etc_preinstall if ENV['HOMEBREW_GIT_ETC']
|
||||
|
||||
@poured_bottle = false
|
||||
|
||||
begin
|
||||
@ -221,8 +149,6 @@ class FormulaInstaller
|
||||
opoo "#{f.name} post_install failed. Rerun with `brew postinstall #{f.name}`."
|
||||
end
|
||||
|
||||
git_etc_postinstall if ENV['HOMEBREW_GIT_ETC']
|
||||
|
||||
opoo "Nothing was installed to #{f.prefix}" unless f.installed?
|
||||
end
|
||||
|
||||
|
@ -15,7 +15,7 @@ module InstallRenamed
|
||||
private
|
||||
|
||||
def append_default_if_different src, dst
|
||||
if File.file? dst and !FileUtils.identical?(src, dst) and !ENV['HOMEBREW_GIT_ETC']
|
||||
if File.file? dst and !FileUtils.identical?(src, dst)
|
||||
dst += ".default"
|
||||
end
|
||||
dst
|
||||
|
Loading…
x
Reference in New Issue
Block a user