-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib: skip fixup! and squash! commits #33
Changes from 1 commit
79f946e
d07d944
25e5398
47f98de
229ba0c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ module.exports = class ValidateCommit extends EE { | |
this.disableRule('reviewers') | ||
this.disableRule('metadata-end') | ||
} | ||
this.disableRule('skip-fixup-squash') | ||
} | ||
|
||
disableRule(id) { | ||
|
@@ -47,9 +48,14 @@ module.exports = class ValidateCommit extends EE { | |
} | ||
} else { | ||
const commit = new Parser(str, this) | ||
for (const rule of this.rules.values()) { | ||
if (rule.disabled) continue | ||
rule.validate(commit) | ||
if (commit.title.startsWith('fixup!') || | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The changes in this file seems unnecessary? I think the request was more like, if an option is on, then enable this rule, then check the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the way it works is the options are positive (e.g., There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The changes in this file are because, AFAICT, the rules as currently implemented are independent of each other and unordered. The new "rule" is there to give visual feedback when the commit is skipped, e.g.
|
||
commit.title.startsWith('squash!')) { | ||
this.rules.get('skip-fixup-squash').validate(commit) | ||
} else { | ||
for (const rule of this.rules.values()) { | ||
if (rule.disabled) continue | ||
rule.validate(commit) | ||
} | ||
} | ||
|
||
setImmediate(() => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use strict' | ||
|
||
const id = 'skip-fixup-squash' | ||
|
||
module.exports = { | ||
id: id | ||
, meta: { | ||
description: 'skip fixup! and squash! commits' | ||
, recommended: true | ||
} | ||
, defaults: { } | ||
, options: { } | ||
, validate: (context, rule) => { | ||
if (context.title.startsWith('fixup!')) { | ||
context.report({ | ||
id: id | ||
, message: 'Skipping fixup! commit.' | ||
, string: context.title | ||
, level: 'pass' | ||
}) | ||
return | ||
} | ||
|
||
if (context.title.startsWith('squash!')) { | ||
context.report({ | ||
id: id | ||
, message: 'Skipping squash! commit.' | ||
, string: context.title | ||
, level: 'pass' | ||
}) | ||
return | ||
} | ||
|
||
context.report({ | ||
id: id | ||
, message: 'Commit is neither fixup! nor squash!.' | ||
, string: context.title | ||
, line: 0 | ||
, column: 0 | ||
, level: 'fail' | ||
}) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be disabled with a CLI option (see
this.opts
above) by default? I think only our CI will actually need this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it
skip-fixup-squash
should be disabled by default. If node-core-utils detects a fixup or squash commit, I'd want it flagged. It's just CI where we want it disabled. I consider node-core-utils the primary use case.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Or
check-fixup-squash
is enabled by default and the--no-check-fixup-squash
flag disables it.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'll rework to
--check-autosquash
(less to type than--check-fixup-squash
).