diff options
Diffstat (limited to 'src/git.rs')
| -rw-r--r-- | src/git.rs | 24 |
1 files changed, 8 insertions, 16 deletions
@@ -1,9 +1,3 @@ -//! Shelling out to `git` (DESIGN.md §4: "shell out to git ... avoids libgit2 -//! build pain"). -//! -//! Every git operation the system performs goes through here so the subprocess -//! surface is auditable in one place. - use std::path::Path; use std::process::{Command, Output}; @@ -40,8 +34,8 @@ pub fn git_ok(cwd: Option<&Path>, args: &[&str]) -> bool { git(cwd, args).is_ok() } -/// `git ls-remote <url> HEAD` — the cheap poll (§5.1). Returns the remote HEAD -/// SHA, or `None` when the remote is gone (deletion / orphan handling). +/// `git ls-remote <url> HEAD` — the cheap poll (§5.1). `None` when the remote is +/// gone. pub fn ls_remote_head(url: &str) -> Result<Option<String>> { match git(None, &["ls-remote", url, "HEAD"]) { Ok(out) => { @@ -91,10 +85,9 @@ fn is_missing_remote(e: &Error) -> bool { || s.contains("404") } -/// Clone an AUR mirror. `--mirror` so that `git fetch` actually moves our refs -/// (a plain clone would leave HEAD on the original commit), and **never** -/// `--filter=blob:none`: a partial clone can lazily drop blobs and we must be -/// able to materialize any historical commit forever (§5.1). +/// Clone an AUR mirror. `--mirror` so that `git fetch` actually moves our refs, +/// and **never** `--filter=blob:none`: a partial clone can lazily drop blobs and +/// we must be able to materialize any historical commit forever (§5.1). pub fn clone(url: &str, dest: &Path) -> Result<()> { if dest.exists() { return Ok(()); @@ -132,8 +125,8 @@ pub fn head(mirror: &Path) -> Result<String> { Ok(git(Some(mirror), &["rev-parse", "HEAD"])?.trim().to_string()) } -/// True if `commit` exists in the local mirror. Guards against a force-pushed -/// AUR history making a pin vanish (§16 mirror divergence). +/// True if `commit` exists in the local mirror. Guards against a force-pushed AUR +/// history making a pin vanish (§16 mirror divergence). pub fn has_commit(mirror: &Path, commit: &str) -> bool { git_ok(Some(mirror), &["cat-file", "-e", &format!("{commit}^{{commit}}")]) } @@ -192,8 +185,7 @@ pub fn materialize(mirror: &Path, commit: &str, dest: &Path) -> Result<()> { Ok(()) } -/// `git log --oneline range` — review context (§5.1) and the upstream delta -/// panel (§6). +/// `git log --oneline range` — review context (§5.1) and the upstream delta panel. pub fn log_oneline(mirror: &Path, range: &str) -> Result<Vec<String>> { let out = git(Some(mirror), &["log", "--oneline", range])?; Ok(out.lines().map(|l| l.to_string()).collect()) |
