docs(comments): rewrite comments across all crates to the guidelines
Sweep every first-party crate source (1956 .rs files) to the project comment guidelines: delete redundant restatements, decorative banners, change narration, and end-of-line comments; keep and tighten the crucial ones (invariants, bug rationale, SAFETY blocks, ported-source attribution). No functional code changed. Every edit is proven comment-only against the prior tree by a comment-stripping lexer (string/char/raw-string aware) plus a separate doctest-fence check. Where removing a comment made rustfmt or clippy want to re-lay-out adjacent code, the minimal triggering comment is restored so code tokens stay byte-identical. Gates green: cargo fmt --all --check (0 diffs), cargo check and cargo clippy --workspace --all-targets (0 warnings). Adds scripts/check_codegen_comment_guidelines.py — the enforcement gate for these guidelines (flags banners, end-of-line comments, change narration, and commented-out code).
This commit is contained in:
1 parent
ff0fb56c67
commit
a02b555e66
1458 files changed
+10729
-21750
No files matched your search
@@ -277,7 +277,6 @@ fn execute_create_worktree_dispatch(plan: WorktreePlan) -> Result<CreateWorktree
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Try BTRFS snapshot (O(1), no file copies)
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
match try_btrfs_worktree(&plan) {
|
||||
@@ -293,7 +292,6 @@ fn execute_create_worktree_dispatch(plan: WorktreePlan) -> Result<CreateWorktree
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Fall back to file-by-file copy
|
||||
#[cfg(target_os = "linux")]
|
||||
if !skipped_reasons.is_empty() {
|
||||
tracing::info!(
|
||||
@@ -502,8 +500,10 @@ fn execute_overlay_worktree(
|
||||
Ok(CreateWorktreeResult {
|
||||
worktree_path: plan.dest,
|
||||
commit,
|
||||
copy_stats: CopyStats::default(), // 0 files copied!
|
||||
ignored_stats: None, // overlay includes everything
|
||||
// 0 files copied!
|
||||
copy_stats: CopyStats::default(),
|
||||
// overlay includes everything
|
||||
ignored_stats: None,
|
||||
dirty_files_report: None,
|
||||
})
|
||||
}
|
||||
@@ -760,9 +760,12 @@ fn execute_btrfs_worktree(
|
||||
Ok(CreateWorktreeResult {
|
||||
worktree_path: plan.dest,
|
||||
commit,
|
||||
copy_stats: CopyStats::default(), // No files copied - instant snapshot!
|
||||
ignored_stats: None, // Snapshot includes everything
|
||||
dirty_files_report: None, // Not tracked for BTRFS snapshots
|
||||
// No files copied - instant snapshot!
|
||||
copy_stats: CopyStats::default(),
|
||||
// Snapshot includes everything
|
||||
ignored_stats: None,
|
||||
// Not tracked for BTRFS snapshots
|
||||
dirty_files_report: None,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -897,7 +900,8 @@ fn execute_copy_worktree(plan: WorktreePlan) -> Result<CreateWorktreeResult> {
|
||||
num_workers: effective_ignored_parallelism,
|
||||
channel_buffer,
|
||||
skip_files: Some(Arc::new(already_copied)),
|
||||
respect_gitignore: false, // We want all files.
|
||||
// We want all files.
|
||||
respect_gitignore: false,
|
||||
skip_patterns,
|
||||
};
|
||||
|
||||
|
||||
@@ -973,7 +973,7 @@ mod tests {
|
||||
let _ = std::fs::remove_dir_all(&repo_path);
|
||||
}
|
||||
|
||||
// ─── Standalone mode tests ───────────────────────────────────────────
|
||||
// Standalone mode tests
|
||||
|
||||
#[test]
|
||||
fn test_standalone_worktree_simple() {
|
||||
@@ -1218,7 +1218,7 @@ mod tests {
|
||||
assert!(result.ignored_copy.is_some());
|
||||
}
|
||||
|
||||
// ─── Cancellation / partial-creation cleanup tests ───────────────────
|
||||
// Cancellation / partial-creation cleanup tests
|
||||
|
||||
#[test]
|
||||
fn test_linked_cancel_after_worktree_add_deregisters() {
|
||||
@@ -1307,7 +1307,8 @@ mod tests {
|
||||
let result = WorktreeBuilder::new(repo_path.clone(), dest.clone())
|
||||
.creation_mode(CreationMode::Linked)
|
||||
.ignored_files_mode(IgnoredFilesMode::Copy {
|
||||
skip_patterns: vec!["[".to_string()], // invalid glob → build fails
|
||||
// invalid glob → build fails
|
||||
skip_patterns: vec!["[".to_string()],
|
||||
})
|
||||
.create();
|
||||
assert!(result.is_err(), "invalid skip glob must fail creation");
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//! Worktree execution planning.
|
||||
//!
|
||||
//! `WorktreePlan` makes the worktree creation pipeline explicit and testable.
|
||||
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
@@ -9,9 +7,10 @@ use tokio_util::sync::CancellationToken;
|
||||
|
||||
use crate::{BtrfsDelegate, CreationMode, IgnoredFilesMode, WorkingTreeMode};
|
||||
|
||||
// Debug cannot be derived: `Arc<dyn BtrfsDelegate>` is not Debug, so there is a
|
||||
// hand-written impl below.
|
||||
#[derive(Clone)]
|
||||
pub(crate) struct WorktreePlan {
|
||||
// Note: manual Debug impl below (Arc<dyn BtrfsDelegate> isn't Debug)
|
||||
pub source: PathBuf,
|
||||
pub dest: PathBuf,
|
||||
pub git_ref: String,
|
||||
@@ -20,13 +19,12 @@ pub(crate) struct WorktreePlan {
|
||||
pub working_tree: WorkingTreeMode,
|
||||
pub ignored_files: IgnoredFilesMode,
|
||||
pub ignored_parallelism: usize,
|
||||
/// Strategy for worktree creation (linked, standalone, or git checkout).
|
||||
pub creation_mode: CreationMode,
|
||||
/// Cancellation token for aborting file copy mid-flight.
|
||||
/// Aborts the file copy mid-flight.
|
||||
pub cancellation_token: CancellationToken,
|
||||
/// Optional delegate for privileged btrfs operations (used when the caller
|
||||
/// lacks CAP_SYS_ADMIN, e.g., inside a bwrap sandbox).
|
||||
/// Only read on Linux (in `try_btrfs_delegate`).
|
||||
/// Performs privileged btrfs operations when the caller lacks
|
||||
/// CAP_SYS_ADMIN, e.g. inside a bwrap sandbox. Only read on Linux, in
|
||||
/// `try_btrfs_delegate`, hence the `dead_code` allowance elsewhere.
|
||||
#[cfg_attr(not(target_os = "linux"), allow(dead_code))]
|
||||
pub btrfs_delegate: Option<Arc<dyn BtrfsDelegate>>,
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user