minor refactor

This commit is contained in:
sxyazi 2025-01-10 16:21:36 +08:00
parent 3193a40a95
commit ebc9e9674f
No known key found for this signature in database
3 changed files with 6 additions and 8 deletions

View file

@ -73,7 +73,7 @@ impl FromStr for Dependency {
use_: s.to_owned(),
name: format!("{name}.yazi"),
parent: format!("{parent}{}", if child.is_empty() { ".yazi" } else { "" }),
child: child.to_owned(),
child: if child.is_empty() { String::new() } else { format!("{child}.yazi") },
..Default::default()
})
}

View file

@ -9,11 +9,7 @@ use super::Dependency;
impl Dependency {
pub(super) async fn deploy(&mut self) -> Result<()> {
let from = if self.child.is_empty() {
self.local().join(&self.child)
} else {
self.local().join(format!("{}.yazi", self.child))
};
let from = self.local().join(&self.child);
self.header("Deploying package `{name}`")?;
self.is_flavor = maybe_exists(&from.join("flavor.toml")).await;

View file

@ -43,8 +43,10 @@ impl Git {
}
async fn exec(f: impl FnOnce(&mut Command) -> &mut Command) -> Result<()> {
let status =
f(&mut Command::new("git")).status().await.context("Failed to execute `git` command")?;
let status = f(Command::new("git").args(["-c", "advice.detachedHead=false"]))
.status()
.await
.context("Failed to execute `git` command")?;
if !status.success() {
bail!("`git` command failed: {status}");