Skip to content

MergeRequestEventPayload has improper unmarshalling for changes #98

Closed as not planned
@EmilLuta

Description

@EmilLuta

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions