pivotal-flow
Version:
🔀 A command-line tool that helps you manage & automate your workflow to use with PivotalTracker.
22 lines (21 loc) • 1.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const common_1 = require("../../utils/pivotal/common");
const hooks_1 = require("../../utils/hooks");
const console_1 = require("../../utils/console");
const git_1 = require("../../utils/git");
function prepareCommitMsgHook(filename, source, sha) {
if (hooks_1.shouldSkipPrepareCommitMessage(filename, source)) {
console_1.debugLogObject('skipped prepare-commit-msg', { filename, source, sha });
}
const original = git_1.getCommitMessage(filename);
const { found, formatted: storyId } = common_1.getStoryIfFromCurrentBranch();
if (!found) {
console_1.debugLog('skipped prepare-commit-msg - story ID not found in branch name');
return;
}
console_1.debugLogObject('story details from branch', { found, storyId });
const preparedMessage = hooks_1.appendStoryIdToCommitMessage(original, storyId);
return git_1.writeCommitMessage(filename, preparedMessage);
}
exports.default = prepareCommitMsgHook;