Skip to content

Add support for git remotes#42819

Merged
yara-blue merged 24 commits intozed-industries:mainfrom
bnjjj:bnjjj/feat_26559
Dec 4, 2025
Merged

Add support for git remotes#42819
yara-blue merged 24 commits intozed-industries:mainfrom
bnjjj:bnjjj/feat_26559

Conversation

@bnjjj
Copy link
Contributor

@bnjjj bnjjj commented Nov 15, 2025

Follow up of #42486
Closes #26559

Enregistrement.de.l.ecran.2025-11-15.a.22.43.44.mov

Release Notes:

  • Added support for git remotes

Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Nov 15, 2025
@bnjjj bnjjj changed the title Bnjjj/feat 26559 Add support for git remotes Nov 15, 2025
Comment on lines 288 to 296
cx.spawn(async move |_, cx| {
repo.update(cx, |repo, _| repo.create_remote(remote_name, remote_url))?
.await??;

Ok(())
})
.detach_and_prompt_err("Failed to create remote", window, cx, |e, _, _| {
Some(e.to_string())
});
Copy link
Contributor

Choose a reason for hiding this comment

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

If this task can ever run for more than a second (e.g. poor internet) we should put a loading icon in the status bar. I'll be happy to help with this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you have examples in your codebase I would be interested

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok I added a loader

format!("refs/heads/{query}").into()
} else {
format!("refs/remotes/{query}").into()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these paths correct on non-unix systems (Windows)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes git references work the same on Windows

Comment on lines 4604 to 4612
unimplemented!();
// client
// .request(proto::GitCreateBranch {
// project_id: project_id.0,
// repository_id: id.to_proto(),
// branch_name,
// })
// .await?;

Copy link
Contributor

Choose a reason for hiding this comment

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

If you need help with creating the proto messages and handlers I'll be happy to pair with you on it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I did it

Comment on lines 1828 to 1843
let remote_names: HashSet<Remote> = String::from_utf8_lossy(&output.stdout)
.lines()
.filter(|line| !line.is_empty())
.filter_map(|line| {
let mut splitted_line = line.split_whitespace();
let remote_name = splitted_line.next()?;
let remote_url = splitted_line.next()?;

Some(remote::Remote {
name: remote_name.trim().to_string().into(),
url: RemoteUrl::from_str(remote_url).ok()?,
})
})
.collect();
Ok(remote_names)

Ok(remote_names.into_iter().collect())
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Seems like you're calling collect twice here. The first in when creating remote_names and the second when returning remote_names.into_iter().collect()

you should be able to get away with only one call to collect

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really because I just convert from an hashset to a vec

Comment on lines +1877 to +1882
fn remove_remote(&self, name: String) -> BoxFuture<'_, Result<()>> {
let repo = self.repository.clone();
self.executor
.spawn(async move {
let repo = repo.lock();
repo.remote_delete(&name)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: remove_remote and repo.remote_delete should have the same names IMO.

I personally prefer remove_remote/delete_remote because it's consistent with the naming pattern for the rest of the repository functions. Where it's verb_noun

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I completely agree with you but remote_delete comes from the external crate git2 https://docs.rs/git2/latest/git2/struct.Repository.html#method.remote_delete

Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
@bnjjj
Copy link
Contributor Author

bnjjj commented Nov 26, 2025

I think I need guidance on how to write tests for this kind of feature @Anthony-Eid if you're available

Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
@bnjjj
Copy link
Contributor Author

bnjjj commented Nov 27, 2025

I added some tests to also test the previous behavior with the branch and the new one with remote. Let me know if you want me to add other tests.

.border_color(cx.theme().colors().border_variant)
.child(
h_flex().gap_0p5().child(
ToggleButtonGroup::single_row(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know why but since ToggleButton no longer exists it looks like the style doesn't change when it's selected or not. When debugging I can see the Boolean being updated properly but maybe the style when a toggle button is selected is incorrect... I don't know

Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
client.add_entity_request_handler(Self::handle_change_branch);
client.add_entity_request_handler(Self::handle_create_branch);
client.add_entity_request_handler(Self::handle_rename_branch);
client.add_entity_request_handler(Self::handle_create_remote);
Copy link
Member

Choose a reason for hiding this comment

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

@dvdsk need to test this with test server or just cross fingers :)

Copy link
Member

Choose a reason for hiding this comment

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

look over the remote stuff in more detail and fix anything needed. (I should do this)

Copy link
Member

@yara-blue yara-blue left a comment

Choose a reason for hiding this comment

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

Amazing, I want this now. Some minor refactoring and we will check that collab works!

🥳 🥳 🥇

@yara-blue yara-blue assigned yara-blue and unassigned cole-miller Dec 1, 2025
bnjjj added 2 commits December 2, 2025 20:17
Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
@bnjjj
Copy link
Contributor Author

bnjjj commented Dec 2, 2025

cc @dvdsk It should be ready to review again :)

@bnjjj bnjjj requested a review from yara-blue December 2, 2025 19:19
Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
@yara-blue
Copy link
Member

cc @dvdsk It should be ready to review again :)

sorry GitHub did not notify me for some reason.....
thanks for reaching out on discord!

I'll review it right now.

Copy link
Member

@yara-blue yara-blue 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! Tests are super readable now. Like the is_new_branch solution too btw!

LGTM

@yara-blue yara-blue merged commit 4c51fff into zed-industries:main Dec 4, 2025
23 checks passed
baldwindavid added a commit to baldwindavid/zed that referenced this pull request Dec 4, 2025
* main: (155 commits)
  Add support for git remotes (zed-industries#42819)
  python: Improve sorting order of toolchains to give higher precedence to project-local virtual environments that are within current subproject (zed-industries#44141)
  Use buffer language when formatting with Prettier (zed-industries#43368)
  search: Fix sort order not being maintained in presence of open buffers (zed-industries#44135)
  bedrock: Support global endpoints and new regional endpoints (zed-industries#44103)
  linux: Spawn at least two background threads (zed-industries#44110)
  macos: Add missing file access entitlements (zed-industries#43609)
  Re-colorize the brackets when the theme changes (zed-industries#44130)
  Reduce priority of Windows thread pool work items (zed-industries#44121)
  Update fancy-regex (zed-industries#44120)
  Prefer to disable options over hiding (git panel entry context menu) (zed-industries#44102)
  tab_switcher: Subscribe to workspace events instead of pane events (zed-industries#44101)
  editor: Add active match highlight for buffer and project search (zed-industries#44098)
  Add more preview tab settings and fix janky behavior (zed-industries#43921)
  ai: Add an eval for the inline assistant (zed-industries#43291)
  Fix circular reference issue around PopoverMenu again (zed-industries#44084)
  Run `git2::Repository::find_remote` in the background (zed-industries#44092)
  Improve support for multiple registrations of  `textDocument/diagnostic` (zed-industries#43703)
  Revert "http_client: Add integrity checks for GitHub binaries using digest checks (zed-industries#43737)" (zed-industries#44086)
  editor: Fix blame hover not working when inline git blame is disabled (zed-industries#42992)
  ...
Anthony-Eid added a commit that referenced this pull request Dec 5, 2025
… on the branch name (#44206)

The bug was introduced in this recent PR:
#42819. Since it's still in
nightly, there is no need for release notes.

I also polished the feature a bit by:
- Ensuring branch names are always a single line so the branch picker's
uniform list uses the correct element height.
- Adding tooltip text for the filter remotes button.
- Fixing the create branch from default icon showing up for non-new
branch entries.

Release Notes:

- N/A
AlpSha pushed a commit to AlpSha/zed that referenced this pull request Dec 5, 2025
Follow up of zed-industries#42486 
Closes zed-industries#26559



https://github.com/user-attachments/assets/e2f54dda-a78b-4d9b-a910-16d51f98a111



Release Notes:

- Added support for git remotes

---------

Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
AlpSha pushed a commit to AlpSha/zed that referenced this pull request Dec 5, 2025
… on the branch name (zed-industries#44206)

The bug was introduced in this recent PR:
zed-industries#42819. Since it's still in
nightly, there is no need for release notes.

I also polished the feature a bit by:
- Ensuring branch names are always a single line so the branch picker's
uniform list uses the correct element height.
- Adding tooltip text for the filter remotes button.
- Fixing the create branch from default icon showing up for non-new
branch entries.

Release Notes:

- N/A
danilo-leal added a commit that referenced this pull request Dec 5, 2025
Follow up to #42819 and
#44206.

- Make this picker feel more consistent with other similar pickers
(namely, the project picker)
- Move actions to the footer and toggle them conditionally
- Only show the "Create" and "Create New From: {default}" when we're
selecting the "Create" list item _or_ when that item is the only
visible. This means I'm changing here the state transition to only
change to `NewBranch/NewRemote` if we only have those items available.
- Reuse more UI code and use components when available (e.g.,
`ListHeader`)
- Remove secondary actions from the list item

Next step (in another PR), will be refine the same picker in the
smaller, panel version.


https://github.com/user-attachments/assets/fe72ac06-c1df-4829-a8a4-df8a9222672f

Release Notes:

- N/A
@esthertrapadoux esthertrapadoux moved this to 🚢 Shipped by Community in Git board Dec 9, 2025
@esthertrapadoux esthertrapadoux moved this from Community PRs to Shipped by Community in Quality Week – December 2025 Dec 9, 2025
CherryWorm pushed a commit to CherryWorm/zed that referenced this pull request Dec 16, 2025
Follow up of zed-industries#42486 
Closes zed-industries#26559



https://github.com/user-attachments/assets/e2f54dda-a78b-4d9b-a910-16d51f98a111



Release Notes:

- Added support for git remotes

---------

Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
CherryWorm pushed a commit to CherryWorm/zed that referenced this pull request Dec 16, 2025
… on the branch name (zed-industries#44206)

The bug was introduced in this recent PR:
zed-industries#42819. Since it's still in
nightly, there is no need for release notes.

I also polished the feature a bit by:
- Ensuring branch names are always a single line so the branch picker's
uniform list uses the correct element height.
- Adding tooltip text for the filter remotes button.
- Fixing the create branch from default icon showing up for non-new
branch entries.

Release Notes:

- N/A
CherryWorm pushed a commit to CherryWorm/zed that referenced this pull request Dec 16, 2025
Follow up to zed-industries#42819 and
zed-industries#44206.

- Make this picker feel more consistent with other similar pickers
(namely, the project picker)
- Move actions to the footer and toggle them conditionally
- Only show the "Create" and "Create New From: {default}" when we're
selecting the "Create" list item _or_ when that item is the only
visible. This means I'm changing here the state transition to only
change to `NewBranch/NewRemote` if we only have those items available.
- Reuse more UI code and use components when available (e.g.,
`ListHeader`)
- Remove secondary actions from the list item

Next step (in another PR), will be refine the same picker in the
smaller, panel version.


https://github.com/user-attachments/assets/fe72ac06-c1df-4829-a8a4-df8a9222672f

Release Notes:

- N/A
someone13574 pushed a commit to someone13574/zed that referenced this pull request Dec 16, 2025
Follow up of zed-industries#42486 
Closes zed-industries#26559



https://github.com/user-attachments/assets/e2f54dda-a78b-4d9b-a910-16d51f98a111



Release Notes:

- Added support for git remotes

---------

Signed-off-by: Benjamin <5719034+bnjjj@users.noreply.github.com>
someone13574 pushed a commit to someone13574/zed that referenced this pull request Dec 16, 2025
… on the branch name (zed-industries#44206)

The bug was introduced in this recent PR:
zed-industries#42819. Since it's still in
nightly, there is no need for release notes.

I also polished the feature a bit by:
- Ensuring branch names are always a single line so the branch picker's
uniform list uses the correct element height.
- Adding tooltip text for the filter remotes button.
- Fixing the create branch from default icon showing up for non-new
branch entries.

Release Notes:

- N/A
someone13574 pushed a commit to someone13574/zed that referenced this pull request Dec 16, 2025
Follow up to zed-industries#42819 and
zed-industries#44206.

- Make this picker feel more consistent with other similar pickers
(namely, the project picker)
- Move actions to the footer and toggle them conditionally
- Only show the "Create" and "Create New From: {default}" when we're
selecting the "Create" list item _or_ when that item is the only
visible. This means I'm changing here the state transition to only
change to `NewBranch/NewRemote` if we only have those items available.
- Reuse more UI code and use components when available (e.g.,
`ListHeader`)
- Remove secondary actions from the list item

Next step (in another PR), will be refine the same picker in the
smaller, panel version.


https://github.com/user-attachments/assets/fe72ac06-c1df-4829-a8a4-df8a9222672f

Release Notes:

- N/A
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

Projects

Status: 🚢 Shipped by Community

Development

Successfully merging this pull request may close these issues.

Add UI for managing the configured remotes on a repository

4 participants