Skip to content

Commit

Permalink
Automatic git configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Hammond authored and Nathan Hammond committed May 15, 2023
1 parent 7d2a57f commit 033a04e
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions packages/create-turbo/src/utils/git.ts
Expand Up @@ -51,7 +51,6 @@ export function isInMercurialRepository(): boolean {
export function tryGitInit(root: string, message: string): boolean {
let didInit = false;
try {
execSync("git --version", { stdio: "ignore" });
if (isInGitRepository() || isInMercurialRepository()) {
return false;
}
Expand All @@ -61,10 +60,7 @@ export function tryGitInit(root: string, message: string): boolean {

execSync("git checkout -b main", { stdio: "ignore" });

execSync("git add -A", { stdio: "ignore" });
execSync(`git commit -m "${message}"`, {
stdio: "ignore",
});
gitCommit(message);
return true;
} catch (err) {
if (didInit) {
Expand All @@ -78,12 +74,18 @@ export function tryGitInit(root: string, message: string): boolean {

export function tryGitCommit(message: string): boolean {
try {
execSync("git add -A", { stdio: "ignore" });
execSync(`git commit -m "${message}"`, {
stdio: "ignore",
});
gitCommit(message);
return true;
} catch (err) {
return false;
}
}

function gitCommit(message: string) {
execSync(
`git commit --author="Turbobot <turbobot@vercel.com>" -am "${message}"`,
{
stdio: "ignore",
}
);
}

0 comments on commit 033a04e

Please sign in to comment.