-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
git-commit.js
42 lines (34 loc) · 1.04 KB
/
git-commit.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"use strict";
const { EOL } = require("os");
const log = require("npmlog");
const tempWrite = require("@lerna/temp-write");
const childProcess = require("@lerna/child-process");
module.exports.gitCommit = gitCommit;
/**
* @param {string} message
* @param {{ amend: boolean; commitHooks: boolean; signGitCommit: boolean; }} gitOpts
* @param {import("@lerna/child-process").ExecOpts} opts
*/
function gitCommit(message, { amend, commitHooks, signGitCommit, signoffGitCommit }, opts) {
log.silly("gitCommit", message);
const args = ["commit"];
if (commitHooks === false) {
args.push("--no-verify");
}
if (signGitCommit) {
args.push("--gpg-sign");
}
if (signoffGitCommit) {
args.push("--signoff");
}
if (amend) {
args.push("--amend", "--no-edit");
} else if (message.indexOf(EOL) > -1) {
// Use tempfile to allow multi\nline strings.
args.push("-F", tempWrite.sync(message, "lerna-commit.txt"));
} else {
args.push("-m", message);
}
log.verbose("git", args);
return childProcess.exec("git", args, opts);
}