Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@iamazeem
Copy link
Contributor

@iamazeem iamazeem commented Feb 3, 2025

Fixes #8320.

Flags (merge commit)

--merge-commit-message string              Default value for a merge commit message: {PR_BODY|PR_TITLE|BLANK}
--merge-commit-title string                Default value for a merge commit title: {PR_TITLE|MERGE_MESSAGE}

Flags (squash merge)

--squash-merge-commit-message string       Default value for a squash merge commit message: {PR_BODY|COMMIT_MESSAGES|BLANK}
--squash-merge-commit-title string         Default value for a squash merge commit title: {PR_TITLE|COMMIT_OR_PR_TITLE}

Test commands with valid combinations

## merge commit

# default message
$ bin/gh repo edit --merge-commit-title=MERGE_MESSAGE --merge-commit-message=PR_TITLE

# pull request title
$ bin/gh repo edit --merge-commit-title=PR_TITLE --merge-commit-message=BLANK

# pull request title and description
$ bin/gh repo edit --merge-commit-title=PR_TITLE --merge-commit-message=PR_BODY


## squash merge

# default message
$ bin/gh repo edit --squash-merge-commit-title=COMMIT_OR_PR_TITLE --squash-merge-commit-message=COMMIT_MESSAGES

# pull request title
$ bin/gh repo edit --squash-merge-commit-title=PR_TITLE --squash-merge-commit-message=BLANK

# pull request title and description
$ bin/gh repo edit --squash-merge-commit-title=PR_TITLE --squash-merge-commit-message=PR_BODY

# pull request title and commit details
$ bin/gh repo edit --squash-merge-commit-title=PR_TITLE --squash-merge-commit-message=COMMIT_MESSAGES

Sample invalid combination with error i.e. HTTP 422 Validation Failed

$ bin/gh repo edit --merge-commit-title=MERGE_MESSAGE --merge-commit-message=PR_BODY
HTTP 422: Validation Failed (https://api.github.com/repos/iamazeem/cli)
Repository.merge_commit_allowed is invalid

$ GH_DEBUG=api bin/gh repo edit --merge-commit-title=MERGE_MESSAGE --merge-commit-message=PR_BODY
[git remote -v]
[git config --get-regexp ^remote\..*\.gh-resolved$]
* Request at 2025-02-03 15:46:50.267265355 +0500 PKT m=+0.058248330
* Request to https://api.github.com/repos/iamazeem/cli
> PATCH /repos/iamazeem/cli HTTP/1.1
> Host: api.github.com
> Accept: application/vnd.github.merge-info-preview+json, application/vnd.github.nebula-preview
> Authorization: token β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
> Content-Length: 72
> Content-Type: application/json; charset=utf-8
> Time-Zone: Asia/Karachi
> User-Agent: GitHub CLI fab84beb

{
  "merge_commit_title": "MERGE_MESSAGE",
  "merge_commit_message": "PR_BODY"
}

< HTTP/2.0 422 Unprocessable Entity
< Access-Control-Allow-Origin: *
< Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset
< Content-Length: 445
< Content-Security-Policy: default-src 'none'
< Content-Type: application/json; charset=utf-8
< Date: Mon, 03 Feb 2025 10:46:50 GMT
< Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
< Server: github.com
< Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
< Vary: Accept-Encoding, Accept, X-Requested-With
< X-Accepted-Oauth-Scopes: 
< X-Content-Type-Options: nosniff
< X-Frame-Options: deny
< X-Github-Api-Version-Selected: 2022-11-28
< X-Github-Media-Type: github.v3; param=merge-info-preview.nebula-preview; format=json
< X-Github-Request-Id: 8402:5F6AE:47AD15:5ECC4A:67A09E9A
< X-Oauth-Client-Id: 178c6fc778ccc68e1d6a
< X-Oauth-Scopes: admin:public_key, codespace, gist, project, read:org, repo
< X-Ratelimit-Limit: 5000
< X-Ratelimit-Remaining: 4989
< X-Ratelimit-Reset: 1738580183
< X-Ratelimit-Resource: core
< X-Ratelimit-Used: 11
< X-Xss-Protection: 0

{
  "message": "Validation Failed",
  "errors": [
    {
      "message": "Sorry, invalid setting combination. The following are valid combinations for the merge commit title and message: PR_TITLE and PR_BODY, PR_TITLE and BLANK, MERGE_MESAGE and PR_TITLE. (invalid_merge_commit_setting_combo)",
      "resource": "Repository",
      "field": "merge_commit_allowed",
      "code": "invalid"
    }
  ],
  "documentation_url": "https://docs.github.com/rest/repos/repos#update-a-repository",
  "status": "422"
}

* Request took 858.044007ms
HTTP 422: Validation Failed (https://api.github.com/repos/iamazeem/cli)
Repository.merge_commit_allowed is invalid

@iamazeem iamazeem requested a review from a team as a code owner February 3, 2025 10:58
@iamazeem iamazeem requested a review from BagToad February 3, 2025 10:58
@cliAutomation cliAutomation added the external pull request originating outside of the CLI core team label Feb 3, 2025
@iamazeem iamazeem changed the title [gh repo edit] Allow setting commit title defaults [gh repo edit] Allow setting commit message defaults Feb 3, 2025
Copy link
Member

@BagToad BagToad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great and works great - thanks @iamazeem! ✨

My only complaint is that these flags require capital values which is inconsistent with other string enum flags across gh, but that's the API's fault, not yours ❀️

@BagToad BagToad merged commit 353799b into cli:trunk Feb 4, 2025
9 checks passed
@BagToad
Copy link
Member

BagToad commented Feb 4, 2025

I'm sorry @iamazeem, I have to revert this PR because @andyfeller just informed me of #10092 which is actually a duplicate of #8320 that we all sort of missed. #10092 has much more discussion on about the desired UX and different Acceptance Criteria for this feature.

Issues like #8320 unfortunately predate our team, which can cause these sorts of issues. We're going to discuss this problem more as a team.

I hope that makes sense, and I apologize for the bad news πŸ˜”

@iamazeem
Copy link
Contributor Author

iamazeem commented Feb 5, 2025

@BagToad: No worries! I totally missed that too. πŸ€”
Mapping to the UI makes more sense and is much better UX than mapping as-is it to the API. πŸ‘
That's what I personally felt too while working on it.

Regarding issues that predate the current team, the backlog could use fresh round(s) of triage.
Maybe, adding a note about the requirement of an acceptance criteria in the contribution guide would also be needed.


BTW, there's a typo in the API error message for invalid combination:

Sorry, invalid setting combination. The following are valid combinations for the merge commit title and message: PR_TITLE and PR_BODY, PR_TITLE and BLANK, MERGE_MESAGE and PR_TITLE. (invalid_merge_commit_setting_combo)

MERGE_MESAGE should be MERGE_MESSAGE.
Might need to be conveyed to the API team for fixing.

@BagToad
Copy link
Member

BagToad commented Feb 6, 2025

@BagToad: No worries! I totally missed that too. πŸ€”
Mapping to the UI makes more sense and is much better UX than mapping as-is it to the API. πŸ‘
That's what I personally felt too while working on it.

@iamazeem thank you for understanding πŸ™‡

Regarding issues that predate the current team, the backlog could use fresh round(s) of triage.
Maybe, adding a note about the requirement of an acceptance criteria in the contribution guide would also be needed.

All good feedback - I'm going to add this to the discussion with the team and see what we can do. It's been a topic of discussion on the team recently. We have been trying to figure out how we can prioritize this type of work.

BTW, there's a typo in the API error message for invalid combination:

Thanks good catch ✨ I passed that typo on to the team that owns this internally ❀️

tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Feb 13, 2025
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [cli/cli](https://github.com/cli/cli) | minor | `v2.66.1` -> `v2.67.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>cli/cli (cli/cli)</summary>

### [`v2.67.0`](https://github.com/cli/cli/releases/tag/v2.67.0): GitHub CLI 2.67.0

[Compare Source](cli/cli@v2.66.1...v2.67.0)

#### `gh pr checkout` now supports interactively selecting a pull request

Similar to commands like `gh workflow run` which prompts for a workflow to run, now `gh pr checkout` will prompt for a pull request to checkout. The list is currently limited to the most recent 10 pull requests in the repository.

https://github.com/user-attachments/assets/0b2e3761-7318-4573-8a23-ae6f1a44b018

Big thank you to [@&#8203;nilvng](https://github.com/nilvng) for implementing this πŸ™Œ

#### Contributing guidelines updated

We've updated our [`CONTRIBUTING.md`](https://github.com/cli/cli/blob/trunk/.github/CONTRIBUTING.md) guidelines to give more clarity around old `help wanted` issues.

*TLDR*:

-   Please directly mention `@cli/code-reviewers` when an issue you want to work on does not have clear Acceptance Criteria
-   Please only open pull requests for issues with *both*  the help wanted label and clear Acceptance Criteria
-   Please avoid expanding pull request scope to include changes that are not described in the connected issue's Acceptance Criteria

Note: Acceptance Criteria is posted as an issue comment by a core maintainer.

See cli/cli#10381 and cli/cli#10395 for more information.

❓ Have feedback on anything? We'd love to hear from you in a discussion post ❀️

#### What's Changed

##### ✨ Features

-   feat: let user select pr to checkout by [@&#8203;nilvng](https://github.com/nilvng) in cli/cli#9868
-   feat: Add support for deleting autolink references by [@&#8203;hoffm](https://github.com/hoffm) in cli/cli#10362
-   \[gh extensions install] Improve help text and error message by [@&#8203;iamazeem](https://github.com/iamazeem) in cli/cli#10333
-   Error when `gh repo rename` is used with a new repo name that contains an owner by [@&#8203;timrogers](https://github.com/timrogers) in cli/cli#10364
-   Attestation bundle fetch improvements by [@&#8203;malancas](https://github.com/malancas) in cli/cli#10233
-   \[gh project item-list] Add `iterationId` field in ProjectV2ItemFieldIterationValue by [@&#8203;iamazeem](https://github.com/iamazeem) in cli/cli#10329

##### πŸ› Fixes

-   \[gh api] Fix mutual exclusion messages of `--slurp` flag by [@&#8203;iamazeem](https://github.com/iamazeem) in cli/cli#10332
-   Exit with error if no matching predicate type exists by [@&#8203;kommendorkapten](https://github.com/kommendorkapten) in cli/cli#10421
-   Do not try to parse bodies for HEAD requests by [@&#8203;jsoref](https://github.com/jsoref) in cli/cli#10388
-   \[gh project item-edit] Fix number type by [@&#8203;iamazeem](https://github.com/iamazeem) in cli/cli#10374
-   \[gh workflow run] Improve error handling for `--ref` flag by [@&#8203;iamazeem](https://github.com/iamazeem) in cli/cli#10328
-   \[gh config] Escape pipe symbol in Long desc for website manual by [@&#8203;iamazeem](https://github.com/iamazeem) in cli/cli#10371

##### πŸ“š Docs & Chores

-   Fix logic error in contributing docs by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#10395
-   Docs: Clarify guidelines for `help wanted` issues and pull requests by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#10381
-   \[gh pr status] Mention `gh pr checks` in the `Long` section by [@&#8203;iamazeem](https://github.com/iamazeem) in cli/cli#10389
-   \[docs/releasing.md] Add basic info for homebrew update flow by [@&#8203;iamazeem](https://github.com/iamazeem) in cli/cli#10344
-   \[gh issue/pr list] Improve help text by [@&#8203;iamazeem](https://github.com/iamazeem) in cli/cli#10335
-   Remove v1 project 'add to board' automation from prauto workflow by [@&#8203;hoffm](https://github.com/hoffm) in cli/cli#10331
-   Note: the following pair of MRs was reverted and never made into a release
    -   \[gh repo edit] Allow setting commit message defaults by [@&#8203;iamazeem](https://github.com/iamazeem) in cli/cli#10363
    -   Revert "\[gh repo edit] Allow setting commit message defaults" by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#10372

##### :dependabot: Dependencies

-   Bump google.golang.org/protobuf from 1.36.4 to 1.36.5 by [@&#8203;dependabot](https://github.com/dependabot) in cli/cli#10379

**Full Changelog**: cli/cli@v2.66.1...v2.67.0

</details>

---

### Configuration

πŸ“… **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

β™» **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

πŸ”• **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4xNjUuMSIsInVwZGF0ZWRJblZlciI6IjM5LjE2NS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external pull request originating outside of the CLI core team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow setting commit title defaults in gh repo edit

3 participants