Add color and pager support to log command
This commit is contained in:
parent
e6c9489137
commit
a89d8482d2
|
|
@ -1,12 +1,15 @@
|
||||||
import { $ } from "bun"
|
import { $ } from "bun"
|
||||||
import { die } from "../fmt.ts"
|
import { die, yellow, reset, pager } from "../fmt.ts"
|
||||||
import { requireSession } from "./helpers.ts"
|
import { requireSession } from "./helpers.ts"
|
||||||
|
|
||||||
export async function action(branch: string) {
|
export async function action(branch: string) {
|
||||||
const { session } = await requireSession(branch)
|
const { session } = await requireSession(branch)
|
||||||
|
|
||||||
const result = await $`git -C ${session.worktree} log main..HEAD`.nothrow()
|
const result = await $`git -C ${session.worktree} log --no-color main..HEAD`.nothrow().quiet()
|
||||||
if (result.exitCode !== 0) {
|
if (result.exitCode !== 0) {
|
||||||
die("git log failed")
|
die("git log failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const output = result.text().replace(/^(commit [0-9a-f]+)/gm, `${yellow}$1${reset}`)
|
||||||
|
await pager(output)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user