-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgitlab.go
42 lines (33 loc) · 841 Bytes
/
gitlab.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"strings"
"github.com/xanzy/go-gitlab"
)
func parseParamsFromDesc(str string) map[string]string {
params := make(map[string]string, 0)
inCodeBlock := false
for _, v := range strings.Split(str, "\n") {
if strings.Contains(v, "```env") {
inCodeBlock = true
continue
}
if !inCodeBlock {
continue
}
for param, val := range ParseParams(v) {
params[param] = val
}
if strings.Contains(v, "```") {
inCodeBlock = false
}
}
return params
}
func getMergeRequest(baseUrl, token, pid string, mergeRequest int) (*gitlab.MergeRequest, error) {
gitlabClient, err := gitlab.NewClient(token, gitlab.WithBaseURL(baseUrl))
if err != nil {
return nil, err
}
mr, _, err := gitlabClient.MergeRequests.GetMergeRequest(pid, mergeRequest, &gitlab.GetMergeRequestsOptions{})
return mr, err
}