Skip to content

Take the merge button configuration into consideration while merging using the cli #2954

Closed

Description

@TomerFi

Describe the feature or problem you’d like to solve

I'm using:

gh version 1.5.0 (2021-01-21)
https://github.com/cli/cli/releases/tag/v1.5.0

I think it will be a good feature to make the cli take the repository configuration under consideration.
For instance, the Merge button configuration, the following configuration:

image

Will prevent merging commits in the UI,
but if one were to merge using the cli,
then this configuration is ignored.

Today, I had a typo while working with cli:
(extra space between the pr number and the squash parameter)

gh pr merge 22  --squash

That caused the pr to be merged without being squashed first.

Proposed solution

My expectation was for an error message to be displayed,
letting me know that merging commits is disallowed.

Fixing it required me to fetch, pull, amend and force push the repository.

Additional context

Activity

  1. added
    enhancement
    on Feb 12, 2021
  2. added
    more-info-needed
    on Feb 12, 2021
  3. mislav commented on Feb 12, 2021

    @mislav
    Contributor

    Thank you for reporting!

    (extra space between the pr number and the squash parameter)

    gh pr merge 22  --squash

    Hmm, I find this really odd! The extra space should not matter in most shells; --squash should have been interpreted as a normal flag.

    And even if you used the --merge flag instead, that would not work on the server with your repository settings, because you would have gotten an error: Merge commits are not allowed on this repository.

    In my testing, I cannot use gh pr merge to bypass repository setting. Could you try again and provide us with more info?

    Ref. #2224

  4. TomerFi commented on Feb 14, 2021

    @TomerFi
    Author

    @mislav
    Thank you for your response.
    I tested this again in a demo project, you are correct, I was wrong.
    This was my mistake.

    I seem to remember the up until recently when performing squash-&-merge on a PR with only one commit,
    The commit message was used for the merge and not the pr title,
    I was expecting the commit message but found the pr title was stated as the commit message.
    My mistake was not checking previous commits and automatically assuming that no squash was performed.
    This was o course, not the case.

    This feature request can be closed.

    Nevertheless,
    I could swear I remember the commit message was used for squashing prs with 1 commit.
    Was I mistaken?

  5. mislav commented on Feb 15, 2021

    @mislav
    Contributor

    I could swear I remember the commit message was used for squashing prs with 1 commit.

    Hmm, you might be right. By default on web, it looks like the commit message is being used by default for the squashed merge, whereas in GitHub CLI, the PR title is being used by default. Perhaps we should have the same defaults as the web. I'll consider ironing this out together with changes in #2896

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementmore-info-needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions