summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/generate/src_contribs.go50
1 files changed, 49 insertions, 1 deletions
diff --git a/cmd/generate/src_contribs.go b/cmd/generate/src_contribs.go
index eb611a3..2ace0fd 100644
--- a/cmd/generate/src_contribs.go
+++ b/cmd/generate/src_contribs.go
@@ -409,12 +409,60 @@ func (c Contribution) fetchLastUpdated() (time.Time, User, error) {
urlStr := "https://" + authority + "/api/v4/projects/" + url.QueryEscape(projectID) + "/merge_requests/" + mrnum
var obj struct {
+ ID int `json:"id"`
+
UpdatedAt time.Time `json:"updated_at"`
+
+ CreatedAt time.Time `json:"created_at"`
+ CreatedBy struct {
+ Username string `json:"username"`
+ WebURL string `json:"web_url"`
+ } `json:"author"`
+
+ MergedAt time.Time `json:"merged_at"`
+ MergedBy struct {
+ Username string `json:"username"`
+ WebURL string `json:"web_url"`
+ } `json:"merged_by"`
}
if err := httpGetJSON(urlStr, nil, &obj); err != nil {
return time.Time{}, User{}, err
}
- return obj.UpdatedAt, User{}, nil
+
+ retUpdatedAt := obj.UpdatedAt
+ var retUser User
+
+ if retUser == (User{}) && withinOneSecond(obj.CreatedAt, retUpdatedAt) {
+ retUser.Name = obj.CreatedBy.Username
+ retUser.URL = obj.CreatedBy.WebURL
+ }
+ if retUser == (User{}) && withinOneSecond(obj.MergedAt, retUpdatedAt) {
+ retUser.Name = obj.MergedBy.Username
+ retUser.URL = obj.MergedBy.WebURL
+ }
+ if retUser == (User{}) {
+ var notes struct {
+ Notes []struct {
+ UpdatedAt time.Time `json:"updated_at"`
+ Author struct {
+ Username string `json:"username"`
+ WebURL string `json:"web_url"`
+ } `json:"author"`
+ } `json:"notes"`
+ }
+ if err := httpGetJSON(fmt.Sprintf("https://%s/%s/noteable/merge_request/%d/notes", authority, projectID, obj.ID), map[string]string{"X-Last-Fetched-At": "0"}, &notes); err != nil {
+ return time.Time{}, User{}, err
+ }
+ for _, note := range notes.Notes {
+ if withinOneSecond(note.UpdatedAt, retUpdatedAt) {
+ retUser.Name = note.Author.Username
+ retUser.URL = note.Author.WebURL
+ break
+ }
+ }
+ }
+
+ return retUpdatedAt, retUser, nil
}
var ret time.Time