Skip to content

Not differentiating between blank string and null causes difficulties in merging pull requests #1815

Closed
@john-m-liu

Description

@john-m-liu

(Github API doc is at https://docs.github.com/en/rest/reference/pulls#merge-a-pull-request)

When making a request to merge a pull request, there is a difference between the following:
curl -X PUT -H "Authorization: <token>" https://github.com/api/repos/{owner}/{repo}/pulls/{pull_number}/merge -d '{"merge_method": "squash", "commit_title": "my commit", "commit_message": ""}'
and
curl -X PUT -H "Authorization: <token>" https://github.com/api/repos/{owner}/{repo}/pulls/{pull_number}/merge -d '{"merge_method": "squash", "commit_title": "my commit"}'
Specifically, the former will have no commit message, and the latter will have the default commit message (typically the concatenation of all commit messages in the pull request).

This differentiation isn't possible with the go-github library because the following struct has omitempty: https://github.com/google/go-github/blob/master/github/pulls.go#L435. The default commit message will always be used if you pass the blank string.

I believe this is a specific case of #19 but was not addressed

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