Class: SvnAuto::Externals
Constant Summary
Constants inherited
from Command
Command::VALID_SET_KEYS
Instance Method Summary
collapse
Methods inherited from Command
commands, force?, inherited, options, reset!
Instance Method Details
#info ⇒ Object
77
78
79
80
|
# File 'lib/svnauto/commands/externals.rb', line 77
def info
show_info_for(:locked)
show_info_for(:unlocked)
end
|
#lock ⇒ Object
83
84
85
86
87
|
# File 'lib/svnauto/commands/externals.rb', line 83
def lock
locking = @externals.unlocked.dup
@externals.lock
show_info_for(:locked, locking)
end
|
#run(project, args) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/svnauto/commands/externals.rb', line 60
def run (project, args)
@externals = SvnExternals.new(args, !opthash[:nonrecursive])
if opthash[:info]
info
elsif opthash[:lock] or opthash[:unlock]
if opthash[:lock] and opthash[:unlock]
raise "--lock and --unlock are mutually exclusive, you may only use one at a time"
end
uncommitted_check
lock if opthash[:lock]
unlock if opthash[:unlock]
end
end
|
#show_info_for(state, collection = nil) ⇒ Object
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
# File 'lib/svnauto/commands/externals.rb', line 97
def show_info_for (state, collection=nil)
title = 'unlocked'
color = :green
if state == :locked
title = ' locked'
color = :red
end
collection ||= @externals.send(state)
collection.each do |external|
status = Constants::TERMINAL.color(title, color) + ' '
status << Constants::TERMINAL.color(external.revision.rjust(6), :red) + ' '
status << Constants::TERMINAL.color(external.path, :green) + ' '
status << Constants::TERMINAL.color(external.url, :cyan)
Constants::TERMINAL.say(status)
end
end
|
#uncommitted_check ⇒ Object
make sure we can’t run if there are uncomitted changes
118
119
120
121
122
123
124
|
# File 'lib/svnauto/commands/externals.rb', line 118
def uncommitted_check
Svn.status do |line|
next if line.match(/^\s*X/) or line.match(/^\s*$/)
next if line.match(/^\s*Performing/)
raise "you have uncommitted changes, you must commit first: #{line}"
end
end
|
#unlock ⇒ Object
90
91
92
93
94
|
# File 'lib/svnauto/commands/externals.rb', line 90
def unlock
unlocking = @externals.locked.dup
@externals.unlock
show_info_for(:unlocked, unlocking)
end
|