From a0615aeeac0ab61b643ced163d170a5f964bcb90 Mon Sep 17 00:00:00 2001 From: Daniel Scherzer Date: Sat, 18 Apr 2026 20:26:47 -0700 Subject: [PATCH] src/main.rs: expand documentation, part 3 Add documentation for - `get_versions()` function - `up_to_release()` function - `generate_thanks()` function - `run()` function - `main()` function - `get_submodules()` function Also includes some TODO notes on improving performance --- src/main.rs | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/src/main.rs b/src/main.rs index 7de94877..b941cd5d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -248,6 +248,18 @@ impl fmt::Debug for VersionTag { } } +/// Identify the versions that have been tagged in the given repo. +/// +/// A [`VersionTag`] is created for each tagged commit in the given repository +/// where either +/// * the name of the tag can be parsed with [`Version::parse()`] +/// * the name of the tag, followed by ".0", can be parsed with +/// [`Version::parse()`] +/// +/// The values of [`VersionTag::version`] are the results of the successful +/// [`Version::parse()`] calls (i.e. they might include extra ".0"s not in the +/// tag names). Each of the returned version tags has the +/// [`in_progress`][VersionTag::in_progress] field as `false`. fn get_versions(repo: &Repository) -> Result, Box> { let tags = repo .tag_names(None)? @@ -561,6 +573,16 @@ fn mailmap_from_repo(repo: &git2::Repository) -> Result Result, Box> { let path = update_repo("https://github.com/rust-lang/rust.git")?; let repo = git2::Repository::open(&path)?; @@ -680,9 +713,22 @@ fn generate_thanks() -> Result, Box Result<(), Box> { let by_version = generate_thanks()?; + // TODO: this currently just adds up the AuthorMap instances for each + // version - since those were created by subtracted older versions from + // newer ones, we should already have a full AuthorMap for all time already + // created in generate_thanks(). We should use that instead. + // Though, if up_to_release() is refactored to account for commits in the + // previous release then that will no longer be an option. let mut all_time = by_version.values().next().unwrap().clone(); for map in by_version.values().skip(1) { all_time.extend(map.clone()); @@ -693,6 +739,7 @@ fn run() -> Result<(), Box> { Ok(()) } +/// Generate thanks information via [`run()`] but with error handling fn main() { if let Err(err) = run() { eprintln!("Error: {}", err); @@ -715,6 +762,17 @@ struct Submodule { repository: String, } +/// Identify the submodules present in a repository as-of the given commit. +/// +/// The actual submodules are identified based on [`modules_file()`]. These +/// are then filtered to only include submodules where the source URL includes +/// "rust-lang" or "rust-lang-nursery", and also filtered to excluded a few +/// specific repositories. +/// +/// The returned [`Submodule`] objects include not only the repository the +/// submodule was cloned from, but also the commit *of the submodule* present +/// in the primary repository *as of the given commit*. This information is +/// used to include thanks information for contributions to submodules. fn get_submodules( repo: &Repository, at: &Commit,