add Config class and initial status handler
This commit is contained in:
parent
f1ed0cb50f
commit
d9334aa224
17
lib/svi.rb
17
lib/svi.rb
@ -1,6 +1,8 @@
|
|||||||
require_relative "svi/ansi"
|
require_relative "svi/ansi"
|
||||||
require_relative "svi/cli"
|
require_relative "svi/cli"
|
||||||
|
require_relative "svi/config"
|
||||||
require_relative "svi/svn_runner"
|
require_relative "svi/svn_runner"
|
||||||
|
require_relative "svi/util"
|
||||||
require_relative "svi/version"
|
require_relative "svi/version"
|
||||||
require "svi/svi"
|
require "svi/svi"
|
||||||
|
|
||||||
@ -58,5 +60,20 @@ module Svi
|
|||||||
0
|
0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def status
|
||||||
|
config = Config.new
|
||||||
|
SvnRunner.run_svn("status", []) do |line|
|
||||||
|
if line =~ %r{^([ACDIMRX\?!~ ])[CM ][L ][\+ ][SX ][KOTB ]..(.+)$}
|
||||||
|
action, path = $1, $2
|
||||||
|
if action == "?" and Util.is_path_ignored?(path, config)
|
||||||
|
# Path is ignored
|
||||||
|
else
|
||||||
|
puts line
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
0
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -65,6 +65,12 @@ EOS
|
|||||||
Svi.checkout(url)
|
Svi.checkout(url)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def cmd_status(params)
|
||||||
|
options = {}
|
||||||
|
opts, args = Yawpa.parse(params, options, posix_order: true)
|
||||||
|
Svi.status
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
35
lib/svi/config.rb
Normal file
35
lib/svi/config.rb
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
module Svi
|
||||||
|
class Config
|
||||||
|
|
||||||
|
def initialize
|
||||||
|
@ignores = []
|
||||||
|
|
||||||
|
load_global_config
|
||||||
|
end
|
||||||
|
|
||||||
|
# Get the ignore patterns.
|
||||||
|
#
|
||||||
|
# @return [Array<String, Proc>]
|
||||||
|
# Each entry is a pattern or a Proc that returns a list of patterns.
|
||||||
|
def ignores
|
||||||
|
@_ignores ||= @ignores.map do |ignore|
|
||||||
|
if ignore.is_a?(Proc)
|
||||||
|
ignore[]
|
||||||
|
else
|
||||||
|
ignore
|
||||||
|
end
|
||||||
|
end.flatten
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def load_global_config
|
||||||
|
global_config_path = "#{ENV["HOME"]}/.svi/config"
|
||||||
|
if File.exists?(global_config_path)
|
||||||
|
global_config = File.read(global_config_path)
|
||||||
|
instance_eval(global_config, global_config_path, 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
15
lib/svi/util.rb
Normal file
15
lib/svi/util.rb
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
module Svi
|
||||||
|
module Util
|
||||||
|
|
||||||
|
class << self
|
||||||
|
|
||||||
|
def is_path_ignored?(path, config)
|
||||||
|
config.ignores.find do |ignore_pattern|
|
||||||
|
File.fnmatch(ignore_pattern, path, File::FNM_PATHNAME)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user