|
|
@@ -442,9 +442,10 @@ export const GithubRunCommand = cmd({
|
|
|
const head = (await $`git rev-parse HEAD`).stdout.toString().trim()
|
|
|
const dataPrompt = buildPromptDataForPR(prData)
|
|
|
const response = await chat(`${userPrompt}\n\n${dataPrompt}`, promptFiles)
|
|
|
- if (await branchIsDirty(head)) {
|
|
|
+ const { dirty, uncommittedChanges } = await branchIsDirty(head)
|
|
|
+ if (dirty) {
|
|
|
const summary = await summarize(response)
|
|
|
- await pushToLocalBranch(summary)
|
|
|
+ await pushToLocalBranch(summary, uncommittedChanges)
|
|
|
}
|
|
|
const hasShared = prData.comments.nodes.some((c) => c.body.includes(`${shareBaseUrl}/s/${shareId}`))
|
|
|
await updateComment(`${response}${footer({ image: !hasShared })}`)
|
|
|
@@ -455,9 +456,10 @@ export const GithubRunCommand = cmd({
|
|
|
const head = (await $`git rev-parse HEAD`).stdout.toString().trim()
|
|
|
const dataPrompt = buildPromptDataForPR(prData)
|
|
|
const response = await chat(`${userPrompt}\n\n${dataPrompt}`, promptFiles)
|
|
|
- if (await branchIsDirty(head)) {
|
|
|
+ const { dirty, uncommittedChanges } = await branchIsDirty(head)
|
|
|
+ if (dirty) {
|
|
|
const summary = await summarize(response)
|
|
|
- await pushToForkBranch(summary, prData)
|
|
|
+ await pushToForkBranch(summary, prData, uncommittedChanges)
|
|
|
}
|
|
|
const hasShared = prData.comments.nodes.some((c) => c.body.includes(`${shareBaseUrl}/s/${shareId}`))
|
|
|
await updateComment(`${response}${footer({ image: !hasShared })}`)
|
|
|
@@ -470,9 +472,10 @@ export const GithubRunCommand = cmd({
|
|
|
const issueData = await fetchIssue()
|
|
|
const dataPrompt = buildPromptDataForIssue(issueData)
|
|
|
const response = await chat(`${userPrompt}\n\n${dataPrompt}`, promptFiles)
|
|
|
- if (await branchIsDirty(head)) {
|
|
|
+ const { dirty, uncommittedChanges } = await branchIsDirty(head)
|
|
|
+ if (dirty) {
|
|
|
const summary = await summarize(response)
|
|
|
- await pushToNewBranch(summary, branch)
|
|
|
+ await pushToNewBranch(summary, branch, uncommittedChanges)
|
|
|
const pr = await createPR(
|
|
|
repoData.data.default_branch,
|
|
|
branch,
|
|
|
@@ -805,33 +808,39 @@ export const GithubRunCommand = cmd({
|
|
|
return `opencode/${type}${issueId}-${timestamp}`
|
|
|
}
|
|
|
|
|
|
- async function pushToNewBranch(summary: string, branch: string) {
|
|
|
+ async function pushToNewBranch(summary: string, branch: string, commit: boolean) {
|
|
|
console.log("Pushing to new branch...")
|
|
|
- await $`git add .`
|
|
|
- await $`git commit -m "${summary}
|
|
|
+ if (commit) {
|
|
|
+ await $`git add .`
|
|
|
+ await $`git commit -m "${summary}
|
|
|
|
|
|
Co-authored-by: ${actor} <${actor}@users.noreply.github.com>"`
|
|
|
+ }
|
|
|
await $`git push -u origin ${branch}`
|
|
|
}
|
|
|
|
|
|
- async function pushToLocalBranch(summary: string) {
|
|
|
+ async function pushToLocalBranch(summary: string, commit: boolean) {
|
|
|
console.log("Pushing to local branch...")
|
|
|
- await $`git add .`
|
|
|
- await $`git commit -m "${summary}
|
|
|
+ if (commit) {
|
|
|
+ await $`git add .`
|
|
|
+ await $`git commit -m "${summary}
|
|
|
|
|
|
Co-authored-by: ${actor} <${actor}@users.noreply.github.com>"`
|
|
|
+ }
|
|
|
await $`git push`
|
|
|
}
|
|
|
|
|
|
- async function pushToForkBranch(summary: string, pr: GitHubPullRequest) {
|
|
|
+ async function pushToForkBranch(summary: string, pr: GitHubPullRequest, commit: boolean) {
|
|
|
console.log("Pushing to fork branch...")
|
|
|
|
|
|
const remoteBranch = pr.headRefName
|
|
|
|
|
|
- await $`git add .`
|
|
|
- await $`git commit -m "${summary}
|
|
|
+ if (commit) {
|
|
|
+ await $`git add .`
|
|
|
+ await $`git commit -m "${summary}
|
|
|
|
|
|
Co-authored-by: ${actor} <${actor}@users.noreply.github.com>"`
|
|
|
+ }
|
|
|
await $`git push fork HEAD:${remoteBranch}`
|
|
|
}
|
|
|
|
|
|
@@ -839,9 +848,17 @@ Co-authored-by: ${actor} <${actor}@users.noreply.github.com>"`
|
|
|
console.log("Checking if branch is dirty...")
|
|
|
const ret = await $`git status --porcelain`
|
|
|
const status = ret.stdout.toString().trim()
|
|
|
- if (status.length > 0) return true
|
|
|
+ if (status.length > 0) {
|
|
|
+ return {
|
|
|
+ dirty: true,
|
|
|
+ uncommittedChanges: true,
|
|
|
+ }
|
|
|
+ }
|
|
|
const head = await $`git rev-parse HEAD`
|
|
|
- return head.stdout.toString().trim() !== originalHead
|
|
|
+ return {
|
|
|
+ dirty: head.stdout.toString().trim() !== originalHead,
|
|
|
+ uncommittedChanges: false,
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
async function assertPermissions() {
|