change(sync)!: now it use git cli by default

This commit is contained in:
qwjyh 2025-03-02 01:18:08 +09:00
parent 0412233f86
commit 63c6c397c3
4 changed files with 12 additions and 11 deletions

View file

@ -63,15 +63,15 @@ pub(crate) enum Commands {
Sync { Sync {
/// Remote name to sync. /// Remote name to sync.
remote_name: Option<String>, remote_name: Option<String>,
/// Use custom git implementation.
#[arg(short, long)]
use_libgit2: bool,
/// Whether to use ssh-agent /// Whether to use ssh-agent
#[arg(long)] #[arg(long)]
use_sshagent: bool, use_sshagent: bool,
/// Manually specify ssh key /// Manually specify ssh key
#[arg(long)] #[arg(long)]
ssh_key: Option<PathBuf>, ssh_key: Option<PathBuf>,
/// Use git command.
#[arg(short, long)]
use_cl: bool,
}, },
/// Check config files validity. /// Check config files validity.

View file

@ -12,12 +12,12 @@ pub(crate) fn cmd_sync(
remote_name: Option<String>, remote_name: Option<String>,
use_sshagent: bool, use_sshagent: bool,
ssh_key: Option<PathBuf>, ssh_key: Option<PathBuf>,
use_cl: bool, use_libgit2: bool,
) -> Result<()> { ) -> Result<()> {
if use_cl { if use_libgit2 {
cmd_sync_cl(config_dir, remote_name, ssh_key)
} else {
cmd_sync_custom(config_dir, remote_name, use_sshagent, ssh_key) cmd_sync_custom(config_dir, remote_name, use_sshagent, ssh_key)
} else {
cmd_sync_cl(config_dir, remote_name, ssh_key)
} }
} }

View file

@ -94,10 +94,10 @@ fn main() -> Result<()> {
} }
Commands::Sync { Commands::Sync {
remote_name, remote_name,
use_libgit2,
use_sshagent, use_sshagent,
ssh_key, ssh_key,
use_cl, } => cmd_sync::cmd_sync(&config_dir, remote_name, use_sshagent, ssh_key, use_libgit2)?,
} => cmd_sync::cmd_sync(&config_dir, remote_name, use_sshagent, ssh_key, use_cl)?,
Commands::Status { Commands::Status {
path, path,
storage, storage,

View file

@ -78,14 +78,14 @@ mod integrated_test {
Command::cargo_bin("xdbm")? Command::cargo_bin("xdbm")?
.arg("-c") .arg("-c")
.arg(config_dir) .arg(config_dir)
.args(["sync", "-vvvv", "-u"]) .args(["sync", "-vvvv"])
.assert() .assert()
.success(); .success();
} else { } else {
Command::cargo_bin("xdbm")? Command::cargo_bin("xdbm")?
.arg("-c") .arg("-c")
.arg(config_dir) .arg(config_dir)
.args(["sync", "-vvvv"]) .args(["sync", "-vvvv", "-u"])
.assert() .assert()
.success(); .success();
} }
@ -338,6 +338,7 @@ mod integrated_test {
.arg(config_dir_2.path()) .arg(config_dir_2.path())
.arg("sync") .arg("sync")
.arg("-vvvv") .arg("-vvvv")
.arg("-u")
.assert() .assert()
.success() .success()
.stderr(predicate::str::contains("successfully pushed")); .stderr(predicate::str::contains("successfully pushed"));