Skip to content

Commit

Permalink
[Move] Check for git explicitly in resolution graph (aptos-labs#7585)
Browse files Browse the repository at this point in the history
  • Loading branch information
banool authored Apr 11, 2023
1 parent 6a103d1 commit 01ee6de
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,9 @@ impl ResolvingGraph {
git_url,
)?;

// Confirm git is available.
confirm_git_available()?;

// If the cached folder does not exist, download and clone accordingly
Command::new("git")
.args(["clone", git_url, git_path])
Expand All @@ -594,6 +597,9 @@ impl ResolvingGraph {
)
})?;
} else if !skip_fetch_latest_git_deps {
// Confirm git is available.
confirm_git_available()?;

// Update the git dependency
// Check first that it isn't a git rev (if it doesn't work, just continue with the fetch)
if let Ok(rev) = Command::new("git")
Expand Down Expand Up @@ -964,3 +970,22 @@ impl ResolvedPackage {
}
}
}

fn confirm_git_available() -> Result<()> {
match Command::new("git").arg("--version").output() {
Ok(_) => Ok(()),
Err(e) => {
if let std::io::ErrorKind::NotFound = e.kind() {
bail!(
"git was not found, confirm you have git installed and it is on your PATH. \
Alternatively, skip with --skip-fetch-latest-git-deps"
);
} else {
bail!(
"Unexpected error occured when checking for presence of `git`: {:#}",
e
);
}
},
}
}

0 comments on commit 01ee6de

Please sign in to comment.