3
3
# Repos to monitor
4
4
5
5
def query-week-span [] {
6
- let site_table = [
7
- [site repo ];
8
- [Nushell nushell ]
9
- [Extension vscode-nushell-lang ]
10
- [Documentation nushell.github.io ]
11
- [Wasm demo ]
12
- [Nu_Scripts nu_scripts ]
13
- [RFCs rfcs ]
14
- [reedline reedline ]
15
- [Nana nana ]
16
- # ] [Jupyter jupyter]
17
- ]
18
-
19
- let query_prefix = " https://api.github.com/search/issues?q=repo:nushell/"
20
- let query_date = (seq date -- days 7 - r | get 6 )
21
- let per_page = " 100"
22
- let page_num = " 1" # need to implement iterating pages
23
- let colon = " %3A"
24
- let gt = " %3E"
25
- let eq = " %3D"
26
- let amp = " %26"
27
- let query_suffix = $" +is($colon )pr+is($colon )merged+merged($colon )($gt )($eq )($query_date )&per_page=100&page=1"
28
-
29
- for repo in $site_table {
30
- let query_string = $" ($query_prefix )($repo.repo )($query_suffix )"
31
- let site_json = (http get - u $env .GITHUB_USERNAME - p $env .GITHUB_PASSWORD $query_string | get items | select html_url user.login title )
6
+ # Update the '7' below to however many days it has been since the last TWiN
7
+ let query_date = (seq date -- days 21 - r | get 7 )
8
+
9
+ # The heading mappings for each repository. This is only
10
+ # used to display the Heading for each reposting in TWiN.
11
+ # Repos without a mapping (that have activity) will simply
12
+ # default to the repo name.
13
+ let repo_headings = {
14
+ nushell : Nushell
15
+ nushell.github.io : Documentation
16
+ reedline : reedline
17
+ nu_scripts : Nu_Scripts
18
+ nupm : NUPM
19
+ demo : Wasm
20
+ nufmt : nufmt
21
+ awesome-nu : " Awesome Nu"
22
+ tree-sitter-nu : Tree-sitter
23
+ new-nu-parser : " New nu-parser"
24
+ rfcs : RFCs
25
+ nana : Nana
26
+ integrations : Integrations
27
+ vscode-nushell-lang : " VSCode Extension"
28
+ nu_plugin_template : " Plugin Template"
29
+ grammar : Grammar
30
+ nu_jupyter : Jupyter
31
+ }
32
+
33
+ # If environment variables exists for GH username/pw, use
34
+ # them. If a token is available, it will take precedence,
35
+ # so passing an empty username/password isn't a problem.
36
+ let gh_username = ($env .GITHUB_USERNAME ? | default " " )
37
+ let gh_password = ($env .GITHUB_PASSWORD ? | default " " )
38
+ let gh_token = $env .GH_AUTH_TOKEN ? | default (try { gh auth token })
39
+ let headers = match $gh_token {
40
+ null => {}
41
+ _ => { Authorization : $' Bearer ($gh_token )' }
42
+ }
43
+
44
+ let repos = (
45
+ http get - H $headers - u $gh_username - p $gh_password https://api.github.com/users/nushell/repos?sort=pushed
46
+ | get name
47
+ | where $it != ' nightly'
48
+ | where $it != ' this_week_in_nu'
49
+ | first 30
50
+ )
51
+
52
+ for repo in $repos {
53
+ let query_string = (
54
+ $" https://api.github.com/search/issues"
55
+ | url parse
56
+ | merge {
57
+ params : {
58
+ q : $' repo:nushell/($repo ) is:pr is:merged merged:>=($query_date )'
59
+ page : 1
60
+ per_page : 100
61
+ }
62
+ }
63
+ | url join
64
+ )
65
+ let site_json = (
66
+ http get - H $headers - u $gh_username - p $gh_password $query_string
67
+ | get items
68
+ | select html_url user.login title
69
+ )
32
70
33
71
if not ($site_json | all { |it | $it | is-empty }) {
34
- print $" (char nl )## ($repo.site )(char nl )"
72
+ let heading_name = ($repo_headings | get - i $repo | default $repo )
73
+ print $" (char nl )## ($heading_name )(char nl )"
35
74
36
75
for user in ($site_json | group-by " user.login" | transpose user prs ) {
37
76
let user_name = $user.user
@@ -52,12 +91,18 @@ def query-week-span [] {
52
91
}
53
92
}
54
93
55
- # 2019-08-23 was the release of 0.2.0, the first public release
56
- let week_num = ((seq date - b ' 2019-08-23' - n 7 | length ) - 1 )
57
- print $" # This week in Nushell #($week_num )(char nl )"
94
+ let has_token = (try { gh auth token }) != null
95
+ let has_username_pw = ($env | get - i GITHUB_USERNAME | is-not-empty ) and ($env | get - i GITHUB_PASSWORD | is-not-empty )
58
96
59
- if ($env | get - i GITHUB_USERNAME | is-empty ) or ($env | get - i GITHUB_PASSWORD | is-empty ) {
60
- print ' Please set GITHUB_USERNAME and GITHUB_PASSWORD in $env to use this script'
97
+ if not ($has_token or $has_username_pw ) {
98
+ print " This script requires either a working GitHub client that returns `gh auth token` or"
99
+ print " $env.GITHUB_USERNAME and $env.GITHUB_PASSWORD. Neither were found."
61
100
} else {
101
+ # 2019-08-23 was the release of 0.2.0, the first public release
102
+
103
+ let week_num = ((seq date - b ' 2019-08-23' - n 7 | length ) - 1 )
104
+ print $" # This week in Nushell #($week_num )(char nl )"
105
+
62
106
query-week-span
63
107
}
108
+
0 commit comments