Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions apps/staged/src-tauri/src/session_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,24 +213,22 @@ pub fn resume_session(
.map(|note| note.project_id);

// If this session is linked to a commit, capture the current HEAD so we
// can detect amended commits when the session completes.
// can detect new or amended commits when the session completes.
// This applies both when the commit already has a SHA (amend case) and
// when it's still pending (no SHA — the previous run didn't produce a
// commit, so we need to detect if this resumed run does).
let (pre_head_sha, workspace_name) =
if let Ok(Some(commit)) = store.get_commit_by_session(&session_id) {
// Only bother if the commit already has a SHA (i.e. was previously completed).
if commit.sha.is_some() {
let branch = store.get_branch(&commit.branch_id).ok().flatten();
let ws_name = branch.as_ref().and_then(|b| b.workspace_name.clone());
let head = if let Some(ref ws) = ws_name {
crate::blox::ws_exec(ws, &["git", "rev-parse", "HEAD"])
.map(|s| s.trim().to_string())
.ok()
} else {
crate::git::get_head_sha(&working_dir).ok()
};
(head, ws_name)
let branch = store.get_branch(&commit.branch_id).ok().flatten();
let ws_name = branch.as_ref().and_then(|b| b.workspace_name.clone());
let head = if let Some(ref ws) = ws_name {
crate::blox::ws_exec(ws, &["git", "rev-parse", "HEAD"])
.map(|s| s.trim().to_string())
.ok()
} else {
(None, None)
}
crate::git::get_head_sha(&working_dir).ok()
};
(head, ws_name)
} else {
(None, None)
};
Expand Down