-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjprc.ts
More file actions
executable file
·24 lines (19 loc) · 841 Bytes
/
Copy pathjprc.ts
File metadata and controls
executable file
·24 lines (19 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env -S deno run --allow-env --allow-read --allow-run=jj,gh
import $ from "jsr:@david/dax@0.42.0"
import { parseArgs } from "jsr:@std/cli@1.0/parse-args"
const { r } = parseArgs(Deno.args, { string: ["r"], default: { r: "@-" } })
const bookmarks = (await $`jj bookmark list -r ${r} -T 'name++"\n"'`.lines())
.filter((x) => !!x)
let bookmark: string
if (bookmarks.length === 0) {
bookmark = (await $.prompt("No bookmarks found. Create one:", { noClear: true })).trim()
if (!bookmark) Deno.exit()
await $`jj bookmark create ${bookmark} -r ${r}`
} else if (bookmarks.length === 1) {
bookmark = bookmarks[0]
} else {
const i = await $.select({ message: "Pick a bookmark:", options: bookmarks })
bookmark = bookmarks[i]
}
await $`jj git push -b ${bookmark} --allow-new`
await $`gh pr create --head ${bookmark} --web`