Skip to content

Commit 3f75eb0

Browse files
thisisaaronlandthisisaaronland
andauthored
add -exclude-archived flag per issue #27 (#28)
Co-authored-by: thisisaaronland <thisisaaronland@localhost>
1 parent c46e2ad commit 3f75eb0

File tree

4 files changed

+43
-20
lines changed

4 files changed

+43
-20
lines changed

README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Usage of ./bin/wof-create-hook:
2121
Go through the motions but don't create webhooks.
2222
-exclude value
2323
Exclude repositories with this prefix
24+
-exclude-archived
25+
Exclude repos that have been archived.
2426
-hook-content-type string
2527
The content type for your webhook. (default "json")
2628
-hook-secret string
@@ -31,6 +33,8 @@ Usage of ./bin/wof-create-hook:
3133
The GitHub organization to create webhookd in.
3234
-prefix value
3335
Limit repositories to only those with this prefix
36+
-repo value
37+
A valid GitHub repository name
3438
-token string
3539
A valid GitHub API access token.
3640
```
@@ -141,22 +145,28 @@ Usage of ./bin/wof-clone-repos:
141145
Print (to STDOUT) the list of repository names for an organization.
142146

143147
```
144-
./bin/wof-list-repos -h
148+
> ./bin/wof-list-repos -h
145149
Usage of ./bin/wof-list-repos:
146-
-exclude string
150+
-debug
151+
Enable debug logging
152+
-ensure-commits
153+
Ensure that 1 or more files have been updated in the last commit
154+
-exclude value
147155
Exclude repositories with this prefix
156+
-exclude-archived
157+
Exclude repos that have been archived.
148158
-forked
149159
Only include repositories that have been forked
150160
-not-forked
151161
Only include repositories that have not been forked
152162
-org string
153163
The name of the organization to clone repositories from (default "whosonfirst-data")
154-
-prefix string
155-
Limit repositories to only those with this prefix (default "whosonfirst-data")
164+
-prefix value
165+
Limit repositories to only those with this prefix
156166
-token string
157167
A valid GitHub API access token
158168
-updated-since string
159-
A valid ISO8601 duration string (months are currently not supported)
169+
A valid Unix timestamp or an ISO8601 duration string (months are currently not supported)
160170
```
161171

162172
For example:

cmd/wof-create-hook/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ func main() {
3232
var exclude multi.MultiString
3333
flag.Var(&exclude, "exclude", "Exclude repositories with this prefix")
3434

35+
exclude_archived := flag.Bool("exclude-archived", false, "Exclude repos that have been archived.")
36+
3537
var repos multi.MultiString
3638
flag.Var(&repos, "repo", "A valid GitHub repository name")
3739

@@ -64,6 +66,8 @@ func main() {
6466

6567
opts.Prefix = prefix
6668
opts.Exclude = exclude
69+
opts.ExcludeArchived = *exclude_archived
70+
6771
// opts.Forked = *forked
6872
// opts.NotForked = *not_forked
6973
opts.AccessToken = *token

cmd/wof-list-repos/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ func main() {
2929
not_forked := flag.Bool("not-forked", false, "Only include repositories that have not been forked")
3030
token := flag.String("token", "", "A valid GitHub API access token")
3131

32+
exclude_archived := flag.Bool("exclude-archived", false, "Exclude repos that have been archived.")
33+
3234
ensure_commits := flag.Bool("ensure-commits", false, "Ensure that 1 or more files have been updated in the last commit")
3335

3436
debug := flag.Bool("debug", false, "Enable debug logging")
@@ -44,6 +46,7 @@ func main() {
4446
opts.AccessToken = *token
4547
opts.Debug = *debug
4648
opts.EnsureCommits = *ensure_commits
49+
opts.ExcludeArchived = *exclude_archived
4750

4851
if *updated_since != "" {
4952

organizations/organizations.go

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ import (
1212
)
1313

1414
type ListOptions struct {
15-
Prefix []string
16-
Exclude []string
17-
Forked bool
18-
NotForked bool
19-
AccessToken string
20-
PushedSince *time.Time
21-
Debug bool
22-
EnsureCommits bool
15+
Prefix []string
16+
Exclude []string
17+
Forked bool
18+
NotForked bool
19+
ExcludeArchived bool
20+
AccessToken string
21+
PushedSince *time.Time
22+
Debug bool
23+
EnsureCommits bool
2324
}
2425

2526
type CreateOptions struct {
@@ -32,13 +33,14 @@ type CreateOptions struct {
3233
func NewDefaultListOptions() *ListOptions {
3334

3435
opts := ListOptions{
35-
Prefix: []string{},
36-
Exclude: []string{},
37-
Forked: false,
38-
NotForked: false,
39-
AccessToken: "",
40-
PushedSince: nil,
41-
Debug: false,
36+
Prefix: []string{},
37+
Exclude: []string{},
38+
Forked: false,
39+
NotForked: false,
40+
ExcludeArchived: false,
41+
AccessToken: "",
42+
PushedSince: nil,
43+
Debug: false,
4244
}
4345

4446
return &opts
@@ -156,6 +158,10 @@ func ListReposWithCallback(org string, opts *ListOptions, cb func(repo *github.R
156158
continue
157159
}
158160

161+
if opts.ExcludeArchived && *r.Archived {
162+
continue
163+
}
164+
159165
if opts.PushedSince != nil {
160166

161167
if opts.Debug {

0 commit comments

Comments
 (0)