Skip to content

Commit 6bc76f6

Browse files
committed
Clean up the option names.
1 parent b80a06d commit 6bc76f6

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

githubfs.go

+11-5
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ type FS struct {
8282
type Option func(gfs *FS)
8383

8484
// WithURL provides a way to set the URL for the specific github instance to use.
85-
func WithURL(url string) Option {
85+
func WithGithubURL(url string) Option {
8686
return func(gfs *FS) {
8787
gfs.githubUrl = url
8888
}
8989
}
9090

9191
// WithRawURL provides a way to set the URL for downloading files via the web
9292
// interface vs. a tarball.
93-
func WithRawURL(url string) Option {
93+
func WithRawDownloadURL(url string) Option {
9494
return func(gfs *FS) {
9595
gfs.rawUrl = url
9696
}
@@ -103,9 +103,12 @@ func WithHttpClient(c *http.Client) Option {
103103
}
104104
}
105105

106-
// WithFullOrg instructs the filesystem to include all the repositories owned
106+
// WithOrg instructs the filesystem to include all the repositories owned
107107
// by an organization or user and the default branches of each repo.
108-
func WithFullOrg(org string, allowArchivedrepos ...bool) Option {
108+
//
109+
// Repos marked as archived are filtered unless allowArchivedrepos is set to
110+
// true.
111+
func WithOrg(org string, allowArchivedrepos ...bool) Option {
109112
with := false
110113
if len(allowArchivedrepos) > 0 {
111114
with = allowArchivedrepos[len(allowArchivedrepos)-1]
@@ -116,7 +119,8 @@ func WithFullOrg(org string, allowArchivedrepos ...bool) Option {
116119
}
117120

118121
// WithRepo configures a specific owner, repository and branchs to include. If
119-
// no branch is specified the default branch is selected.
122+
// no branch is specified the default branch is selected. Multiple branches may
123+
// be specified in one call.
120124
func WithRepo(org string, repo string, branches ...string) Option {
121125
if len(branches) == 0 {
122126
return func(gfs *FS) {
@@ -142,6 +146,8 @@ func WithRepo(org string, repo string, branches ...string) Option {
142146

143147
// WithThresholdInKB sets the maximum size to download the entire repository vs.
144148
// downloading the individual files.
149+
//
150+
// Defaults to downloading a repo snapshot if the repo is less than 10MB.
145151
func WithThresholdInKB(max int) Option {
146152
return func(gfs *FS) {
147153
gfs.threshold = max

githubfs_test.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ func TestNew(t *testing.T) {
3030
}, {
3131
description: "different github url",
3232
ghUrl: "https://example.com",
33-
opts: []Option{WithURL("https://example.com")},
33+
opts: []Option{WithGithubURL("https://example.com")},
3434
}, {
3535
description: "different http url",
3636
rawUrl: "https://example.com",
37-
opts: []Option{WithRawURL("https://example.com")},
37+
opts: []Option{WithRawDownloadURL("https://example.com")},
3838
}, {
3939
description: "different http client",
4040
nilHttpClient: true,
@@ -45,8 +45,8 @@ func TestNew(t *testing.T) {
4545
opts: []Option{WithThresholdInKB(10)},
4646
}, {
4747
description: "specify orgs and repos.",
48-
opts: []Option{WithFullOrg("foo"),
49-
WithFullOrg("bar", true),
48+
opts: []Option{WithOrg("foo"),
49+
WithOrg("bar", true),
5050
WithRepo("org", "repo"),
5151
WithRepo("cat", "repo", "branch1", "branch2"),
5252
},
@@ -149,22 +149,22 @@ func TestMostThings(t *testing.T) {
149149
expectErr: true,
150150
}, {
151151
description: "fetch a few of repos test",
152-
opts: []Option{WithFullOrg("org")},
152+
opts: []Option{WithOrg("org")},
153153
payload: []string{twoReposResponse},
154154
expect: []string{"org/.github/git", "org/.go-template/git"},
155155
}, {
156156
description: "fetch a few of repos spread across requests test",
157-
opts: []Option{WithFullOrg("org")},
157+
opts: []Option{WithOrg("org")},
158158
payload: []string{twoReposOneAtATimeResponse001, twoReposOneAtATimeResponse002},
159159
expect: []string{"org/.github/git", "org/.go-template/git"},
160160
}, {
161161
description: "fetch a disabled and archived repo.",
162-
opts: []Option{WithFullOrg("org")},
162+
opts: []Option{WithOrg("org")},
163163
payload: []string{twoReposOneDisabledResponse},
164164
unexpected: []string{"org/.github/git", "org/.go-template/git"},
165165
}, {
166166
description: "get an invalid response during fetching a single repo",
167-
opts: []Option{WithFullOrg("org")},
167+
opts: []Option{WithOrg("org")},
168168
payload: []string{invalidJsonResponse},
169169
expect: []string{"org/repo/git", "org/moved/git"},
170170
expectErr: true,
@@ -292,7 +292,7 @@ func TestMostThings(t *testing.T) {
292292

293293
server.Start()
294294

295-
tc.opts = append(tc.opts, WithURL(server.URL), WithRawURL(server.URL))
295+
tc.opts = append(tc.opts, WithGithubURL(server.URL), WithRawDownloadURL(server.URL))
296296
gfs := New(tc.opts...)
297297
require.NotNil(gfs)
298298

0 commit comments

Comments
 (0)