Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MergeRequestEventPayload has improper unmarshalling for changes #98

Open
EmilLuta opened this issue Nov 12, 2019 · 0 comments
Open

MergeRequestEventPayload has improper unmarshalling for changes #98

EmilLuta opened this issue Nov 12, 2019 · 0 comments

Comments

@EmilLuta
Copy link

EmilLuta commented Nov 12, 2019

By default, the changes field of the JSON will look something like this (according to: https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#merge-request-events):

...
"changes":
    "author_id": {
        "previous": null,
        "current": 1
    },
    "merge_params": {
        "previous": {
        },
        "current": {
            "force_remove_source_branch": "0"
        }
    },...
...

The current format looks as it follows:

type Changes struct {
	LabelChanges LabelChanges `json:"labels"`
}

// LabelChanges contains changes in labels associated with a GitLab issue or MR
type LabelChanges struct {
	Previous []Label `json:"previous"`
	Current  []Label `json:"current"`
}

// Label contains all of the GitLab label information
type Label struct {
	ID          int64      `json:"id"`
	Title       string     `json:"title"`
	Color       string     `json:"color"`
	ProjectID   int64      `json:"project_id"`
	CreatedAt   customTime `json:"created_at"`
	UpdatedAt   customTime `json:"updated_at"`
	Template    bool       `json:"template"`
	Description string     `json:"description"`
	Type        string     `json:"type"`
	GroupID     int64      `json:"group_id"`
}

I propose that this should be marked as (excuse my poor Golang):

type Changes map[string]Change

type Change struct {
    Current  interface{}
    Previous interface{}
}

Unless objections, I'll be providing a PR for this.

Thanks in advance!

@EmilLuta EmilLuta changed the title MergeRequestEventPayload has poor unmarshalling for changes MergeRequestEventPayload has improper unmarshalling for changes Nov 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant