-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
828 additions
and
316 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package tasks | ||
|
||
import ( | ||
"context" | ||
|
||
gitlab "github.com/xanzy/go-gitlab" | ||
) | ||
|
||
func FetchProjectMergeRequest(ctx context.Context, glab *gitlab.Client, pid int64, iid int64) (*gitlab.MergeRequest, error) { | ||
opt := gitlab.GetMergeRequestsOptions{} | ||
|
||
mr, _, err := glab.MergeRequests.GetMergeRequest(int(pid), int(iid), &opt, gitlab.WithContext(ctx)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return mr, nil | ||
} | ||
|
||
func FetchMergeRequestNotes(ctx context.Context, glab *gitlab.Client, pid interface{}, iid int) ([]*gitlab.Note, error) { | ||
opts := gitlab.ListMergeRequestNotesOptions{ | ||
ListOptions: gitlab.ListOptions{ | ||
Pagination: "keyset", | ||
PerPage: 100, | ||
OrderBy: "created_at", | ||
Sort: "desc", | ||
}, | ||
} | ||
|
||
options := []gitlab.RequestOptionFunc{ | ||
gitlab.WithContext(ctx), | ||
} | ||
|
||
var notes []*gitlab.Note | ||
for { | ||
ns, resp, err := glab.Notes.ListMergeRequestNotes(pid, iid, &opts, options...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
notes = append(notes, ns...) | ||
|
||
if resp.NextLink == "" { | ||
break | ||
} | ||
|
||
options = []gitlab.RequestOptionFunc{ | ||
gitlab.WithContext(ctx), | ||
gitlab.WithKeysetPaginationParameters(resp.NextLink), | ||
} | ||
} | ||
|
||
return notes, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.