Skip to content

Commit 5f00834

Browse files
committed
Add git user name and email config
1 parent b5d1c1a commit 5f00834

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

packages/opencode/src/flag/flag.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
export namespace Flag {
22
export const OPENCODE_AUTO_SHARE = truthy("OPENCODE_AUTO_SHARE")
3+
export const OPENCODE_GIT_USER_NAME = process.env["OPENCODE_GIT_USER_NAME"] || "shuvcode"
4+
export const OPENCODE_GIT_USER_EMAIL = process.env["OPENCODE_GIT_USER_EMAIL"] || "shuvcode@localhost"
35
export const OPENCODE_GIT_BASH_PATH = process.env["OPENCODE_GIT_BASH_PATH"]
46
export const OPENCODE_CONFIG = process.env["OPENCODE_CONFIG"]
57
export const OPENCODE_CONFIG_DIR = process.env["OPENCODE_CONFIG_DIR"]

packages/opencode/src/project/project.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,16 @@ export namespace Project {
267267
if (!isGitRepo) {
268268
// Initialize git and create empty initial commit (required for project ID which is the first commit hash)
269269
await $`git init`.cwd(projectPath).quiet()
270-
await $`git commit --allow-empty -m "Initial commit"`.cwd(projectPath).quiet()
270+
await $`git -c user.name=${Flag.OPENCODE_GIT_USER_NAME} -c user.email=${Flag.OPENCODE_GIT_USER_EMAIL} commit --allow-empty -m "Initial commit"`
271+
.cwd(projectPath)
272+
.quiet()
271273
} else {
272274
// Check if there are any commits
273275
const hasCommits = await $`git rev-list -n 1 --all`.cwd(projectPath).quiet().nothrow().text()
274276
if (!hasCommits.trim()) {
275-
await $`git commit --allow-empty -m "Initial commit"`.cwd(projectPath).quiet()
277+
await $`git -c user.name=${Flag.OPENCODE_GIT_USER_NAME} -c user.email=${Flag.OPENCODE_GIT_USER_EMAIL} commit --allow-empty -m "Initial commit"`
278+
.cwd(projectPath)
279+
.quiet()
276280
}
277281
}
278282

0 commit comments

Comments
 (0)