update git-check.ts
This commit is contained in:
@@ -7,10 +7,17 @@ import {
|
|||||||
ProcessBar,
|
ProcessBar,
|
||||||
readFileToString,
|
readFileToString,
|
||||||
stringifyPretty,
|
stringifyPretty,
|
||||||
|
term,
|
||||||
uint8ArrayToHexString,
|
uint8ArrayToHexString,
|
||||||
writeStringToFile,
|
writeStringToFile,
|
||||||
} from "https://script.hatter.ink/@34/deno-commons-mod.ts";
|
} from "https://script.hatter.ink/@34/deno-commons-mod.ts";
|
||||||
import {getGitLocalRev, getGitRemoteRev,} from "https://script.hatter.ink/@0/deno-git-mod.ts";
|
import {
|
||||||
|
getGitLocalRev,
|
||||||
|
getGitRemoteRev,
|
||||||
|
} from "https://script.hatter.ink/@0/deno-git-mod.ts";
|
||||||
|
import { parseArgs } from "jsr:@std/cli/parse-args";
|
||||||
|
|
||||||
|
const MILLIS_OF_HOUR = 60 * 60 * 1000;
|
||||||
|
|
||||||
async function sha256OfString(input: string): Promise<string> {
|
async function sha256OfString(input: string): Promise<string> {
|
||||||
const data = new TextEncoder().encode(input);
|
const data = new TextEncoder().encode(input);
|
||||||
@@ -30,6 +37,23 @@ interface GitCheckCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
|
const flags = parseArgs(Deno.args, {
|
||||||
|
boolean: [
|
||||||
|
"help",
|
||||||
|
],
|
||||||
|
string: [
|
||||||
|
"interval",
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
if (flags.help) {
|
||||||
|
console.log(`Usage:
|
||||||
|
git-check.ts --help
|
||||||
|
git-check.ts [--interval NUMBER-OF-HOURS]`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const intervalHours = parseInt(flags.interval ?? "2", 10);
|
||||||
|
|
||||||
const pwd = await getPwd();
|
const pwd = await getPwd();
|
||||||
const pwdHash = await sha256OfString(pwd);
|
const pwdHash = await sha256OfString(pwd);
|
||||||
const gitCheckCacheFile = `~/.cache/git-check-${
|
const gitCheckCacheFile = `~/.cache/git-check-${
|
||||||
@@ -42,12 +66,12 @@ async function main() {
|
|||||||
: null;
|
: null;
|
||||||
if (gitCheckCache) {
|
if (gitCheckCache) {
|
||||||
const timeBefore = Date.now() - gitCheckCache.lastCheckTime;
|
const timeBefore = Date.now() - gitCheckCache.lastCheckTime;
|
||||||
if (timeBefore < 60 * 60 * 1000) {
|
if (timeBefore < MILLIS_OF_HOUR * intervalHours) {
|
||||||
const lastCheckTime = new Date(gitCheckCache.lastCheckTime);
|
const lastCheckTime = new Date(gitCheckCache.lastCheckTime);
|
||||||
const timeBeforeHuman = formatHumanTime(timeBefore);
|
const timeBeforeHuman = formatHumanTime(timeBefore);
|
||||||
log.info(
|
log.info(term.auto(
|
||||||
`Last check at ${lastCheckTime}, in ${timeBeforeHuman}, skip check git remote rev`,
|
`Last check at [under]${lastCheckTime.toLocaleString()}[/], in [under]${timeBeforeHuman}[/], [green]skip check git remote rev[/]`,
|
||||||
);
|
));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -76,5 +100,5 @@ async function main() {
|
|||||||
|
|
||||||
await main();
|
await main();
|
||||||
|
|
||||||
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260208T183447+08:00.MEYCIQCizSoZCohVIszX24vf
|
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260208T202409+08:00.MEUCIQDQct1xYu1frnSk3uzu
|
||||||
// kYa6qKDOpEBl0xwcMz8oY4U4wAIhAM0QzPVsFVZMO5379wA2nQdp0KrjDDzAr2zdd2kVMd7z
|
// RZ5WHoOdBCzaMDAe16JIbKZlGAIgZ3gBrD8FIH+H6efI8C7mkyn3RjoAqa6PAz72KcX/d80=
|
||||||
|
|||||||
6
single-scripts/pub
Normal file
6
single-scripts/pub
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
Script started on Sun Feb 8 19:18:45 2026
|
||||||
|
Command: --type bun ssh-bun.ts
|
||||||
|
script: --type: No such file or directory
|
||||||
|
|
||||||
|
Command exit status: 1
|
||||||
|
Script done on Sun Feb 8 19:18:45 2026
|
||||||
Reference in New Issue
Block a user