mirror of
https://github.com/Z3Prover/z3
synced 2025-04-03 16:19:57 +00:00
refactor and optimize git operations for commit messages and failure analysis (#7412)
This commit is contained in:
parent
2ae4ac8d0a
commit
24d7b05c0d
3
.gitignore.genai
Normal file
3
.gitignore.genai
Normal file
|
@ -0,0 +1,3 @@
|
|||
**/genaiscript.d.ts
|
||||
**/package-lock.json
|
||||
**/yarn.lock
|
17
genaisrc/gai.genai.mts
Normal file
17
genaisrc/gai.genai.mts
Normal file
|
@ -0,0 +1,17 @@
|
|||
script({
|
||||
tools: ["agent_fs", "agent_git", "agent_github"],
|
||||
})
|
||||
|
||||
const {
|
||||
workflow = "latest failed",
|
||||
failure_run_id = "latest",
|
||||
branch = await git.defaultBranch(),
|
||||
} = env.vars
|
||||
|
||||
$`Investigate the status of the ${workflow} workflow and identify the root cause of the failure of run ${failure_run_id} in branch ${branch}.
|
||||
|
||||
- Correlate the failure with the relevant commits, pull requests or issues.
|
||||
- Compare the source code between the failed run commit and the last successful run commit before that run.
|
||||
|
||||
In your report, include html links to the relevant runs, commits, pull requests or issues.
|
||||
`
|
|
@ -6,28 +6,16 @@ script({
|
|||
description: "Generate a commit message for all staged changes",
|
||||
})
|
||||
|
||||
// TODO: update this diff command to match your workspace
|
||||
const diffCmd = "git diff --cached -- . :!**/genaiscript.d.ts"
|
||||
|
||||
// Check for staged changes and stage all changes if none are staged
|
||||
let diff = await host.exec(diffCmd)
|
||||
if (!diff.stdout) {
|
||||
/**
|
||||
* Ask user to stage all changes if none are staged
|
||||
*/
|
||||
const stage = await host.confirm("No staged changes. Stage all changes?", {
|
||||
default: true,
|
||||
})
|
||||
if (stage) {
|
||||
// Stage all changes and recompute diff
|
||||
await host.exec("git add .")
|
||||
diff = await host.exec(diffCmd)
|
||||
}
|
||||
if (!diff.stdout) cancel("no staged changes")
|
||||
}
|
||||
const diff = await git.diff({
|
||||
staged: true,
|
||||
excludedPaths: "**/genaiscript.d.ts",
|
||||
askStageOnEmpty: true,
|
||||
})
|
||||
if (!diff) cancel("no staged changes")
|
||||
|
||||
// show diff in the console
|
||||
console.log(diff.stdout)
|
||||
console.log(diff)
|
||||
|
||||
let choice
|
||||
let message
|
||||
|
@ -79,9 +67,9 @@ Please generate a concise, one-line commit message for these changes.
|
|||
}
|
||||
// Regenerate message
|
||||
if (choice === "commit" && message) {
|
||||
console.log((await host.exec("git", ["commit", "-m", message])).stdout)
|
||||
console.log(await git.exec(["commit", "-m", message]))
|
||||
if (await host.confirm("Push changes?", { default: true }))
|
||||
console.log((await host.exec("git push")).stdout)
|
||||
console.log(await git.exec("push"))
|
||||
break
|
||||
}
|
||||
} while (choice !== "commit")
|
||||
|
|
BIN
genaisrc/genaiscript.d.ts
generated
vendored
BIN
genaisrc/genaiscript.d.ts
generated
vendored
Binary file not shown.
Loading…
Reference in a new issue