Skip to content

Commit ca7ae71

Browse files
committed
chore(git-hooks): commit validation skip cherry-pick/rebase/merge ops
1 parent cec370f commit ca7ae71

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

.githooks/prepare-commit-msg

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ var validate = require('./scripts/validate'),
77

88
var options = { style: "default" };
99

10+
// Second arg: commit source (merge, squash, commit, or empty)
11+
var commitSource = process.argv[3];
12+
13+
// Detect rebase / cherry-pick via .git state files
14+
var gitDir = path.resolve(process.env.GIT_DIR || '.git');
15+
var isRebase = fs.existsSync(path.join(gitDir, 'REBASE_HEAD'))
16+
|| fs.existsSync(path.join(gitDir, 'rebase-merge'))
17+
|| fs.existsSync(path.join(gitDir, 'rebase-apply'));
18+
var isCherryPick = fs.existsSync(path.join(gitDir, 'CHERRY_PICK_HEAD'));
19+
20+
if (isRebase || isCherryPick || commitSource === 'merge' || commitSource === 'squash') {
21+
process.exit(0);
22+
}
23+
1024
var text = fs.readFileSync(process.argv[2]).toString();
1125
var errors = [];
1226
errors = validate(text, options, errors);

0 commit comments

Comments
 (0)