From 84193de4889d2c87305e184b51d52ef4b2c10164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Katona?= Date: Mon, 29 Aug 2022 09:18:26 +0200 Subject: [PATCH] fix profile ops, fully fixes #4 --- src/vcs.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/vcs.rs b/src/vcs.rs index f019154..280071d 100644 --- a/src/vcs.rs +++ b/src/vcs.rs @@ -326,9 +326,12 @@ impl Vcs { } } - let current_ref = project.repo.current_ref()?; // stash changes before moving project off to a new ref - let stashed_changes = project.repo.stash_changes(¤t_ref)?; + let stashed_changes = if let Some(current_ref) = project.current_ref()? { + project.repo.stash_changes(¤t_ref)? + } else { + false + }; // try to switch to new ref using provided setter let new_ref = match setter(project) { @@ -371,8 +374,9 @@ impl Vcs { let mut table = Table::new(); for project in &self.projects { - let head_ref_name = project.repo.current_ref()?; - table.insert(project.name().into(), Value::String(head_ref_name)); + if let Some(head_ref_name) = project.current_ref()? { + table.insert(project.name().into(), Value::String(head_ref_name)); + } } Ok(Value::Table(table))