load a local config file
This commit is contained in:
parent
67beb1dece
commit
0330206e55
@ -1,8 +1,15 @@
|
||||
require "open3"
|
||||
|
||||
module Svi
|
||||
class Application
|
||||
|
||||
def initialize
|
||||
@config = Config.new
|
||||
@svn_info = {}
|
||||
@config = Config.new(self)
|
||||
end
|
||||
|
||||
def wc_info
|
||||
svn_info(".")
|
||||
end
|
||||
|
||||
def checkout(url)
|
||||
@ -70,5 +77,20 @@ module Svi
|
||||
0
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def svn_info(path)
|
||||
@svn_info[path] ||= begin
|
||||
info = {}
|
||||
stdout, stderr, status = Open3.capture3("svn", "info", path)
|
||||
stdout.lines.each do |line|
|
||||
if line =~ /^(.*?):\s(.*)$/
|
||||
info[$1] = $2
|
||||
end
|
||||
end
|
||||
info
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -1,10 +1,12 @@
|
||||
module Svi
|
||||
class Config
|
||||
|
||||
def initialize
|
||||
def initialize(application)
|
||||
@application = application
|
||||
@ignores = []
|
||||
|
||||
load_global_config
|
||||
load_local_config
|
||||
end
|
||||
|
||||
# Get the ignore patterns.
|
||||
@ -31,5 +33,15 @@ module Svi
|
||||
end
|
||||
end
|
||||
|
||||
def load_local_config
|
||||
if wcrp = @application.wc_info["Working Copy Root Path"]
|
||||
local_config_path = "#{wcrp}/.svn/svi/config"
|
||||
if File.exists?(local_config_path)
|
||||
local_config = File.read(local_config_path)
|
||||
instance_eval(local_config, local_config_path, 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user