Class: MultiRepo::DoCommand
- Inherits:
-
Command
- Object
- CLAide::Command
- Command
- MultiRepo::DoCommand
show all
- Defined in:
- lib/multirepo/commands/do-command.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Command
#ensure_in_work_tree, #ensure_multirepo_enabled, #ensure_multirepo_tracked, #install_hooks, #multirepo_enabled_dependencies, report_error, #uninstall_hooks, #update_gitconfig
Constructor Details
#initialize(argv) ⇒ DoCommand
Returns a new instance of DoCommand.
24
25
26
27
28
|
# File 'lib/multirepo/commands/do-command.rb', line 24
def initialize(argv)
@operation = argv.remainder!.join(" ")
@repo_selection = RepoSelection.new(argv)
super
end
|
Class Method Details
.options ⇒ Object
15
16
17
18
19
20
21
22
|
# File 'lib/multirepo/commands/do-command.rb', line 15
def self.options
[
['"<operation>"', 'The git command to perform, between quotes, omitting the executable name (ex: "reset --hard HEAD")'],
['[--main]', 'Perform the operation in the main repository only.'],
['[--deps]', 'Perform the operation in dependencies only.'],
['[--all]', 'Perform the operation in the main repository and all dependencies.']
].concat(super)
end
|
Instance Method Details
#confirm_dependencies_operation ⇒ Object
84
85
86
87
88
89
|
# File 'lib/multirepo/commands/do-command.rb', line 84
def confirm_dependencies_operation
unless dependencies_clean?
Console.log_warning("Some dependencies contain uncommitted changes")
fail MultiRepoException, "Aborted" unless Console.ask("Proceed anyway?")
end
end
|
#confirm_main_repo_operation ⇒ Object
77
78
79
80
81
82
|
# File 'lib/multirepo/commands/do-command.rb', line 77
def confirm_main_repo_operation
unless main_repo_clean?
Console.log_warning("Main repo contains uncommitted changes")
fail MultiRepoException, "Aborted" unless Console.ask("Proceed anyway?")
end
end
|
#dependencies_clean? ⇒ Boolean
#main_repo_clean? ⇒ Boolean
91
92
93
|
# File 'lib/multirepo/commands/do-command.rb', line 91
def main_repo_clean?
Repo.new(".").clean?
end
|
63
64
65
66
67
68
69
|
# File 'lib/multirepo/commands/do-command.rb', line 63
def perform_operation_on_dependencies(operation)
success = true
Performer.depth_ordered_dependencies.each do |dependency|
success &= perform_operation(dependency.config_entry.repo.path, operation)
end
return success
end
|
#perform_operation_on_main(operation) ⇒ Object
59
60
61
|
# File 'lib/multirepo/commands/do-command.rb', line 59
def perform_operation_on_main(operation)
perform_operation(".", operation)
end
|
#run ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/multirepo/commands/do-command.rb', line 35
def run
ensure_in_work_tree
ensure_multirepo_enabled
@operation = @operation.sub(/^git /, "")
success = true
case @repo_selection.value
when RepoSelection::MAIN
confirm_main_repo_operation
success &= perform_operation_on_main(@operation)
when RepoSelection::DEPS
confirm_dependencies_operation
success &= perform_operation_on_dependencies(@operation)
when RepoSelection::ALL
confirm_main_repo_operation
confirm_dependencies_operation
success &= perform_operation_on_dependencies(@operation) success &= perform_operation_on_main(@operation) end
Console.log_warning("Some operations finished with non-zero exit status. Please review the above.") unless success
end
|
#validate! ⇒ Object
30
31
32
33
|
# File 'lib/multirepo/commands/do-command.rb', line 30
def validate!
help! "You must provide a git operation to perform" unless @operation
help! "You can't provide more than one operation modifier (--deps, --main, etc.)" unless @repo_selection.valid?
end
|