Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

Commit

Permalink
#341 support commit patterns anywhere in the multiline message (#473)
Browse files Browse the repository at this point in the history
  • Loading branch information
prayerslayer authored Oct 27, 2016
1 parent ce66a3c commit 641814d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
6 changes: 3 additions & 3 deletions config/app-enterprise.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ ZAPPR_DEFAULT_CONFIG:
commit:
message:
patterns:
- "^(?:(?:[a-zA-Z0-9_\\-]*|[a-zA-Z0-9_\\-]+\\/[a-zA-Z0-9_\\-]+)#|GH-)\\d+"
- "^#?[A-Z]+-[0-9]+" # like JIRA-123
- "^#[0-9+]" # regular github pattern like #123
- "(?:(?:[a-zA-Z0-9_\\-]*|[a-zA-Z0-9_\\-]+\\/[a-zA-Z0-9_\\-]+)#|GH-)\\d+"
- "#?[A-Z]+-[0-9]+" # like JIRA-123
- "#[0-9+]" # regular github pattern like #123
approvals:
minimum: 2
ignore: none
Expand Down
2 changes: 1 addition & 1 deletion config/app-opensource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ZAPPR_DEFAULT_CONFIG:
commit:
message:
patterns:
- "^#[0-9]+"
- "#[0-9]+"
approvals:
minimum: 2
ignore: none
Expand Down
2 changes: 1 addition & 1 deletion server/checks/CommitMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default class CommitMessage extends Check {
// get all the commits in the PR
const commits = await this.github.fetchPullRequestCommits(owner.login, name, number, token)
// get matcher function for all those patterns
const matcherFn = getAnyMatcherFn(patterns.map(pattern => new RegExp(pattern)))
const matcherFn = getAnyMatcherFn(patterns.map(pattern => new RegExp(pattern, 'm')))
// gather non-merge commits with bad messages
const badCommits = commits.filter(c => !isMergeCommit(c) && !matcherFn(c.commit.message.trim()))

Expand Down
10 changes: 8 additions & 2 deletions test/server/commitmessage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import CommitMessage, {getAnyMatcherFn} from '../../server/checks/CommitMessage'
const CONFIG = {
commit: {
message: {
patterns: ['^#[0-9]+']
patterns: ['#[0-9]+']
}
}
}
Expand Down Expand Up @@ -124,7 +124,13 @@ describe('CommitMessage', () => {
}, {
sha: '2commit',
commit: {
message: '#123 polizei'
message: `also matching, but multiline
#552`
}
}, {
sha: '3commit',
commit: {
message: `does not have to be at beginning: #123`
}
}, {
sha: '4commit',
Expand Down

0 comments on commit 641814d

Please sign in to comment.