Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
golang-gitlab-gitlab-org-api-client-go
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Debian Go Packaging Team
packages
golang-gitlab-gitlab-org-api-client-go
Commits
c4ae36b0
Commit
c4ae36b0
authored
6 years ago
by
Sander van Harmelen
Browse files
Options
Downloads
Patches
Plain Diff
Make a custom marshaller for merge params
Fixes #626
parent
58470707
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
event_types.go
+75
-35
75 additions, 35 deletions
event_types.go
services.go
+1
-1
1 addition, 1 deletion
services.go
with
76 additions
and
36 deletions
event_types.go
+
75
−
35
View file @
c4ae36b0
...
...
@@ -17,6 +17,9 @@
package
gitlab
import
(
"encoding/json"
"fmt"
"strconv"
"time"
)
...
...
@@ -533,9 +536,7 @@ type MergeEvent struct {
LockedAt
string
`json:"locked_at"`
UpdatedByID
int
`json:"updated_by_id"`
MergeError
string
`json:"merge_error"`
MergeParams
struct
{
ForceRemoveSourceBranch
string
`json:"force_remove_source_branch"`
}
`json:"merge_params"`
MergeParams
*
MergeParams
`json:"merge_params"`
MergeWhenBuildSucceeds
bool
`json:"merge_when_build_succeeds"`
MergeUserID
int
`json:"merge_user_id"`
MergeCommitSHA
string
`json:"merge_commit_sha"`
...
...
@@ -594,6 +595,45 @@ type MergeEvent struct {
}
`json:"changes"`
}
// MergeParams represents the merge params.
type
MergeParams
struct
{
ForceRemoveSourceBranch
bool
`json:"force_remove_source_branch"`
}
// UnmarshalJSON decodes the merge parameters
//
// This allows support of ForceRemoveSourceBranch for both type bool (>11.9) and string (<11.9)
func
(
p
*
MergeParams
)
UnmarshalJSON
(
b
[]
byte
)
error
{
type
Alias
MergeParams
raw
:=
struct
{
*
Alias
ForceRemoveSourceBranch
interface
{}
`json:"force_remove_source_branch"`
}{
Alias
:
(
*
Alias
)(
p
),
}
err
:=
json
.
Unmarshal
(
b
,
&
raw
)
if
err
!=
nil
{
return
err
}
switch
v
:=
raw
.
ForceRemoveSourceBranch
.
(
type
)
{
case
nil
:
// No action needed.
case
bool
:
p
.
ForceRemoveSourceBranch
=
v
case
string
:
p
.
ForceRemoveSourceBranch
,
err
=
strconv
.
ParseBool
(
v
)
if
err
!=
nil
{
return
err
}
default
:
return
fmt
.
Errorf
(
"failed to unmarshal ForceRemoveSourceBranch of type: %T"
,
v
)
}
return
nil
}
// WikiPageEvent represents a wiki page event.
//
// GitLab API docs:
...
...
This diff is collapsed.
Click to expand it.
services.go
+
1
−
1
View file @
c4ae36b0
...
...
@@ -416,7 +416,7 @@ func (p *JiraServiceProperties) UnmarshalJSON(b []byte) error {
switch
id
:=
raw
.
JiraIssueTransitionID
.
(
type
)
{
case
nil
:
p
.
JiraIssueTransitionID
=
""
// No action needed.
case
string
:
p
.
JiraIssueTransitionID
=
id
case
float64
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment