From e757979f1a2afdbe7146066345bb9acd19d3b151 Mon Sep 17 00:00:00 2001 From: aur-build Date: Thu, 19 Nov 2026 17:09:59 +0000 Subject: comments: say why, not what MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every module-level `//!` header is gone, and the comments that remained either re-explained the line below them or had grown into paragraphs. Density went from one comment line per 6.7 lines of code to one per 10. 827 insertions against 2194 deletions across 86 files. What survived: the invariants (I1-I12), the design cross-references into DESIGN.md, and the notes recording a bug that was found and fixed — those are the comments that carry weight, because they answer a question the code cannot answer about itself. What did not: restating a function signature in prose, and narration of the statement underneath. --- src/git.rs | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'src/git.rs') diff --git a/src/git.rs b/src/git.rs index 6c1f442..4520548 100644 --- a/src/git.rs +++ b/src/git.rs @@ -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 HEAD` — the cheap poll (§5.1). Returns the remote HEAD -/// SHA, or `None` when the remote is gone (deletion / orphan handling). +/// `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) => { @@ -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 { 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> { let out = git(Some(mirror), &["log", "--oneline", range])?; Ok(out.lines().map(|l| l.to_string()).collect()) -- cgit v1.2.3