angular-docs-cn/dev-infra/commit-message
George Kalpakas 364284b0dc fix(dev-infra): ignore comments when validating commit messages (#38438)
When creating a commit with the git cli, git pre-populates the editor
used to enter the commit message with some comments (i.e. lines starting
with `#`). These comments contain helpful instructions or information
regarding the changes that are part of the commit. As happens with all
commit message comments, they are removed by git and do not end up in
the final commit message.

However, the file that is passed to the `commit-msg` to be validated
still contains these comments. This may affect the outcome of the commit
message validation. In such cases, the author will not realize that the
commit message is not in the desired format until the linting checks
fail on CI (which validates the final commit messages and is not
affected by this issue), usually several minutes later.

Possible ways in which the commit message validation outcome can be
affected:
- The minimum body length check may pass incorrectly, even if there is
  no actual body, because the comments are counted as part of the body.
- The maximum line length check may fail incorrectly due to a very long
  line in the comments.

This commit fixes the problem by removing comment lines before
validating a commit message.

Fixes #37865

PR Close #38438
2020-08-21 12:17:14 -07:00
..
BUILD.bazel feat(dev-infra): create a wizard for building commit messages (#38457) 2020-08-18 17:01:14 -07:00
builder.spec.ts feat(dev-infra): create a wizard for building commit messages (#38457) 2020-08-18 17:01:14 -07:00
builder.ts feat(dev-infra): create a wizard for building commit messages (#38457) 2020-08-18 17:01:14 -07:00
cli.ts feat(dev-infra): create a wizard for building commit messages (#38457) 2020-08-18 17:01:14 -07:00
commit-message-draft.ts feat(dev-infra): save invalid commit message attempts to be restored on next commit attempt (#38304) 2020-08-13 08:45:25 -07:00
config.ts feat(dev-infra): create a wizard for building commit messages (#38457) 2020-08-18 17:01:14 -07:00
parse.spec.ts fix(dev-infra): ignore comments when validating commit messages (#38438) 2020-08-21 12:17:14 -07:00
parse.ts fix(dev-infra): ignore comments when validating commit messages (#38438) 2020-08-21 12:17:14 -07:00
restore-commit-message.ts feat(dev-infra): save invalid commit message attempts to be restored on next commit attempt (#38304) 2020-08-13 08:45:25 -07:00
validate-file.ts feat(dev-infra): save invalid commit message attempts to be restored on next commit attempt (#38304) 2020-08-13 08:45:25 -07:00
validate-range.ts refactor(dev-infra): extract the commit message parsing function into its own file (#38429) 2020-08-12 16:10:07 -07:00
validate.spec.ts feat(dev-infra): migrate to unified commit message types in commit message linting (#38430) 2020-08-13 09:11:17 -07:00
validate.ts feat(dev-infra): migrate to unified commit message types in commit message linting (#38430) 2020-08-13 09:11:17 -07:00
wizard.ts feat(dev-infra): create a wizard for building commit messages (#38457) 2020-08-18 17:01:14 -07:00