Skip to content

Commit 64cbc5a

Browse files
committed
feat(provider): add information when using the provider repository
When using the provider 'repository' we add options to precise a repo-name and whether the repo is private or not in the final outputs
1 parent 22bfb84 commit 64cbc5a

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

cmd/src-fingerprint/main.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,15 @@ func main() {
137137
Required: true,
138138
Usage: "vcs provider. options: 'gitlab'/'github'/'bitbucket'/'repository'",
139139
},
140+
&cli.StringFlag{
141+
Name: "repo-name",
142+
Usage: "Name of the repository to display in outputs if the provider is 'repository'",
143+
},
144+
&cli.BoolFlag{
145+
Name: "repo-is-private",
146+
Value: false,
147+
Usage: "Private status value to display in outputs if the provider is 'repository'",
148+
},
140149
&cli.StringFlag{
141150
Name: "token",
142151
Aliases: []string{"t"},
@@ -204,9 +213,11 @@ func mainAction(c *cli.Context) error {
204213
var srcCloner cloner.Cloner = cloner.NewDiskCloner(c.String("clone-dir"))
205214

206215
providerOptions := provider.Options{
207-
OmitForks: !c.Bool("extract-forks"),
208-
SkipArchived: c.Bool("skip-archived"),
209-
BaseURL: c.String("provider-url"),
216+
OmitForks: !c.Bool("extract-forks"),
217+
SkipArchived: c.Bool("skip-archived"),
218+
BaseURL: c.String("provider-url"),
219+
RepositoryName: c.String("repo-name"),
220+
RespositoryIsPrivate: c.Bool("repo-is-private"),
210221
}
211222

212223
defer func() {

provider/generic_repository.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ func (r *Repository) GetStorageSize() int64 { return r.storageSize }
3535
func (r *Repository) GetPrivate() bool { return r.private }
3636

3737
type GenericProvider struct {
38+
options Options
3839
}
3940

4041
func NewGenericProvider(options Options) Provider {
41-
return &GenericProvider{}
42+
return &GenericProvider{options}
4243
}
4344

4445
func (p *GenericProvider) Gather(user string) ([]GitRepository, error) {
@@ -47,11 +48,11 @@ func (p *GenericProvider) Gather(user string) ([]GitRepository, error) {
4748
}
4849

4950
return []GitRepository{&Repository{
50-
name: "",
51+
name: p.options.RepositoryName,
5152
httpURL: user,
5253
createdAt: time.Time{},
5354
storageSize: 0,
54-
private: true,
55+
private: p.options.RespositoryIsPrivate,
5556
}}, nil
5657
}
5758

provider/provider.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ type Options struct {
4242
OmitForks bool
4343
// SkipArchived will skip archived repositories
4444
SkipArchived bool
45+
// Repository private status to display in the output if the provider is 'repository'
46+
RespositoryIsPrivate bool
4547
// BaseURL is the base URL of the API
4648
BaseURL string
49+
// Repository name to display in the output if the provider is 'repository'
50+
RepositoryName string
4751
}

0 commit comments

Comments
 (0)