Skip to content

Commit

Permalink
Add options to set name and email on commit
Browse files Browse the repository at this point in the history
[changelog:added]
  • Loading branch information
cdupuis committed Jun 10, 2020
1 parent 89cb3bc commit 762d025
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/project/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

import * as pRetry from "p-retry";
import { execPromise } from "../child_process";
import { debug } from "../log";
import {
Expand All @@ -22,7 +23,6 @@ import {
} from "./gitStatus";
import { Project } from "./project";
import { cwd } from "./util";
import * as pRetry from "p-retry";
import forOwn = require("lodash.forown");

/**
Expand Down Expand Up @@ -53,7 +53,13 @@ export async function status(projectOrCwd: Project | string): Promise<GitStatus>
/**
* `git add .` and `git commit -m MESSAGE`
*/
export async function commit(projectOrCwd: Project | string, message: string): Promise<void> {
export async function commit(projectOrCwd: Project | string, message: string, options: { name?: string; email?: string } = {}): Promise<void> {
if (options.name) {
await execPromise("git", ["config", "user.name", name], { cwd: cwd(projectOrCwd) });
}
if (options.email) {
await execPromise("git", ["config", "user.email", options.email], { cwd: cwd(projectOrCwd) });
}
await execPromise("git", ["add", "."], { cwd: cwd(projectOrCwd) });
await execPromise("git", ["commit", "-m", message], { cwd: cwd(projectOrCwd) });
}
Expand Down

0 comments on commit 762d025

Please sign in to comment.