chore(repo): exclude master commits from commit linting (#22029)
This commit is contained in:
parent
c2070817ba
commit
888110a20b
@ -3,11 +3,43 @@
|
|||||||
const { types, scopes } = require('./commitizen.js');
|
const { types, scopes } = require('./commitizen.js');
|
||||||
|
|
||||||
console.log('🐟🐟🐟 Validating git commit message 🐟🐟🐟');
|
console.log('🐟🐟🐟 Validating git commit message 🐟🐟🐟');
|
||||||
const gitMessage = require('child_process')
|
|
||||||
.execSync('git log -1 --no-merges')
|
const childProcess = require('child_process');
|
||||||
|
|
||||||
|
let gitLogCmd = 'git log -1 --no-merges';
|
||||||
|
|
||||||
|
const gitRemotes = childProcess
|
||||||
|
.execSync('git remote -v')
|
||||||
|
.toString()
|
||||||
|
.trim()
|
||||||
|
.split('\n');
|
||||||
|
const upstreamRemote = gitRemotes.find((remote) =>
|
||||||
|
remote.includes('nrwl/nx.git')
|
||||||
|
);
|
||||||
|
if (upstreamRemote) {
|
||||||
|
const upstreamRemoteIdentifier = upstreamRemote.split('\t')[0].trim();
|
||||||
|
console.log(`Comparing against remote ${upstreamRemoteIdentifier}`);
|
||||||
|
const currentBranch = childProcess
|
||||||
|
.execSync('git branch --show-current')
|
||||||
.toString()
|
.toString()
|
||||||
.trim();
|
.trim();
|
||||||
|
|
||||||
|
// exclude all commits already present in upstream/master
|
||||||
|
gitLogCmd =
|
||||||
|
gitLogCmd + ` ${currentBranch} ^${upstreamRemoteIdentifier}/master`;
|
||||||
|
} else {
|
||||||
|
console.error(
|
||||||
|
'No upstream remote found for nrwl/nx.git. Skipping comparison against upstream master.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const gitMessage = childProcess.execSync(gitLogCmd).toString().trim();
|
||||||
|
|
||||||
|
if (!gitMessage) {
|
||||||
|
console.log('No commits found. Skipping commit message validation.');
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
const allowedTypes = types.map((type) => type.value).join('|');
|
const allowedTypes = types.map((type) => type.value).join('|');
|
||||||
const allowedScopes = scopes.map((scope) => scope.value).join('|');
|
const allowedScopes = scopes.map((scope) => scope.value).join('|');
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user