✨ Add custom timeout argument to git commit script
This commit is contained in:
@@ -32,7 +32,9 @@ export async function howto(message: string): Promise<string> {
|
||||
return (await response.json())["data"]["summary"];
|
||||
}
|
||||
|
||||
export async function summarizeGitStatusDiff(): Promise<string> {
|
||||
export async function summarizeGitStatusDiff(
|
||||
timeoutMillis?: number,
|
||||
): Promise<string> {
|
||||
const gitStatus = (await execCommand("git", ["status"]))
|
||||
.assertSuccess().getStdoutAsStringThenTrim();
|
||||
const gitDiff = (await execCommand("git", ["diff"]))
|
||||
@@ -50,7 +52,7 @@ export async function summarizeGitStatusDiff(): Promise<string> {
|
||||
"gitStatus": gitStatus,
|
||||
"gitDiff": gitDiff,
|
||||
}),
|
||||
timeoutMillis: 30_000,
|
||||
timeoutMillis: timeoutMillis ?? 30_000,
|
||||
},
|
||||
);
|
||||
if (response.status != 200) {
|
||||
|
||||
@@ -63,12 +63,12 @@
|
||||
},
|
||||
"commit.ts": {
|
||||
"script_name": "commit.ts",
|
||||
"script_length": 3837,
|
||||
"script_sha256": "c61abe4b6fc8e9eb71795fff5cbcb8d3b1907eee541559abb34d316364967e3b",
|
||||
"script_length": 4070,
|
||||
"script_sha256": "b71c50161801e910857589860c6acb1d25124c07f09c123159678376c8ac00f1",
|
||||
"script_full_url": "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/single-scripts/commit.ts",
|
||||
"single_script_file": true,
|
||||
"publish_time": 1769318306585,
|
||||
"update_time": 1776005626908
|
||||
"update_time": 1777219521641
|
||||
},
|
||||
"decode-uri-component.ts": {
|
||||
"script_name": "decode-uri-component.ts",
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import {parseArgs} from "jsr:@std/cli/parse-args";
|
||||
import {execCommandShell, log, ProcessBar, term,} from "https://script.hatter.ink/@61/deno-commons-mod.ts";
|
||||
import {summarizeGitStatusDiff} from "https://script.hatter.ink/@2/deno-ai-mod.ts";
|
||||
import {summarizeGitStatusDiff} from "https://script.hatter.ink/@4/deno-ai-mod.ts";
|
||||
import {getGitLocalRev, getGitRemoteRev, getGitStatus,} from "https://script.hatter.ink/@2/deno-git-mod.ts";
|
||||
|
||||
async function checkRev(): Promise<boolean> {
|
||||
@@ -22,14 +22,20 @@ async function checkRev(): Promise<boolean> {
|
||||
async function main() {
|
||||
const flags = parseArgs(Deno.args, {
|
||||
boolean: ["help", "check-only", "auto-commit"],
|
||||
string: ["timeout-ms"],
|
||||
alias: {
|
||||
h: "help",
|
||||
C: "check-only",
|
||||
A: "auto-commit",
|
||||
t: "timeout-ms",
|
||||
},
|
||||
});
|
||||
const checkOnly = flags["check-only"];
|
||||
const autoCommit = flags["auto-commit"];
|
||||
const argTimeoutMs = flags["timeout-ms"];
|
||||
const timeoutMillis: number | undefined = argTimeoutMs
|
||||
? parseInt(argTimeoutMs)
|
||||
: undefined;
|
||||
|
||||
if (flags.help) {
|
||||
console.log(`commit.ts
|
||||
@@ -55,7 +61,7 @@ commit.ts [-A|--auto-commit] - auto commit with AI summarize
|
||||
|
||||
const summary = await new ProcessBar("AI summarizing").call(
|
||||
async (): Promise<string> => {
|
||||
return await summarizeGitStatusDiff();
|
||||
return await summarizeGitStatusDiff(timeoutMillis);
|
||||
},
|
||||
);
|
||||
if (summary != null) {
|
||||
@@ -117,5 +123,5 @@ main().catch((err) => {
|
||||
process.exit(0);
|
||||
}).then(() => process.exit(0));
|
||||
|
||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260412T225340+08:00.MEUCIQCtE3akY/QOeUWRm6sz
|
||||
// R/yRzGFIChTIGNcBHouraVAkWwIgMsbQ2FvJIJDHHgyyeimmRbe7+8nYuVYGcw1udlCZz2A=
|
||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260427T000515+08:00.MEUCIQCWHN3NOg3iwZnNIuLp
|
||||
// 3EqVZEuJjqD4x1+gfgpGgznuEgIga/bS7aBT5mQtp7VWG27mY8DOgBxjDkj0NKTJ+TnqsDM=
|
||||
|
||||
Reference in New Issue
Block a user