Skip to content

Commit 8dc5352

Browse files
committed
refactor: simplify git calls using --wrapped
1 parent 3393c71 commit 8dc5352

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

nut/repo.nu

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ export def cache [remote: string]: string -> nothing {
33
let path = $in
44

55
if not ($path | path exists) {
6-
exec { git clone --bare $remote $path }
6+
git clone --bare $remote $path
77
}
88
}
99

1010
export def update []: string -> nothing {
1111
let path = $in
1212
cd $path
1313

14-
exec { git fetch --tags }; ignore
14+
git fetch --tags; ignore
1515
}
1616

1717
export def tags []: string -> list<record<created: datetime, name: string>> {
@@ -20,7 +20,7 @@ export def tags []: string -> list<record<created: datetime, name: string>> {
2020

2121
let format = '{ created: "%(creatordate:iso8601-strict)" name: "%(refname:short)" }'
2222

23-
exec { git for-each-ref --sort=creatordate --format $format refs/tags }
23+
git for-each-ref --sort=creatordate --format $format refs/tags
2424
| $"([$in])"
2525
| from nuon
2626
| upsert created { |row|
@@ -32,21 +32,21 @@ export def "work create" [repo: string, ref: string]: string -> nothing {
3232
let path = $in
3333
cd $repo
3434

35-
exec { git worktree add --detach $path $ref }; ignore
35+
git worktree add --detach $path $ref; ignore
3636
}
3737

3838
export def "work list" []: string -> table<path: string, revision: string> {
3939
let path = $in
4040
cd $path
4141

42-
exec { git worktree list --porcelain }
42+
git worktree list --porcelain
4343
| split row "\n\n"
4444
| each { parse "worktree {path}\nHEAD {revision}\ndetached" }
4545
| flatten
4646
}
4747

48-
def exec [cmd: closure]: nothing -> string {
49-
let result = do $cmd | complete
48+
def --wrapped git [...args: string]: nothing -> string {
49+
let result = ^git ...$args | complete
5050

5151
if $result.exit_code != 0 {
5252
error make { msg: ($result.stderr | str trim) }

0 commit comments

Comments
 (0)