Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port all git functionality to use git CLI #3833

Merged
merged 6 commits into from
May 30, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
use exec_with_output instead of exec_with_streaming
  • Loading branch information
ibraheemdev committed May 30, 2024
commit 915d8d87a609f89c8d9b4c10d98e7813dd7c2898
22 changes: 8 additions & 14 deletions crates/uv-git/src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl GitRepository {
ProcessBuilder::new("git")
.arg("rev-parse")
.cwd(path)
.exec_with_streaming(&mut silent, &mut silent, true)?;
.exec_with_output()?;

Ok(GitRepository {
path: path.to_path_buf(),
Expand All @@ -168,7 +168,7 @@ impl GitRepository {
ProcessBuilder::new("git")
.arg("init")
.cwd(path)
.exec_with_streaming(&mut silent, &mut silent, true)?;
.exec_with_output()?;

Ok(GitRepository {
path: path.to_path_buf(),
Expand All @@ -181,7 +181,7 @@ impl GitRepository {
.arg("rev-parse")
.arg(refname)
.cwd(&self.path)
.exec_with_streaming(&mut silent, &mut silent, true)?;
.exec_with_output()?;

let mut result = String::from_utf8(result.stdout)?;
result.truncate(result.trim_end().len());
Expand Down Expand Up @@ -289,7 +289,7 @@ impl GitDatabase {
.arg("--short")
.arg(revision.as_str())
.cwd(&self.repo.path)
.exec_with_streaming(&mut silent, &mut silent, true)?;
.exec_with_output()?;

let mut result = String::from_utf8(output.stdout)?;
result.truncate(result.trim_end().len());
Expand Down Expand Up @@ -369,7 +369,7 @@ impl GitCheckout {
// have a HEAD checked out.
.arg(database.repo.path.simplified_display().to_string())
.arg(into.simplified_display().to_string())
.exec_with_streaming(&mut silent, &mut silent, true)?;
.exec_with_output()?;

let repo = GitRepository::open(into)?;
let checkout = GitCheckout::new(revision, repo);
Expand Down Expand Up @@ -412,7 +412,7 @@ impl GitCheckout {
.arg("--hard")
.arg(self.revision.as_str())
.cwd(&self.repo.path)
.exec_with_streaming(&mut silent, &mut silent, true)?;
.exec_with_output()?;

paths::create(ok_file)?;
Ok(())
Expand All @@ -426,7 +426,7 @@ impl GitCheckout {
.arg("--recursive")
.arg("--init")
.cwd(&self.repo.path)
.exec_with_streaming(&mut silent, &mut silent, true)
.exec_with_output()
.map(drop)
}
}
Expand Down Expand Up @@ -608,13 +608,7 @@ fn fetch_with_cli(
// We capture the output to avoid streaming it to the user's console during clones.
// The required `on...line` callbacks currently do nothing.
// The output appears to be included in error messages by default.
cmd.exec_with_streaming(&mut silent, &mut silent, true)?;
Ok(())
}

/// Callback used with `exec_with_streaming` that silences the output.
#[allow(clippy::unnecessary_wraps)]
fn silent(_: &str) -> Result<()> {
cmd.exec_with_output()?;
Ok(())
}

Expand Down
Loading