Skip to content

git_ui: Always display "Create Pull Request" button on push toast - #53913

Merged
dinocosta merged 5 commits into
mainfrom
refactor-git-push-toast
Jun 15, 2026
Merged

git_ui: Always display "Create Pull Request" button on push toast#53913
dinocosta merged 5 commits into
mainfrom
refactor-git-push-toast

Conversation

@dinocosta

@dinocosta dinocosta commented Apr 14, 2026

Copy link
Copy Markdown
Member

Update the toast shown after running git: push so as to always include a button to create a pull request for the current branch.

We used to only do this on the initial push, as that is when the output of running git push would include an URL that could be used to create the Pull Request. However, since we now have a git: create pull request, we can always build this URL, meaning we no longer need to rely on the command's output in order to display the "Create Pull Request" button.

Something worth noting is that the git_ui::remote_output::format_output function used to also match on Bitbucket's terminal output, so these changes include the implementation of GitHostingProvider::build_create_pull_request_url for the Bitbucket provider.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content is consistent with the UI/UX checklist
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Release Notes:

  • Improved the toast shown after git: push to always display the "Create Pull Request" button

Ensure that we always show the "Create Pull Request" button when the
user pushes the changes, and not only when those are pushed the first
time or when the `git push` command outputs the Pull Request's URL,
seeing as we're now able to build these URLs on demand.
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Apr 14, 2026
@zed-community-bot zed-community-bot Bot added the staff Pull requests authored by a current member of Zed staff label Apr 14, 2026
@dinocosta
dinocosta force-pushed the refactor-git-push-toast branch from 319b8f0 to 45475ed Compare April 14, 2026 16:36
@dinocosta
dinocosta marked this pull request as ready for review April 21, 2026 10:44
@dinocosta
dinocosta added this pull request to the merge queue Jun 15, 2026
Merged via the queue into main with commit 62b4fd2 Jun 15, 2026
31 checks passed
@dinocosta
dinocosta deleted the refactor-git-push-toast branch June 15, 2026 08:50
This was referenced Jun 18, 2026
fly2xj added a commit to fly2xj/zed that referenced this pull request Jun 25, 2026
The post-push toast's "Create Pull Request" button regressed in zed-industries#53913:
it now always dispatches the git::CreatePullRequest action, which parses
the remote URL through the GitHostingProviderRegistry. For remotes whose
host has no registered provider (e.g. internal GitLab instances such as
git.woa.com), parse_git_remote_url returns None and the button fails
with "Unsupported remote URL".

Restore the pre-regression path: when git's push output contains a
create/view pull/merge request link on a remote: line, open that URL
directly instead of relying on a matching provider. Fall back to the
provider-based action only when no link is present, so known hosts
without a stderr link still work.
pull Bot pushed a commit to Mu-L/zed that referenced this pull request Jul 7, 2026
…ustries#60522)

## Summary

Fixes zed-industries#60288 and zed-industries#60454 .

After a push, the push toast's "Create Pull Request" button fails with
`Unsupported remote URL` when the repository's remote is not a plain,
recognized host. This restores the pre-zed-industries#53913 behavior as a fallback:
use the create-PR/MR link that `git push` itself prints, and only build
a URL from the provider registry when the push output had no link.

## Why this matters

zed-industries#53913 made the button always appear and changed `create_pull_request`
to reconstruct the PR URL from the remote via
`git::parse_git_remote_url` against the `GitHostingProviderRegistry`.
When the remote is not recognized, parsing returns `None` and the action
errors. This affects self-hosted GitLab/GitHub, an SSH-config host alias
like `git@personal:owner/repo` (the duplicate zed-industries#60076), and any
non-standard host. Before zed-industries#53913, the flow used the link git prints in
the push output, which works regardless of host, so this is a regression
for anyone not pushing to a plainly-recognized GitHub URL.

## Solution

`git push` prints a `remote:` line with the hosting provider's
create-PR/MR URL (GitHub: "Create a pull request for '\<branch>' on
GitHub by visiting:", GitLab: "To create a merge request for \<branch>,
visit:", Bitbucket: "Create pull request for \<branch>:"), and we
already hold the push `RemoteCommandOutput`.

- `remote_output.rs`: add `extract_pull_request_url`, which scans the
push stderr for the first `http(s)` URL on a `remote:` line tied to a
create-PR/MR prompt. It ignores unrelated URLs (for example the OpenSSH
post-quantum warning line).
- `git_panel.rs`: capture that URL in `show_remote_output` into
`pending_pull_request_url`, and prefer it in `create_pull_request`,
falling back to the existing provider construction only when the push
output had no link. The cached URL is consumed once (`take()`) and
cleared when the active repo, the active branch/head, or the pending
remote operation changes, so a later `git: Create Pull Request` action
never opens a stale URL from an earlier push.

Recognized GitHub remotes are unaffected: they still get a link from the
push output, with the provider path as the fallback.

## Testing

Unit tests in `remote_output.rs` cover `extract_pull_request_url` for
the GitHub, GitLab, and Bitbucket prompt formats, the no-link case
(returns `None`, so the provider fallback runs), and an output
containing an unrelated URL that must not be mistaken for the PR link.
The existing remote-operation test also asserts the cached URL is
cleared when a new operation starts.

`cargo test -p git_ui remote_output` passes (5 tests). Tested on macOS.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- Fixed "Create Pull Request" button in the toast shown after `git:
push` failing for repositories on unrecognized Git hosts by using the
link printed in the push output.
- Fixed the button shown on the toast after `git: push` for GitLab
branches with an existing merge request. It now shows "View Merge
Request" and links to the existing merge request.

---------

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: dino <dinojoaocosta@gmail.com>
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
…d-industries#53913)

Update the toast shown after running `git: push` so as to always include
a button to create a pull request for the current branch.

We used to only do this on the initial push, as that is when the output
of running `git push` would include an URL that could be used to create
the Pull Request. However, since we now have a `git: create pull
request`, we can always build this URL, meaning we no longer need to
rely on the command's output in order to display the "Create Pull
Request" button.

Something worth noting is that the
`git_ui::remote_output::format_output` function used to also match on
Bitbucket's terminal output, so these changes include the implementation
of `GitHostingProvider::build_create_pull_request_url` for the
`Bitbucket` provider.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Improved the toast shown after `git: push` to always display the
"Create Pull Request" button
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
…ustries#60522)

## Summary

Fixes zed-industries#60288 and zed-industries#60454 .

After a push, the push toast's "Create Pull Request" button fails with
`Unsupported remote URL` when the repository's remote is not a plain,
recognized host. This restores the pre-zed-industries#53913 behavior as a fallback:
use the create-PR/MR link that `git push` itself prints, and only build
a URL from the provider registry when the push output had no link.

## Why this matters

zed-industries#53913 made the button always appear and changed `create_pull_request`
to reconstruct the PR URL from the remote via
`git::parse_git_remote_url` against the `GitHostingProviderRegistry`.
When the remote is not recognized, parsing returns `None` and the action
errors. This affects self-hosted GitLab/GitHub, an SSH-config host alias
like `git@personal:owner/repo` (the duplicate zed-industries#60076), and any
non-standard host. Before zed-industries#53913, the flow used the link git prints in
the push output, which works regardless of host, so this is a regression
for anyone not pushing to a plainly-recognized GitHub URL.

## Solution

`git push` prints a `remote:` line with the hosting provider's
create-PR/MR URL (GitHub: "Create a pull request for '\<branch>' on
GitHub by visiting:", GitLab: "To create a merge request for \<branch>,
visit:", Bitbucket: "Create pull request for \<branch>:"), and we
already hold the push `RemoteCommandOutput`.

- `remote_output.rs`: add `extract_pull_request_url`, which scans the
push stderr for the first `http(s)` URL on a `remote:` line tied to a
create-PR/MR prompt. It ignores unrelated URLs (for example the OpenSSH
post-quantum warning line).
- `git_panel.rs`: capture that URL in `show_remote_output` into
`pending_pull_request_url`, and prefer it in `create_pull_request`,
falling back to the existing provider construction only when the push
output had no link. The cached URL is consumed once (`take()`) and
cleared when the active repo, the active branch/head, or the pending
remote operation changes, so a later `git: Create Pull Request` action
never opens a stale URL from an earlier push.

Recognized GitHub remotes are unaffected: they still get a link from the
push output, with the provider path as the fallback.

## Testing

Unit tests in `remote_output.rs` cover `extract_pull_request_url` for
the GitHub, GitLab, and Bitbucket prompt formats, the no-link case
(returns `None`, so the provider fallback runs), and an output
containing an unrelated URL that must not be mistaken for the PR link.
The existing remote-operation test also asserts the cached URL is
cleared when a new operation starts.

`cargo test -p git_ui remote_output` passes (5 tests). Tested on macOS.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- Fixed "Create Pull Request" button in the toast shown after `git:
push` failing for repositories on unrecognized Git hosts by using the
link printed in the push output.
- Fixed the button shown on the toast after `git: push` for GitLab
branches with an existing merge request. It now shows "View Merge
Request" and links to the existing merge request.

---------

Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
Co-authored-by: dino <dinojoaocosta@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants