feat(commitlint): lint pull request titles - #66
Conversation
The action only lints commit ranges. commitlint reads a message on stdin only when --edit, --env, --from and --to are all omitted, so a title cannot be checked by setting an existing input: --to defaults to HEAD, and blanking it still routes to git history. Add a pr-title input that takes the title branch instead, bound through env so the title is never interpolated into the run body. Signed-off-by: Sai Tejas Janjur <sjanjur@nvidia.com>
|
All contributors have signed the DCO ✍️ ✅ |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review. 📝 WalkthroughWalkthroughThe commitlint action now accepts an optional pull request title. When provided, it lints the title through standard input and skips commit-range linting. The README documents this mode and its checkout-history requirements. ChangesCommitlint title linting
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Merge Risk: ⚪ Minimal · up to This change adds optional pull-request title linting while preserving existing commit-range behavior. No actionable merge-blocking risk remains after normal checks. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Comment |
|
I have read the DCO Document and I hereby sign the DCO |
Description
The commitlint action can only lint commit ranges. This adds a
pr-titleinput that lints a supplied pull request title instead.This cannot be expressed with the existing inputs. commitlint reads a message on stdin only when
--edit,--env,--fromand--toare all omitted, and the run step emits--to "$COMMITLINT_TO"unconditionally withtodefaulting toHEAD. Settingto: ''does not help either: the pipe is still discarded and git history is linted instead. So the title path is a separate branch that emits no range flags.A pull request title is attacker-controlled free text, so it is bound through the step-level
env:block and never interpolated into the run body.Compatibility
Callers that do not set
pr-titleare unaffected. The input defaults to'', the range path is untouched, and the pre-change and post-change step bodies produce identical output and exit codes across every existing input combination listed below.Validation
Both the pre-change and post-change
Run commitlintstep bodies were extracted from the parsedaction.ymland executed under the composite shell GitHub uses,bash --noprofile --norc -e -o pipefail, against@commitlint/cli@21.2.2:pr-titleset to a conventional title: exit 0, the title is lintedpr-titleset toAdd Some Feature: exit 1,subject-emptyandtype-emptypr-titlecontaining command substitution, backticks, quotes, semicolons and newlines: passed through as data, nothing executed and no file writtenpr-titleset whilefromis also set: the title is linted and the range is ignored-eandpipefailabort before the branch'sexit 0, so it cannot mask a failurepr-title, across no inputs,from,to,config-fileandfrom+to, in a normal clone, a shallow clone and an initial-commit repository: byte-identical output and exit codes before and after the changefixup!, bare-semver, acronym-leading, title-case and a 120-character header: exit codes identical to that repository's current inline invocationgit diff --check origin/main...HEADChecklist
Summary by CodeRabbit
New Features
Documentation