Skip to content

Commit

Permalink
ignore disabled repositories
Browse files Browse the repository at this point in the history
fixes #43

Signed-off-by: Markus Blaschke <mblaschke82@gmail.com>
  • Loading branch information
mblaschke committed Jul 30, 2022
1 parent 9ad76dd commit bf80c82
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions azure-devops-client/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ type Repository struct {
Visibility string
Size int64

IsDisabled *bool `json:"isDisabled"`

Links Links `json:"_links"`
}

Expand Down Expand Up @@ -128,3 +130,11 @@ func (c *AzureDevopsClient) ListPushes(project string, repository string, fromDa

return
}

func (r *Repository) Disabled() (ret bool) {
if r.IsDisabled != nil {
return *r.IsDisabled
}

return false
}
4 changes: 4 additions & 0 deletions metrics_pullrequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ func (m *MetricsCollectorPullRequest) Reset() {

func (m *MetricsCollectorPullRequest) Collect(ctx context.Context, logger *log.Entry, callback chan<- func(), project devopsClient.Project) {
for _, repository := range project.RepositoryList.List {
if repository.Disabled() {
continue
}

contextLogger := logger.WithField("repository", repository.Name)
m.collectPullRequests(ctx, contextLogger, callback, project, repository)
}
Expand Down
4 changes: 4 additions & 0 deletions metrics_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ func (m *MetricsCollectorRepository) Collect(ctx context.Context, logger *log.En
wg := sync.WaitGroup{}

for _, repository := range project.RepositoryList.List {
if repository.Disabled() {
continue
}

wg.Add(1)
go func(ctx context.Context, callback chan<- func(), project devopsClient.Project, repository devopsClient.Repository) {
defer wg.Done()
Expand Down

0 comments on commit bf80c82

Please sign in to comment.