Skip to content

Commit

Permalink
Skipping MRs with Merge Error.
Browse files Browse the repository at this point in the history
  • Loading branch information
Whyeasy committed Jul 15, 2020
1 parent 065cef1 commit cf0fb57
Showing 1 changed file with 34 additions and 30 deletions.
64 changes: 34 additions & 30 deletions lib/client/mergeRequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,21 +192,23 @@ func getMergedMergeRequests(c *gitlab.Client, errCh chan<- error, wg *sync.WaitG
return nil
}

duration, _ := time.ParseDuration(result.MergedAt.Sub(*result.CreatedAt).String())

resultMerged = append(resultMerged, MergeMergedStats{
MergedAt: result.MergedAt,
Duration: duration.Seconds(),
MergeRequest: MergeRequestStats{
ProjectID: strconv.Itoa(result.ProjectID),
ID: strconv.Itoa(result.ID),
CreatedAt: result.CreatedAt,
LastUpdated: result.UpdatedAt,
ChangeCount: result.ChangesCount,
Assignees: len(result.Assignees),
SourceBranch: result.SourceBranch,
},
})
if result.MergeError == "" {
duration, _ := time.ParseDuration(result.MergedAt.Sub(*result.CreatedAt).String())

resultMerged = append(resultMerged, MergeMergedStats{
MergedAt: result.MergedAt,
Duration: duration.Seconds(),
MergeRequest: MergeRequestStats{
ProjectID: strconv.Itoa(result.ProjectID),
ID: strconv.Itoa(result.ID),
CreatedAt: result.CreatedAt,
LastUpdated: result.UpdatedAt,
ChangeCount: result.ChangesCount,
Assignees: len(result.Assignees),
SourceBranch: result.SourceBranch,
},
})
}
}
log.Info(len(resultMerged), " Merged MRs")
wg.Done()
Expand All @@ -226,21 +228,23 @@ func getClosedMergeRequests(c *gitlab.Client, errCh chan<- error, wg *sync.WaitG
return nil
}

duration, _ := time.ParseDuration(result.ClosedAt.Sub(*result.CreatedAt).String())

resultClosed = append(resultClosed, MergeClosedStats{
ClosedAt: result.ClosedAt,
Duration: duration.Seconds(),
MergeRequest: MergeRequestStats{
ProjectID: strconv.Itoa(result.ProjectID),
ID: strconv.Itoa(result.ID),
CreatedAt: result.CreatedAt,
LastUpdated: result.UpdatedAt,
ChangeCount: result.ChangesCount,
Assignees: len(result.Assignees),
SourceBranch: result.SourceBranch,
},
})
if result.MergeError == "" {
duration, _ := time.ParseDuration(result.ClosedAt.Sub(*result.CreatedAt).String())

resultClosed = append(resultClosed, MergeClosedStats{
ClosedAt: result.ClosedAt,
Duration: duration.Seconds(),
MergeRequest: MergeRequestStats{
ProjectID: strconv.Itoa(result.ProjectID),
ID: strconv.Itoa(result.ID),
CreatedAt: result.CreatedAt,
LastUpdated: result.UpdatedAt,
ChangeCount: result.ChangesCount,
Assignees: len(result.Assignees),
SourceBranch: result.SourceBranch,
},
})
}

}
log.Info(len(resultClosed), " Closed MRs")
Expand Down

0 comments on commit cf0fb57

Please sign in to comment.