aboutsummaryrefslogtreecommitdiff
path: root/src/workspace.rs
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-05-09 21:57:26 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-05-09 21:57:26 +0300
commit819a71ea7a939e45234648c6ee09aa3bcaa6ff77 (patch)
tree49013b4736d9569a4e7c4e3ae2fa3c95cdad0299 /src/workspace.rs
parentd984ab2a3cb4b24788e24b3aaba24adea38b510f (diff)
fix: refresh git status off the main loop
fixes #85
Diffstat (limited to 'src/workspace.rs')
-rw-r--r--src/workspace.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/workspace.rs b/src/workspace.rs
index f9fb0493..e0513f65 100644
--- a/src/workspace.rs
+++ b/src/workspace.rs
@@ -24,6 +24,14 @@ pub use self::{
tab::Tab,
};
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct WorkspaceGitStatus {
+ pub workspace_id: String,
+ pub resolved_identity_cwd: PathBuf,
+ pub branch: Option<String>,
+ pub ahead_behind: Option<(usize, usize)>,
+}
+
static NEXT_WORKSPACE_ID: AtomicU64 = AtomicU64::new(1);
pub(crate) fn generate_workspace_id() -> String {
@@ -362,12 +370,30 @@ impl Workspace {
self.cached_git_ahead_behind
}
+ pub fn refresh_git_branch(&mut self) {
+ let cwd = self.resolved_identity_cwd();
+ self.cached_git_branch = cwd.as_deref().and_then(git_branch);
+ }
+
+ #[cfg(test)]
pub fn refresh_git_ahead_behind(&mut self) {
let cwd = self.resolved_identity_cwd();
self.cached_git_branch = cwd.as_deref().and_then(git_branch);
self.cached_git_ahead_behind = cwd.as_deref().and_then(git_ahead_behind);
}
+ pub fn git_status_for_cwd(
+ workspace_id: String,
+ resolved_identity_cwd: PathBuf,
+ ) -> WorkspaceGitStatus {
+ WorkspaceGitStatus {
+ branch: git_branch(&resolved_identity_cwd),
+ ahead_behind: git_ahead_behind(&resolved_identity_cwd),
+ workspace_id,
+ resolved_identity_cwd,
+ }
+ }
+
pub fn focused_runtime(&self) -> Option<&PaneRuntime> {
self.active_tab().and_then(Tab::focused_runtime)
}