ok/jj
1
0
Fork 0
forked from mirrors/jj

cli: move cmd_git() dispatcher function next to GitCommand enum

This commit is contained in:
Yuya Nishihara 2024-06-19 20:11:46 +09:00
parent e5a3d6a2ba
commit 567f0db734

View file

@ -55,6 +55,23 @@ pub enum GitCommand {
Submodule(SubmoduleCommand),
}
pub fn cmd_git(
ui: &mut Ui,
command: &CommandHelper,
subcommand: &GitCommand,
) -> Result<(), CommandError> {
match subcommand {
GitCommand::Clone(args) => cmd_git_clone(ui, command, args),
GitCommand::Export(args) => cmd_git_export(ui, command, args),
GitCommand::Fetch(args) => cmd_git_fetch(ui, command, args),
GitCommand::Import(args) => cmd_git_import(ui, command, args),
GitCommand::Init(args) => cmd_git_init(ui, command, args),
GitCommand::Push(args) => cmd_git_push(ui, command, args),
GitCommand::Remote(args) => cmd_git_remote(ui, command, args),
GitCommand::Submodule(args) => cmd_git_submodule(ui, command, args),
}
}
fn map_git_error(err: git2::Error) -> CommandError {
if err.class() == git2::ErrorClass::Ssh {
let hint =
@ -95,20 +112,3 @@ fn get_single_remote(git_repo: &git2::Repository) -> Result<Option<String>, Comm
_ => None,
})
}
pub fn cmd_git(
ui: &mut Ui,
command: &CommandHelper,
subcommand: &GitCommand,
) -> Result<(), CommandError> {
match subcommand {
GitCommand::Clone(args) => cmd_git_clone(ui, command, args),
GitCommand::Export(args) => cmd_git_export(ui, command, args),
GitCommand::Fetch(args) => cmd_git_fetch(ui, command, args),
GitCommand::Import(args) => cmd_git_import(ui, command, args),
GitCommand::Init(args) => cmd_git_init(ui, command, args),
GitCommand::Push(args) => cmd_git_push(ui, command, args),
GitCommand::Remote(args) => cmd_git_remote(ui, command, args),
GitCommand::Submodule(args) => cmd_git_submodule(ui, command, args),
}
}