Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
go-gitlab
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
go-gitlab
Commits
c675fc56
Commit
c675fc56
authored
May 06, 2018
by
Zaq? Wiedmann
Committed by
Sander van Harmelen
May 06, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(merge_request_approvals) add support for un/approving merge requests (#386)
parent
3c94cb66
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
162 additions
and
80 deletions
+162
-80
README.md
README.md
+1
-1
gitlab.go
gitlab.go
+50
-48
merge_request_approvals.go
merge_request_approvals.go
+111
-0
merge_requests.go
merge_requests.go
+0
-31
No files found.
README.md
View file @
c675fc56
...
@@ -47,7 +47,7 @@ to add new and/or missing endpoints. Currently the following services are suppor
...
@@ -47,7 +47,7 @@ to add new and/or missing endpoints. Currently the following services are suppor
-
[
x
]
Labels
-
[
x
]
Labels
-
[
]
License
-
[
]
License
-
[
x
]
Merge Requests
-
[
x
]
Merge Requests
-
[
]
Merge Request Approvals
-
[
x
]
Merge Request Approvals
-
[
x
]
Project Milestones
-
[
x
]
Project Milestones
-
[
]
Group Milestones
-
[
]
Group Milestones
-
[
x
]
Namespaces
-
[
x
]
Namespaces
...
...
gitlab.go
View file @
c675fc56
...
@@ -267,54 +267,55 @@ type Client struct {
...
@@ -267,54 +267,55 @@ type Client struct {
UserAgent
string
UserAgent
string
// Services used for talking to different parts of the GitLab API.
// Services used for talking to different parts of the GitLab API.
AwardEmoji
*
AwardEmojiService
AwardEmoji
*
AwardEmojiService
Branches
*
BranchesService
Branches
*
BranchesService
BuildVariables
*
BuildVariablesService
BuildVariables
*
BuildVariablesService
BroadcastMessage
*
BroadcastMessagesService
BroadcastMessage
*
BroadcastMessagesService
Commits
*
CommitsService
Commits
*
CommitsService
DeployKeys
*
DeployKeysService
DeployKeys
*
DeployKeysService
Deployments
*
DeploymentsService
Deployments
*
DeploymentsService
Environments
*
EnvironmentsService
Environments
*
EnvironmentsService
Events
*
EventsService
Events
*
EventsService
Features
*
FeaturesService
Features
*
FeaturesService
GitIgnoreTemplates
*
GitIgnoreTemplatesService
GitIgnoreTemplates
*
GitIgnoreTemplatesService
Groups
*
GroupsService
Groups
*
GroupsService
GroupMembers
*
GroupMembersService
GroupMembers
*
GroupMembersService
GroupMilestones
*
GroupMilestonesService
GroupMilestones
*
GroupMilestonesService
Issues
*
IssuesService
Issues
*
IssuesService
IssueLinks
*
IssueLinksService
IssueLinks
*
IssueLinksService
Jobs
*
JobsService
Jobs
*
JobsService
Boards
*
IssueBoardsService
Boards
*
IssueBoardsService
Labels
*
LabelsService
Labels
*
LabelsService
MergeRequests
*
MergeRequestsService
MergeRequests
*
MergeRequestsService
Milestones
*
MilestonesService
MergeRequestApprovals
*
MergeRequestApprovalsService
Namespaces
*
NamespacesService
Milestones
*
MilestonesService
Notes
*
NotesService
Namespaces
*
NamespacesService
NotificationSettings
*
NotificationSettingsService
Notes
*
NotesService
PagesDomains
*
PagesDomainsService
NotificationSettings
*
NotificationSettingsService
Pipelines
*
PipelinesService
PagesDomains
*
PagesDomainsService
PipelineSchedules
*
PipelineSchedulesService
Pipelines
*
PipelinesService
PipelineTriggers
*
PipelineTriggersService
PipelineSchedules
*
PipelineSchedulesService
Projects
*
ProjectsService
PipelineTriggers
*
PipelineTriggersService
ProjectMembers
*
ProjectMembersService
Projects
*
ProjectsService
ProjectSnippets
*
ProjectSnippetsService
ProjectMembers
*
ProjectMembersService
ProtectedBranches
*
ProtectedBranchesService
ProjectSnippets
*
ProjectSnippetsService
Repositories
*
RepositoriesService
ProtectedBranches
*
ProtectedBranchesService
RepositoryFiles
*
RepositoryFilesService
Repositories
*
RepositoriesService
Runners
*
RunnersService
RepositoryFiles
*
RepositoryFilesService
Search
*
SearchService
Runners
*
RunnersService
Services
*
ServicesService
Search
*
SearchService
Session
*
SessionService
Services
*
ServicesService
Settings
*
SettingsService
Session
*
SessionService
Sidekiq
*
SidekiqService
Settings
*
SettingsService
Snippets
*
SnippetsService
Sidekiq
*
SidekiqService
SystemHooks
*
SystemHooksService
Snippets
*
SnippetsService
Tags
*
TagsService
SystemHooks
*
SystemHooksService
Todos
*
TodosService
Tags
*
TagsService
Users
*
UsersService
Todos
*
TodosService
Validate
*
ValidateService
Users
*
UsersService
Version
*
VersionService
Validate
*
ValidateService
Wikis
*
WikisService
Version
*
VersionService
Wikis
*
WikisService
}
}
// ListOptions specifies the optional parameters to various List methods that
// ListOptions specifies the optional parameters to various List methods that
...
@@ -376,6 +377,7 @@ func newClient(httpClient *http.Client, tokenType tokenType, token string) *Clie
...
@@ -376,6 +377,7 @@ func newClient(httpClient *http.Client, tokenType tokenType, token string) *Clie
c
.
Boards
=
&
IssueBoardsService
{
client
:
c
}
c
.
Boards
=
&
IssueBoardsService
{
client
:
c
}
c
.
Labels
=
&
LabelsService
{
client
:
c
}
c
.
Labels
=
&
LabelsService
{
client
:
c
}
c
.
MergeRequests
=
&
MergeRequestsService
{
client
:
c
,
timeStats
:
timeStats
}
c
.
MergeRequests
=
&
MergeRequestsService
{
client
:
c
,
timeStats
:
timeStats
}
c
.
MergeRequestApprovals
=
&
MergeRequestApprovalsService
{
client
:
c
}
c
.
Milestones
=
&
MilestonesService
{
client
:
c
}
c
.
Milestones
=
&
MilestonesService
{
client
:
c
}
c
.
Namespaces
=
&
NamespacesService
{
client
:
c
}
c
.
Namespaces
=
&
NamespacesService
{
client
:
c
}
c
.
Notes
=
&
NotesService
{
client
:
c
}
c
.
Notes
=
&
NotesService
{
client
:
c
}
...
...
merge_request_approvals.go
0 → 100644
View file @
c675fc56
package
gitlab
import
(
"fmt"
"net/url"
"time"
)
// MergeRequestApprovalsService handles communication with the merge request
// approvals related methods of the GitLab API. This includes reading/updating
// approval settings and approve/unapproving merge requests
//
// GitLab API docs: https://docs.gitlab.com/ee/api/merge_request_approvals.html
type
MergeRequestApprovalsService
struct
{
client
*
Client
}
// MergeRequestApprovals represents GitLab merge request approvals.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/merge_request_approvals.html#merge-request-level-mr-approvals
type
MergeRequestApprovals
struct
{
ID
int
`json:"id"`
ProjectID
int
`json:"project_id"`
Title
string
`json:"title"`
Description
string
`json:"description"`
State
string
`json:"state"`
CreatedAt
*
time
.
Time
`json:"created_at"`
UpdatedAt
*
time
.
Time
`json:"updated_at"`
MergeStatus
string
`json:"merge_status"`
ApprovalsRequired
int
`json:"approvals_required"`
ApprovalsLeft
int
`json:"approvals_left"`
ApprovedBy
[]
struct
{
User
struct
{
ID
int
`json:"id"`
Name
string
`json:"name"`
Username
string
`json:"username"`
State
string
`json:"state"`
AvatarURL
string
`json:"avatar_url"`
WebURL
string
`json:"web_url"`
}
`json:"user"`
}
`json:"approved_by"`
ApproverGroups
[]
struct
{
Group
struct
{
ID
int
`json:"id"`
Name
string
`json:"name"`
Path
string
`json:"path"`
Description
string
`json:"description"`
Visibility
string
`json:"visibility"`
AvatarURL
string
`json:"avatar_url"`
WebURL
string
`json:"web_url"`
FullName
string
`json:"full_name"`
FullPath
string
`json:"full_path"`
LFSEnabled
bool
`json:"lfs_enabled"`
RequestAccessEnabled
bool
`json:"request_access_enabled"`
}
`json:"group"`
}
`json:"approver_group"`
}
func
(
m
MergeRequestApprovals
)
String
()
string
{
return
Stringify
(
m
)
}
type
ApproveMergeRequestOptions
struct
{
Sha
*
string
`url:"sha,omitempty" json:"sha,omitempty"`
}
// ApproveMergeRequest approves a merge request on GitLab. If a non-empty sha
// is provided then it must match the sha at the HEAD of the MR.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/merge_request_approvals.html#approve-merge-request
func
(
s
*
MergeRequestApprovalsService
)
ApproveMergeRequest
(
pid
interface
{},
mrID
int
,
opt
*
ApproveMergeRequestOptions
,
options
...
OptionFunc
)
(
*
MergeRequestApprovals
,
*
Response
,
error
)
{
project
,
err
:=
parseID
(
pid
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
u
:=
fmt
.
Sprintf
(
"projects/%s/merge_requests/%d/approve"
,
url
.
QueryEscape
(
project
),
mrID
)
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
u
,
opt
,
options
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
m
:=
new
(
MergeRequestApprovals
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
m
)
if
err
!=
nil
{
return
nil
,
resp
,
err
}
return
m
,
resp
,
err
}
// UnapproveMergeRequest unapproves a previously approved merge request on GitLab.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/merge_request_approvals.html#unapprove-merge-request
func
(
s
*
MergeRequestApprovalsService
)
UnapproveMergeRequest
(
pid
interface
{},
mr
int
,
options
...
OptionFunc
)
(
*
Response
,
error
)
{
project
,
err
:=
parseID
(
pid
)
if
err
!=
nil
{
return
nil
,
err
}
u
:=
fmt
.
Sprintf
(
"projects/%s/merge_requests/%d/unapprove"
,
url
.
QueryEscape
(
project
),
mr
)
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
u
,
nil
,
options
)
if
err
!=
nil
{
return
nil
,
err
}
return
s
.
client
.
Do
(
req
,
nil
)
}
merge_requests.go
View file @
c675fc56
...
@@ -111,37 +111,6 @@ func (m MergeRequest) String() string {
...
@@ -111,37 +111,6 @@ func (m MergeRequest) String() string {
return
Stringify
(
m
)
return
Stringify
(
m
)
}
}
// MergeRequestApprovals represents GitLab merge request approvals.
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/merge_request_approvals.html#merge-request-level-mr-approvals
type
MergeRequestApprovals
struct
{
ID
int
`json:"id"`
ProjectID
int
`json:"project_id"`
Title
string
`json:"title"`
Description
string
`json:"description"`
State
string
`json:"state"`
CreatedAt
*
time
.
Time
`json:"created_at"`
UpdatedAt
*
time
.
Time
`json:"updated_at"`
MergeStatus
string
`json:"merge_status"`
ApprovalsRequired
int
`json:"approvals_required"`
ApprovalsLeft
int
`json:"approvals_left"`
ApprovedBy
[]
struct
{
User
struct
{
Name
string
`json:"name"`
Username
string
`json:"username"`
ID
int
`json:"id"`
State
string
`json:"state"`
AvatarURL
string
`json:"avatar_url"`
WebURL
string
`json:"web_url"`
}
`json:"user"`
}
`json:"approved_by"`
}
func
(
m
MergeRequestApprovals
)
String
()
string
{
return
Stringify
(
m
)
}
// MergeRequestDiffVersion represents Gitlab merge request version.
// MergeRequestDiffVersion represents Gitlab merge request version.
//
//
// Gitlab API docs:
// Gitlab API docs:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment