feat(changelog): warn when template uses remote variables without matching feature#1545
Open
arieleli01212 wants to merge 3 commits into
Open
feat(changelog): warn when template uses remote variables without matching feature#1545arieleli01212 wants to merge 3 commits into
arieleli01212 wants to merge 3 commits into
Conversation
…ching feature When a user's template references variables like `github.contributors` or `commit.gitlab` but the binary was compiled without the corresponding feature flag (`github`, `gitlab`, etc.), the rendering silently produces empty output with no indication of why. Add a `warn_if_remote_template_variables_without_feature` check in `Changelog::build` that emits a `tracing::warn` for each remote whose template variables are present but whose Cargo feature is absent. Fixes orhun#659
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1545 +/- ##
==========================================
- Coverage 48.65% 48.65% -0.00%
==========================================
Files 26 26
Lines 2288 2284 -4
==========================================
- Hits 1113 1111 -2
+ Misses 1175 1173 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…abled The warn_if_remote_template_variables_without_feature function declared a `templates` Vec that was only accessed inside cfg-gated blocks. When all remote features are compiled in (the default build), every `#[cfg(not(feature = "..."))]` condition is false, so `templates` is never read — triggering an unused-variable error under `-D warnings`. Restructure: move the templates array construction inline inside each macro expansion. Each branch is self-contained and only compiled when the corresponding feature is absent, so there is no unused variable in any build configuration.
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.
Fixes #659.
Problem
When a template references variables like
github.contributorsorcommit.gitlabbut the binary was compiled without the corresponding feature flag, the output is silently empty — no error, no warning, just missing data. This is confusing because the template looks correct but produces nothing for those fields.Solution
Added a
warn_if_remote_template_variables_without_featurefunction that is called fromChangelog::build. It checks each template (header, body, footer) for remote-specific variable names and emits atracing::warnwhen the relevant Cargo feature is absent.The check uses the existing
Template::contains_variablemethod and is gated with#[cfg(not(feature = "..."))]so there is zero overhead when the feature is enabled.All five remotes are covered:
github,gitlab,gitea,bitbucket,azure_devops.