Replace custom name generator with petname - #100
Draft
tupe12334 wants to merge 1 commit into
Draft
Conversation
src/name_gen.rs re-implemented Docker-style adjective_noun name generation by burning a UUID v4 just to index two hardcoded 20-word arrays (400 possible names, uneven distribution since 256 % 20 != 0). petname is the standard crate for exactly this use case: bigger curated word lists, proper RNG, actively maintained.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The custom code today
src/name_gen.rs:1-43(called fromsrc/multi_workspace.rs:37insidecreate_multi_workspace()):It hand-rolls a Docker/Heroku-style
adjective_nounrandom name for each new multi-repo workspace directory, burning a full UUID v4 just to get two random bytes as array indices. Only 20×20 = 400 possible names, and the distribution is uneven since 256 isn't evenly divisible by 20.Proposed library:
petname(docs.rs)Namer/petname()API instead of UUID-byte modulo.daemonsubcommand toscheme, removeinstallaction #3-ranked CLI-utility crate on lib.rs, 54 dependent crates. Latest release 3.1.0, actively maintained.What this PR does
petname = "3"toCargo.toml.name_gen::generate_name()on top ofpetname::petname(2, "_"), keeping the same function signature so the call site inmulti_workspace.rsneeds no change._, and non-degenerate distinctness across draws) instead of asserting against the old hardcoded word lists.uuidstays as a dependency — it's used elsewhere in the crate (hooks.rs,opener/*,issue/*) and isn't being removed.Before/after call site (
multi_workspace.rs:37, unchanged by this PR):Verified locally:
cargo buildsucceeds andcargo test --lib name_genpasses (2/2).Trade-offs
petname); dependency weight is modest sinceuuid'sv4feature already pulls in RNG machinery.name_gentests.Cargo.tomldeniesclippy::pedantic/nursery/cargoandmissing_docs— the new code keeps doc comments and avoids.expect()(usesunwrap_or_elseinstead, sinceexpect_usedis denied here) to satisfy those gates.cargo clippy --all-targetsgate in this environment — it fails on a pre-existing, unrelatedallow_attributes_without_reasonviolation insrc/issue/paths.rsthat predates this change. Worth a clean clippy run before merge.Checklist for whoever picks this up
cargo clippy --all-targets --all-featureson a clean checkout and confirm no new lint violations from this diffpetnameversion pin / feature flags (defaultdefault-rng+default-wordsused here)Cargo.lockupdate cleanly with any concurrent dependency changes