Skip to content

Additional header rules (header-full-stop, header-case)#547

Merged
byCedric merged 2 commits intomasterfrom
bycedric-header-rules
Jan 27, 2019
Merged

Additional header rules (header-full-stop, header-case)#547
byCedric merged 2 commits intomasterfrom
bycedric-header-rules

Conversation

@byCedric
Copy link
Copy Markdown
Member

@byCedric byCedric commented Jan 25, 2019

Description

This adds some extra, but missing, rules for header validation (#524). Currently, there are some failing tests that need to be resolved first. But I think I might need some help/eyes to get that resolved.

This PR adds two new rules for the header; header-case and header-full-stop. Both are based on the already existing subject-case and subject-full-stop. Like requested in #524, this is useful when no types (and therefore no subject) are used in commits.

In the issue, we also discussed the header-empty, but when using empty commit messages the parser will throw an error describing it "expects a raw commit". That makes the header-empty rule impossible.

Motivation and Context

Usage examples

How Has This Been Tested?

Copied and edited the tests from the existing rules.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@byCedric byCedric force-pushed the bycedric-header-rules branch 4 times, most recently from 72496eb to 7dadb94 Compare January 27, 2019 12:44
This is a simplified version of the subject-full-stop rule. Headers are always present, so we don’t need to check for empty-ness. If headers are not defined, the parser will throw with an error “expecting raw commit”.
This is a simplified version of the subject-case rule. Headers are always present, so we don’t need to check for empty-ness. If headers are not defined, the parser will throw with an error “expecting raw commit”.
@byCedric byCedric force-pushed the bycedric-header-rules branch from 7dadb94 to 21bdb07 Compare January 27, 2019 12:54
@byCedric byCedric changed the title Additional header rules [WIP] Additional header rules (header-full-stop, header-case) Jan 27, 2019
@byCedric
Copy link
Copy Markdown
Member Author

I fixed the tests and updated the documentation. I think it's ready to merge once it has been approved 😄

@escapedcat
Copy link
Copy Markdown
Member

Looks good to me.
Just for my understanding. So, if commitlint isn't finding a type: subject kinda case it falls back to header-only mode and is able to apply these new rules, yes?

@byCedric
Copy link
Copy Markdown
Member Author

Yes exactly, a conventional commit usually consists of this structure:

<header>
<body>
<footer>

The header itself is structured using <type>(<scope>): <subject> right? So if a type isn't defined, the parser can't find the subject. To "work around" that issue, the raw header is also parsed. These rules allow developers to use that workaround 😄

@escapedcat
Copy link
Copy Markdown
Member

Great! Thanks!
They really should just use the conventional format but 🤷‍♂️ :D

Copy link
Copy Markdown
Contributor

@marionebl marionebl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! 👍

@byCedric byCedric merged commit 4c36cbd into master Jan 27, 2019
@byCedric byCedric deleted the bycedric-header-rules branch January 27, 2019 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants