zed/crates/git_hosting_providers
Jonathan Berkeley 01376d4926
git_hosting_providers: Add Gitiles provider (#63996)
Add Gitiles support to git hosting providers, to enable permalink / git
blame diff link features working for repositories browsed with Gitiles
(used by Gerrit).

Permalinks use the Gitiles URL format:
{base_url}/{repo}/+/{sha}/{path}#{line}

Configured via git_hosting_providers setting:

  { "provider": "gitiles", "name": "...", "base_url": "https://..." }

# Objective

- Add basic permalink + git blame linking support for another common Git
provider (Gerrit + Gitiles).

Gerrit/Gitiles is a self hosted setup used at several large
corporations, so it would be nice to have native support for it
alongside the other git hosting providers. It is relevant to many
people.

URL can vary substantially between different self hosted setups. URL can
be like https://gerrit.example.com or something more elaborate like
https://vcs.internal.example.com/plugins/gitiles.

This does not implement avatars or PR links (as the similar Chromium
provider does) since exact Gerrit setup (e.g. trailers used, avatars
used) can differ significantly between different self hosted instances.

It implements the fundamental Gitiles link part instead which is still
very useful, and is reliable; `base_url` can be set to the gitiles "Git
repositories on [instance]" [base
page](https://gerrit.googlesource.com/), and this integration will then
work.

## Solution

- Implements a new GitHostingProvider which constructs Gitiles format
permalinks based on the user config.

Implementation follows inspiration from other providers: Tangled /
Chromium (also Gitiles/Gerrit based but tied specifically to Chromium).

## Testing

- Unit tests cover the logic in this change.
- Built for Windows, performed exploratory testing (adding multiple
providers, different base_urls, trying a self hosted Gerrit instance vs
googlesource, git blame link through UI works, copy permalink via
right-click context menu in code works).

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments -> N/A
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines) -> N/A
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

## Showcase

#### "Copy permalink to line"
<img width="1958" height="677" alt="image"
src="https://github.com/user-attachments/assets/802a02af-db4e-4b9c-a7d5-ac26dc52cd7e"
/>

Above results in clipboard being set to:

https://gerrit.googlesource.com/gitiles/+/77d36f6ff5f50316daa82c6753af2c3217859df4/java/com/google/gitiles/GitilesUrls.java#34

#### Git blame diff view links to remote Gitiles view for the commit:
<img width="2242" height="808" alt="image"
src="https://github.com/user-attachments/assets/2792397a-83ae-4294-ae61-5a631975950d"
/>

Above example opens this link in browser:

https://gerrit.googlesource.com/gitiles/+/67c7844b7f7f228229c037cf297296874f50692c

---
`settings.json` for showcase example:
```json
  "git_hosting_providers": [
    {
      "provider": "gitiles",
      "name": "Gerrit Googlesource",
      "base_url": "https://gerrit.googlesource.com"
    }
  ],
```
---

Release Notes:

- Added `gitiles` as a Git hosting provider for Gitiles/Gerrit
deployments, enabling permalinks and navigation from git blame diff
view.

Co-authored-by: Christopher Biscardi <chris@christopherbiscardi.com>
2026-10-03 03:43:01 +00:00
..
src git_hosting_providers: Add Gitiles provider (#63996) 2026-10-03 03:43:01 +00:00
Cargo.toml Fix cargo shear warnings (#64340) 2026-09-17 08:49:31 +00:00
LICENSE-GPL