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

chore: suggest git upgrade #5472

Merged
merged 5 commits into from
Jul 10, 2023
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
17 changes: 13 additions & 4 deletions crates/turborepo-scm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ pub enum Error {
control"
)]
GitRequired(AbsoluteSystemPathBuf),
#[error(
"git command failed due to unsupported git version. Upgrade to git 2.18 or newer: {0}"
)]
GitVersion(String),
#[error("io error: {0}")]
Io(#[from] std::io::Error, #[backtrace] backtrace::Backtrace),
#[error("path error: {0}")]
Expand Down Expand Up @@ -92,6 +96,9 @@ pub(crate) fn wait_for_success<R: Read, T>(
let stderr_text = stderr_output
.map(|stderr| format!(" stderr: {}", stderr))
.unwrap_or_default();
if matches!(exit_status.code(), Some(129)) {
return Err(Error::GitVersion(stderr_text));
}
let exit_text = if exit_status.success() {
"".to_string()
} else {
Expand Down Expand Up @@ -134,10 +141,12 @@ impl Git {
// If which produces an invalid absolute path, it's not an execution error, it's
// a programming error. We expect it to always give us an absolute path
// if it gives us any path. If that's not the case, we should crash.
let bin = AbsoluteSystemPathBuf::try_from(bin.as_path()).expect(&format!(
"which git produced an invalid absolute path {}",
bin.display()
));
let bin = AbsoluteSystemPathBuf::try_from(bin.as_path()).unwrap_or_else(|_| {
panic!(
"which git produced an invalid absolute path {}",
bin.display()
)
});
let root =
find_git_root(path_in_repo).map_err(|e| GitError::Root(path_in_repo.to_owned(), e))?;
Ok(Self { root, bin })
Expand Down