-
Notifications
You must be signed in to change notification settings - Fork 1
/
gh.nu
48 lines (45 loc) · 1.25 KB
/
gh.nu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/env nu
# gh.nu
export def gitignore [
--language (-l) ?: string # Language to bypass selection
--no-save (-n)
] {
let language = if not $language {
http get (
{
scheme: https
username: brunerm99
host: api.github.com
port: ""
path: $"gitignore/templates"
fragment: ""
} | url join) | input list -f
} else { $language }
print $"Fetching ($language) gitignore"
let gitignore = (http get (
{
scheme: https
username: brunerm99
host: api.github.com
port: ""
path: $"gitignore/templates/($language)"
fragment: ""
} | url join)
)
if not $no_save {
$gitignore | save .gitignore-test
}
}
# Get info on whether repos are ahead of remote
# Relies on zelp's creation of the project_cache.nuon file
# FIXME: Make tolerant of repos with no 'main' branch
export def ahead-info [] {
open ~/.local/share/zelp/project_cache.nuon |
filter { |prj| $prj.full_path | path join ".git" | path exists } |
insert origin_diff { |prj| git -C $prj.full_path log --oneline origin/main..HEAD | lines } |
insert commits_ahead { |prj| $prj.origin_diff | length }
}
# Return all repos ahead of remote
export def all-ahead [] {
ahead-info | where commits_ahead > 0
}