From 4304b0f336ddba7b4ec6780795059ff2066d105b Mon Sep 17 00:00:00 2001 From: aur-build Date: Thu, 19 Nov 2026 17:33:17 +0000 Subject: comments: keep only what the code cannot show MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stripped every comment that described what an item does, documented its arguments or fields, or cited the design docs (§n, I-n, m-n, decision n). 2247 comments down to 83. What survives: the section dividers that segment the large modules, the secret-handling warnings, the agent wire-frame directions, and the few notes without which the code they attach to reads as redundant, reorderable, or unsound. --- src/git.rs | 24 ------------------------ 1 file changed, 24 deletions(-) (limited to 'src/git.rs') diff --git a/src/git.rs b/src/git.rs index 4520548..8605db7 100644 --- a/src/git.rs +++ b/src/git.rs @@ -3,14 +3,12 @@ use std::process::{Command, Output}; use crate::error::{Error, Result}; -/// Run git and capture output; non-zero status becomes `Error::Git`. pub fn git(cwd: Option<&Path>, args: &[&str]) -> Result { let mut cmd = Command::new("git"); if let Some(c) = cwd { cmd.current_dir(c); } cmd.args(args); - // Never let a stray terminal prompt hang a watcher thread. cmd.env("GIT_TERMINAL_PROMPT", "0"); cmd.env("GIT_CONFIG_NOSYSTEM", "1"); cmd.env("LC_ALL", "C"); @@ -29,13 +27,10 @@ fn ok(out: Output, args: &[&str]) -> Result { Ok(String::from_utf8_lossy(&out.stdout).to_string()) } -/// Run git, discarding output, returning success/failure without allocating. pub fn git_ok(cwd: Option<&Path>, args: &[&str]) -> bool { git(cwd, args).is_ok() } -/// `git ls-remote HEAD` — the cheap poll (§5.1). `None` when the remote is -/// gone. pub fn ls_remote_head(url: &str) -> Result> { match git(None, &["ls-remote", url, "HEAD"]) { Ok(out) => { @@ -51,7 +46,6 @@ pub fn ls_remote_head(url: &str) -> Result> { } } -/// `ls-remote --heads `: every branch tip, as `(refname, sha)`. pub fn ls_remote_heads(url: &str) -> Result> { let out = git(None, &["ls-remote", "--heads", url])?; let mut v = Vec::new(); @@ -64,7 +58,6 @@ pub fn ls_remote_heads(url: &str) -> Result> { Ok(v) } -/// Ask a single remote ref for its SHA, e.g. `refs/tags/v1.2` or a full commit. pub fn ls_remote_ref(url: &str, refname: &str) -> Result> { match git(None, &["ls-remote", url, refname]) { Ok(out) => Ok(out @@ -85,9 +78,6 @@ fn is_missing_remote(e: &Error) -> bool { || s.contains("404") } -/// 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(()); @@ -99,7 +89,6 @@ pub fn clone(url: &str, dest: &Path) -> Result<()> { Ok(()) } -/// `git clone --bare` for the upstream VCS cache. pub fn clone_bare(url: &str, dest: &Path) -> Result<()> { if dest.exists() { return Ok(()); @@ -114,9 +103,7 @@ pub fn clone_bare(url: &str, dest: &Path) -> Result<()> { Ok(()) } -/// Fetch into an existing mirror. Returns the new HEAD. pub fn fetch_head(mirror: &Path) -> Result { - // `--no-prune` mirrors the "never GC a commit we may need" rule (§5.1a). git(Some(mirror), &["fetch", "--quiet", "--no-prune", "origin"])?; head(mirror) } @@ -125,18 +112,14 @@ pub fn head(mirror: &Path) -> Result { 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). pub fn has_commit(mirror: &Path, commit: &str) -> bool { git_ok(Some(mirror), &["cat-file", "-e", &format!("{commit}^{{commit}}")]) } -/// `git ls-tree -r `: every `(path, blob-sha)` in the tree. pub fn ls_tree(mirror: &Path, commit: &str) -> Result> { let out = git(Some(mirror), &["ls-tree", "-r", commit])?; let mut v = Vec::new(); for line in out.lines() { - // " blob \t" if let Some(rest) = line.strip_prefix("100644 blob ").or_else(|| line.strip_prefix("100755 blob ")) { if let Some((sha, path)) = rest.split_once('\t') { v.push((path.to_string(), sha.to_string())); @@ -161,8 +144,6 @@ pub fn read_blob(mirror: &Path, commit: &str, path: &str) -> Result> { Ok(out.stdout) } -/// Materialize a commit into `dest` using the local mirror only — no network -/// (§8.1 step 0). `git archive` + tar keeps it dependency-free. pub fn materialize(mirror: &Path, commit: &str, dest: &Path) -> Result<()> { std::fs::create_dir_all(dest)?; let out = Command::new("git") @@ -185,26 +166,22 @@ pub fn materialize(mirror: &Path, commit: &str, dest: &Path) -> Result<()> { Ok(()) } -/// `git log --oneline range` — review context (§5.1) and the upstream delta panel. pub fn log_oneline(mirror: &Path, range: &str) -> Result> { let out = git(Some(mirror), &["log", "--oneline", range])?; Ok(out.lines().map(|l| l.to_string()).collect()) } -/// `git diff range -- `; empty `paths` means everything. pub fn diff(mirror: &Path, range: &str, paths: &[&str]) -> Result { let mut args: Vec<&str> = vec!["diff", "--no-color", range, "--"]; args.extend(paths); git(Some(mirror), &args) } -/// `git rev-list --count range`. pub fn count_commits(mirror: &Path, range: &str) -> Result { let out = git(Some(mirror), &["rev-list", "--count", range])?; Ok(out.trim().parse().unwrap_or(0)) } -/// Clone a VCS source the way a PKGBUILD would (depth/ref aware) into `dest`. pub fn clone_source(url: &str, dest: &Path, depth: Option, branch: Option<&str>) -> Result<()> { if let Some(parent) = dest.parent() { std::fs::create_dir_all(parent)?; @@ -223,7 +200,6 @@ pub fn clone_source(url: &str, dest: &Path, depth: Option, branch: Option Ok(()) } -/// Fetch into an existing clone and return HEAD. pub fn fetch_and_head(repo: &Path) -> Result { git(Some(repo), &["fetch", "--quiet", "--no-prune", "origin"])?; head(repo) -- cgit v1.2.3