Skip to content

Commit

Permalink
chore: check status
Browse files Browse the repository at this point in the history
  • Loading branch information
Miguel Ramos committed Oct 14, 2024
1 parent 0885ec6 commit 6833edd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 10 additions & 0 deletions crates/workspace_std/src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,16 @@ impl Repository {
execute_git(&self.location, ["status", "--porcelain"], |stdout, _| Ok(!stdout.is_empty()))
}

pub fn status(&self) -> GitResult<Option<String>> {
execute_git(&self.location, ["status", "--porcelain"], |stdout, _| {
if stdout.is_empty() {
Ok(None)
} else {
Ok(Some(stdout.to_string()))
}
})
}

pub fn get_current_branch(&self) -> GitResult<Option<String>> {
execute_git(&self.location, ["rev-parse", "--abbrev-ref", "HEAD"], |stdout, _| {
if stdout.is_empty() {
Expand Down
6 changes: 5 additions & 1 deletion crates/workspace_std/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,14 @@ mod tests {
let root = monorepo.get_monorepo_root().clone();
let js_path = root.join("packages/package-foo/index.mjs");
monorepo.create_workspace(&CorePackageManager::Pnpm)?;

let workspace = Workspace::new(root.clone());
let repo = Repository::new(root.as_path());

#[cfg(windows)]
let status = repo.status();
#[cfg(windows)]
dbg!(status);

let _ = repo.create_branch("feat/message");

let mut js_file = File::create(&js_path)?;
Expand Down

0 comments on commit 6833edd

Please sign in to comment.