module GitThin::Action
Public Class Methods
arguments()
click to toggle source
# File lib/git-thin/command/action.rb, line 11 def self.arguments [ CLAide::Argument.new('TYPE', false ) ] end
description(action)
click to toggle source
# File lib/git-thin/command/action.rb, line 8 def self.description(action) 'Consider thin strategy when performing a '+action+' action ' end
options()
click to toggle source
Calls superclass method
# File lib/git-thin/command/action.rb, line 20 def self.options [ ['--source_root', 'Specify the warehouse address manually if necessary.'], ].concat(super) end
summary(action)
click to toggle source
# File lib/git-thin/command/action.rb, line 16 def self.summary(action) 'Consider thin strategy when performing a '+action+' action ' end
Public Instance Methods
run()
click to toggle source
# File lib/git-thin/command/action.rb, line 94 def run old_config = '' run_shell "git -C #{@source_root} config --get lfs.fetchinclude",true ,!@verbose do|outs,errs,status| if status == 0 && outs.length > 0 old_config = outs[0].strip end end run_config shell_ret = 0 run_shell "git -C #{@source_root} #{@action} "+@argv_remainder.join(' '),true ,LOGPRUNE|LOGC do |outs,errs,status| shell_ret = status end if old_config.strip == '' run_shell 'git config --unset lfs.fetchinclude' ,true ,true else run_shell 'git config lfs.fetchinclude '+old_config ,true ,true end if shell_ret != 0 exit(shell_ret+100) end end
run_config()
click to toggle source
# File lib/git-thin/command/action.rb, line 74 def run_config values=[] for type in @types config = @configs[type] if type == ThinConfig::DEFAULT && !config run_shell 'git config -l',true ,true do |outs,errs,status| g_configs = ThinConfig.prase_config outs config = g_configs[ThinConfig::DEFAULT] end end if config value = config.getValue('lfs') values.push value logN "[thin] platform:#{type} lfs:#{value}\n\n",false end end run_shell 'git config lfs.fetchinclude '+values.join(',') ,true ,true return values end
setup(argv,action)
click to toggle source
# File lib/git-thin/command/action.rb, line 27 def setup(argv,action) @pwd = Dir.pwd @action = action @types = [] @configs = {} @source_root = argv.option('source_root') @verbose = argv.flag?('verbose',false ) if @verbose @verbose = LOGC|LOGN end if not @source_root run_shell 'git rev-parse --show-toplevel',false ,LOGNone do |out,err,status| if status == 0 && out.length > 0 @source_root = out[0].strip end end if !@source_root || !File.exist?(@source_root+'/.git') logE "git repository not found" exit 1 end else if @source_root[-1] == '/' @source_root = @source_root[0..-2 ] end end if !@source_root || !Dir.exist?(@source_root) @source_root = nil return end if FileTest.exist? @source_root+'/.thinconfig' run_shell "git config -lf #{@source_root}/.thinconfig",true ,LOGNone do |out,err,status| @configs = ThinConfig.prase_config out end end @types =ThinConfig.prase_type_config argv,@configs,@source_root,@pwd @argv_remainder = argv.remainder! end
source_root()
click to toggle source
# File lib/git-thin/command/action.rb, line 65 def source_root end
validate!()
click to toggle source
Calls superclass method
# File lib/git-thin/command/action.rb, line 69 def validate! super help! 'validate SOURCE_ROOT is required' unless @source_root end