Skip to content

Commit

Permalink
(#1) Removing status rule.
Browse files Browse the repository at this point in the history
  • Loading branch information
danrivett committed Feb 22, 2020
1 parent 9de43b5 commit 327151d
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 103 deletions.
5 changes: 0 additions & 5 deletions packages/commitlint-config-github/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ export const commitlintConfigGitHub: CommitlintConfigGitHub = {
'always',
commitlintGitHubConstants.UPPERCASE,
],
[commitlintGitHubConstants.GITHUB_RULES.commitStatusCase]: [
2,
'always',
commitlintGitHubConstants.UPPERCASE,
],
[commitlintGitHubConstants.GITHUB_RULES.commitMessageSeparator]: [
2,
'always',
Expand Down
7 changes: 0 additions & 7 deletions packages/commitlint-github-utils/@types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export interface Rules {
commitStatusCase: string
taskIdEmpty: string
taskIdSeparator: string
taskIdCase: string
Expand All @@ -12,12 +11,7 @@ export interface TCommitlintGitHubConstants {
GITHUB_RULES: Rules
COMMIT_MESSAGE_SEPARATOR: string
COMMIT_TASK_IDS_SEPARATOR: string
COMMIT_TASK_STATUS_PATTERN: RegExp
TASK_ID_SEPARATOR: string
COMMIT_STATUS_SEPARATORS: {
start: string
end: string
}
UPPERCASE: string
LOWERCASE: string
COMMIT_DESCRIPTION_SEPARATOR: string
Expand All @@ -29,7 +23,6 @@ export type TParseCommitMessage = (
commitTaskIds: string[]
commitHeader: string
commitFooter: string
commitStatus: string
}

export interface CommitlintGitHubUtils {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export const GITHUB_RULES = {
commitStatusCase: 'github-commit-status-case',
taskIdCase: 'github-task-id-case',
taskIdSeparator: 'github-task-id-separator',
taskIdEmpty: 'github-task-id-empty',
Expand All @@ -10,12 +9,7 @@ export const GITHUB_RULES = {

export const COMMIT_MESSAGE_SEPARATOR = ':'
export const COMMIT_TASK_IDS_SEPARATOR = ','
export const COMMIT_TASK_STATUS_PATTERN = /\[.*\]/gi
export const TASK_ID_SEPARATOR = '-'
export const COMMIT_STATUS_SEPARATORS = {
start: '[',
end: ']',
}
export const UPPERCASE = 'uppercase'
export const LOWERCASE = 'lowercase'
export const COMMIT_DESCRIPTION_SEPARATOR = '\n'
12 changes: 1 addition & 11 deletions packages/commitlint-github-utils/src/parseCommitMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { TParseCommitMessage } from '../@types'
import {
COMMIT_MESSAGE_SEPARATOR,
COMMIT_TASK_IDS_SEPARATOR,
COMMIT_TASK_STATUS_PATTERN,
COMMIT_STATUS_SEPARATORS,
COMMIT_DESCRIPTION_SEPARATOR,
} from './commitlintGitHubConstants'

Expand All @@ -24,9 +22,7 @@ const parseCommitMessage: TParseCommitMessage = rawCommitMessage => {
*/
const rawCommitHeader =
commitMessageParts.length >= 2 ? commitMessageParts[0] : ''
const commitHeader = rawCommitHeader
.replace(COMMIT_TASK_STATUS_PATTERN, '')
.trim()
const commitHeader = rawCommitHeader.trim()
/**
* if commit parts length is greater than 2 return all parts without first part
* because first part is commit header
Expand All @@ -43,11 +39,6 @@ const parseCommitMessage: TParseCommitMessage = rawCommitMessage => {
.trim()
: commitMessageParts[commitMessageParts.length - 1].trim()

const rawCommitStatus = rawCommitHeader.split(COMMIT_STATUS_SEPARATORS.end)
const commitStatus = rawCommitStatus.length
? rawCommitStatus[0].replace(COMMIT_STATUS_SEPARATORS.start, '').trim()
: ''

const commitTaskIds = commitHeader
.split(COMMIT_TASK_IDS_SEPARATOR)
.map(taskId => taskId.trim())
Expand All @@ -57,7 +48,6 @@ const parseCommitMessage: TParseCommitMessage = rawCommitMessage => {
commitTaskIds,
commitFooter,
commitHeader,
commitStatus,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ describe('commitlintPluginGitHubTests', () => {
const testCommitMessages = {
singleScope: 'IB-2121: test commit message',
multyScope: 'IB-2121, IB-21: test commit message',
singleScopeWipTask: '[WIP]IB-2121: test commit message',
multyScopeWipTask: '[WIP]IB-2121, IB-21: test commit message',
// singleScopeWipTask: '[WIP]IB-2121: test commit message',
// multyScopeWipTask: '[WIP]IB-2121, IB-21: test commit message',
emptyTaskIds: ': my commit message',
missingSeparator: 'IB-21 My commit message',
// test data for this issue: https://github.com/Gherciu/commitlint-github/issues/7
Expand All @@ -24,15 +24,15 @@ describe('commitlintPluginGitHubTests', () => {
expect(
parseCommitMessage(testCommitMessages.singleScope).commitTaskIds,
).toEqual(['IB-2121'])
expect(
parseCommitMessage(testCommitMessages.singleScopeWipTask).commitTaskIds,
).toEqual(['IB-2121'])
// expect(
// parseCommitMessage(testCommitMessages.singleScopeWipTask).commitTaskIds,
// ).toEqual(['IB-2121'])
expect(
parseCommitMessage(testCommitMessages.multyScope).commitTaskIds,
).toEqual(['IB-2121', 'IB-21'])
expect(
parseCommitMessage(testCommitMessages.multyScopeWipTask).commitTaskIds,
).toEqual(['IB-2121', 'IB-21'])
// expect(
// parseCommitMessage(testCommitMessages.multyScopeWipTask).commitTaskIds,
// ).toEqual(['IB-2121', 'IB-21'])
})

it('should return correct commitFooter', () => {
Expand All @@ -41,15 +41,6 @@ describe('commitlintPluginGitHubTests', () => {
).toEqual('test commit message')
})

it('should return correct commitStatus', () => {
expect(
parseCommitMessage(testCommitMessages.singleScopeWipTask).commitStatus,
).toEqual('WIP')
expect(
parseCommitMessage(testCommitMessages.multyScopeWipTask).commitStatus,
).toEqual('WIP')
})

it('should return empty array of taskIds', () => {
expect(
parseCommitMessage(testCommitMessages.emptyTaskIds).commitTaskIds,
Expand All @@ -59,7 +50,7 @@ describe('commitlintPluginGitHubTests', () => {
).toEqual([])
})

it('should return corect taskIds and commit footer if a url is added in commit message or multiple commit status separators', () => {
it('should return corect taskIds and commit footer if a url is added in commit message', () => {
expect(
parseCommitMessage(testCommitMessages.multyCommitPartsSeparator)
.commitTaskIds,
Expand Down
4 changes: 1 addition & 3 deletions packages/commitlint-plugin-github-rules/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import githubTaskIdMinLengthRuleResolver from './rules/githubTaskIdMinLengthRule
import githubTaskIdEmptyRuleResolver from './rules/githubTaskIdEmptyRuleResolver'
import githubTaskIdSeparatorRuleResolver from './rules/githubTaskIdSeparatorRuleResolver'
import githubTaskIdCaseRuleResolver from './rules/githubTaskIdCaseRuleResolver'
import githubCommitStatusCaseRuleResolver from './rules/githubCommitStatusCaseRuleResolver'
import githubCommitMessageSeparatorRuleResolver from './rules/githubCommitMessageSeparatorRuleResolver'

export const commitlintPluginGitHub: CommitlintPluginGitHub = {
Expand All @@ -18,9 +17,8 @@ export const commitlintPluginGitHub: CommitlintPluginGitHub = {
.taskIdMaxLength]: githubTaskIdMaxLengthRuleResolver,
[commitlintGitHubConstants.GITHUB_RULES
.taskIdSeparator]: githubTaskIdSeparatorRuleResolver,
[commitlintGitHubConstants.GITHUB_RULES.taskIdCase]: githubTaskIdCaseRuleResolver,
[commitlintGitHubConstants.GITHUB_RULES
.commitStatusCase]: githubCommitStatusCaseRuleResolver,
.taskIdCase]: githubTaskIdCaseRuleResolver,
[commitlintGitHubConstants.GITHUB_RULES
.commitMessageSeparator]: githubCommitMessageSeparatorRuleResolver,
},
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 327151d

Please sign in to comment.