Skip to content

Commit c019557

Browse files
author
Jeremy Desanlis
committed
feat(provider): add either a repository is private or not
1 parent 9f1b120 commit c019557

File tree

6 files changed

+16
-3
lines changed

6 files changed

+16
-3
lines changed

pipeline.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ type ResultGitFilePipelineEvent struct {
3535
type RepositoryPipelineEvent struct {
3636
// Finished is true if the given repository is pipeline is done
3737
Finished bool
38+
// either the repository is private or not
39+
Private bool
3840
// RepositoryName is the name of the repository
3941
RepositoryName string
4042
}
@@ -89,7 +91,7 @@ func (p *Pipeline) gather(
8991

9092
// ExtractRepository extracts for a single repository.
9193
func (p *Pipeline) ExtractRepository(repository provider.GitRepository, eventChan chan<- PipelineEvent) error {
92-
defer p.publishEvent(eventChan, RepositoryPipelineEvent{true, repository.GetName()})
94+
defer p.publishEvent(eventChan, RepositoryPipelineEvent{true, repository.GetPrivate(), repository.GetName()})
9395

9496
log.Infof("Cloning repo %v\n", repository.GetName())
9597

pipeline_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func (m gitRepositoryMock) GetSSHUrl() string { return "" }
3939
func (m gitRepositoryMock) GetHTTPUrl() string { return "" }
4040
func (m gitRepositoryMock) GetCreatedAt() time.Time { return time.Unix(0, 0) }
4141
func (m gitRepositoryMock) GetStorageSize() int64 { return 0 }
42+
func (m gitRepositoryMock) GetPrivate() bool { return true }
4243

4344
func createGitRepository(name string) provider.GitRepository {
4445
return gitRepositoryMock{name: name}
@@ -108,7 +109,7 @@ func (suite *PipelineTestSuite) TestExtractGitRepository() {
108109
// Author: firstCommit.Author,
109110
// Committer: firstCommit.Committer,
110111
// },
111-
RepositoryPipelineEvent{true, "repoName"},
112+
RepositoryPipelineEvent{true, true, "repoName"},
112113
}
113114

114115
provider.AssertExpectations(suite.T())
@@ -149,7 +150,7 @@ func (suite *PipelineTestSuite) TestExtractRepositories() {
149150
// Author: firstCommit.Author,
150151
// Committer: firstCommit.Committer,
151152
// },
152-
RepositoryPipelineEvent{true, "repoName"},
153+
RepositoryPipelineEvent{true, true, "repoName"},
153154
}
154155

155156
providerMock.AssertExpectations(suite.T())

provider/generic_repository.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ type Repository struct {
1515
httpURL string
1616
createdAt time.Time
1717
storageSize int64
18+
private bool
1819
}
1920

2021
// GetName returns the name of the repository.
@@ -32,6 +33,9 @@ func (r *Repository) GetCreatedAt() time.Time { return r.createdAt }
3233
// GetStorageSize returns the storage size of the repository.
3334
func (r *Repository) GetStorageSize() int64 { return r.storageSize }
3435

36+
// GetPrivate returns either the repository is private or not.
37+
func (r *Repository) GetPrivate() bool { return r.private }
38+
3539
type GenericProvider struct {
3640
}
3741

@@ -49,6 +53,7 @@ func (p *GenericProvider) Gather(user string) ([]GitRepository, error) {
4953
httpURL: user,
5054
createdAt: time.Time{},
5155
storageSize: 0,
56+
private: true,
5257
}}, nil
5358
}
5459

provider/github.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func createFromGithubRepo(r *github.Repository) *Repository {
3333
httpURL: r.GetHTMLURL(),
3434
createdAt: r.GetCreatedAt().Time,
3535
storageSize: int64(r.GetSize()),
36+
private: r.GetPrivate(),
3637
}
3738
}
3839

provider/gitlab.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func createFromGitlabRepo(r *gitlab.Project) *Repository {
6060
httpURL: r.HTTPURLToRepo,
6161
createdAt: *r.CreatedAt,
6262
storageSize: storageSize,
63+
private: !r.Public,
6364
}
6465
}
6566

provider/provider.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ type GitRepository interface {
2424

2525
// GetStorageSiwe is the size of the repository
2626
GetStorageSize() int64
27+
28+
// GetPrivate returns either the repository is private or not.
29+
GetPrivate() bool
2730
}
2831

2932
// Provider is the interface to implement for a Git provider.

0 commit comments

Comments
 (0)