Class: MultiRepo::Command
- Inherits:
-
CLAide::Command
- Object
- CLAide::Command
- MultiRepo::Command
show all
- Defined in:
- lib/multirepo/commands/command.rb
Direct Known Subclasses
AddCommand, BranchCommand, CheckoutCommand, CloneCommand, DoCommand, InitCommand, InspectCommand, InstallCommand, MergeCommand, OpenCommand, RemoveCommand, UninitCommand, UpdateCommand
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(argv) ⇒ Command
Returns a new instance of Command.
24
25
26
27
28
29
30
|
# File 'lib/multirepo/commands/command.rb', line 24
def initialize(argv)
@argv = argv
Config.instance.verbose |= argv.flag?("verbose") ? true : false
Config.instance. ||= argv.option("extra-output")
Config.instance.git_executable ||= argv.option("git-exe", "git")
super
end
|
Class Method Details
.report_error(exception) ⇒ Object
16
17
18
19
20
21
22
|
# File 'lib/multirepo/commands/command.rb', line 16
def self.report_error(exception)
if exception.instance_of?(MultiRepoException)
Console.log_error(exception.message)
exit 1
end
fail exception
end
|
Instance Method Details
#ensure_in_work_tree ⇒ Object
70
71
72
73
74
|
# File 'lib/multirepo/commands/command.rb', line 70
def ensure_in_work_tree
repo = Repo.new(".")
fail MultiRepoException, "Not a git repository" unless repo.exists?
fail MultiRepoException, "HEAD is unborn (you must perform at least one commit)" unless repo.head_born?
end
|
#ensure_multirepo_enabled ⇒ Object
76
77
78
|
# File 'lib/multirepo/commands/command.rb', line 76
def ensure_multirepo_enabled
fail MultiRepoException, "multirepo is not initialized in this repository." unless Utils.multirepo_enabled?(".")
end
|
#ensure_multirepo_tracked ⇒ Object
#install_hooks(path) ⇒ Object
44
45
46
47
48
|
# File 'lib/multirepo/commands/command.rb', line 44
def install_hooks(path)
actual_path = path || "."
Utils.install_hook("pre-commit", actual_path)
Utils.install_hook("post-commit", actual_path)
end
|
#multirepo_enabled_dependencies ⇒ Object
#run ⇒ Object
32
33
34
|
# File 'lib/multirepo/commands/command.rb', line 32
def run
help!
end
|
#uninstall_hooks ⇒ Object
50
51
52
53
|
# File 'lib/multirepo/commands/command.rb', line 50
def uninstall_hooks
FileUtils.rm_f(".git/hooks/pre-commit")
FileUtils.rm_f(".git/hooks/post-commit")
end
|
#update_gitconfig(path) ⇒ Object
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/multirepo/commands/command.rb', line 55
def update_gitconfig(path)
actual_path = path || "."
resource_file = Utils.path_for_resource(".gitconfig")
target_file = File.join(actual_path, '.git/config')
template = File.read(resource_file)
first_template_line = template.lines.first
Utils.append_if_missing(target_file, Regexp.new(Regexp.quote(first_template_line)), template)
end
|
#validate! ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/multirepo/commands/command.rb', line 36
def validate!
super
path = Config.instance.git_executable
is_git_exe = path =~ /.*(git)|(git.exe)$/
file_exists = path == "git" || File.exist?(path)
help! "Invalid git executable '#{path}'" unless is_git_exe && file_exists
end
|