feat(cli): support user-defined templates for --init - #1583
feat(cli): support user-defined templates for --init#1583lazizbekravshanov wants to merge 1 commit into
Conversation
|
Thanks for opening this pull request! Please check out our contributing guidelines! ⛰️ |
|
Quick heads-up on the red "Test suite" check: the failure is in the Codecov upload step, not the tests. The uploader couldn't verify its own GPG signature ( |
|
Hi @orhun — gentle nudge on this one whenever you have a moment 🙂 It implements #412 (which you'd approved): Just to re-flag: the one red "Test suite" check is the Codecov upload step failing to verify its own GPG signature (a transient uploader/keyserver issue), not the tests — the actual test job and the other 107 checks are green. Happy to rebase, adjust the flag/UX, or split anything out if that helps review. No rush at all, and thanks for your time! |
|
Hi @orhun, following up on this one. It implements #412 (user-defined templates for |
Add `--templates-dir <PATH>` (env: GIT_CLIFF_TEMPLATES_DIR) so `--init` can look up user-defined templates, and `--list-templates` to print all available template names (built-in and user-defined) for shell/editor completion. A user template overrides a built-in template of the same name. Closes orhun#412
3e0fb4b to
84b587c
Compare
|
Closing this to clear my queue. The branch stays on my fork, so if you would still like the templates feature I am glad to reopen and rebase it whenever. |
Description
Adds support for user-defined
--inittemplates, alongside the existing built-in templates:--templates-dir <PATH>(env:GIT_CLIFF_TEMPLATES_DIR) — a directory of user.tomltemplates that--init <name>can use. A user template overrides a built-in template of the same name.--list-templates— prints all available template names (built-in + user-defined), one per line, sorted and deduplicated. This covers the completion use case from the issue.Behavior details:
--initbehavior is unchanged when no--templates-diris given.--templates-diris a clear error naming the offending path; non-.tomlfiles in the directory are ignored.--list-templatesprints and exits (like--init), and works outside a git repository.--body/--template) are unaffected — this only concerns the--initconfig presets.Motivation and Context
Closes #412. Users who keep their own
--inittemplate presets currently can't use them through git-cliff's built-in mechanism, and there was no way to enumerate the available templates (needed for shell/editor completion).How Has This Been Tested?
git-cliff-core(embed.rs): built-in listing (sorted, no extension); merging a user directory (ignoring non-.toml, deduped); user template overriding a built-in;.tomlextension normalization; and a clear error when the directory is missing.git-cliff(args.rs,lib.rs): parsing--templates-dir/--list-templates;init_configwriting the user template (and falling back to the built-in).cargo test(workspace): all green.cargo +nightly fmt --all -- --check: clean.cargo clippy --tests -- -D warnings: clean on the changed code. (Note: on my local toolchain — rustc 1.97.0 — clippy also reports one pre-existinguseless_borrows_in_formattinglint ingit-cliff-core/src/repo.rs, which is unrelated to this change and outside the diff.)--templates-dir; theGIT_CLIFF_TEMPLATES_DIRenv var;--init <name> --templates-dirwriting user content; the missing-directory error; and confirming both commands work outside a git repository.Types of Changes
Checklist:
cargo +nightly fmt --allcargo clippy --tests --verbose -- -D warningscargo test