mirror of
https://github.com/qwjyh/xdbm
synced 2024-11-22 14:50:12 +09:00
23 lines
675 B
Rust
23 lines
675 B
Rust
|
use std::path::PathBuf;
|
||
|
|
||
|
use anyhow::{anyhow, Result};
|
||
|
use git2::Repository;
|
||
|
|
||
|
pub(crate) fn cmd_sync(config_dir: &PathBuf, remote_name: Option<String>) -> Result<()> {
|
||
|
warn!("Experimental");
|
||
|
let repo = Repository::open(config_dir)?;
|
||
|
let remote_name = match remote_name {
|
||
|
Some(remote_name) => remote_name,
|
||
|
None => {
|
||
|
let remotes = repo.remotes()?;
|
||
|
if remotes.len() != 1 {
|
||
|
return Err(anyhow!("Please specify remote name"));
|
||
|
}
|
||
|
remotes.get(0).unwrap().to_string()
|
||
|
}
|
||
|
};
|
||
|
let mut remote = repo.find_remote(&remote_name)?;
|
||
|
remote.push(&[] as &[&str], None)?;
|
||
|
Ok(())
|
||
|
}
|