-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Description
Summary
git_hosting_providers is missing documentation within the hosted Zed documentation
Adding
"git_hosting_providers": [
{
"provider": "gitlab",
"name": "Tdd",
"base_url": "https://git.tdd.io"
}to the setting works for parsing GitLab permalinks, but this is not documented anywhere
Original report:
Copy Permalink doesn't work with custom gitlab instances if the url doesn't contain "gitlab".
My gitlab instance looks like this:
git@git.tdd.io:engine/engine-api.git
Copy Permalink returns this error:
Failed to copy permalink: parsing Git remote URL

Description
Please fix the permalink logic to work correctly.
Adding a config setting for git instance mappings may be a viable option here.
Then the full url can be determined using the git remote and this config mapping to which provider it's on.
Additionally, it'd be nice to include the start and end line number for the permalink (my custom task below handles this)
Something like this:
"git": {
"remotes": [
{"host": "git.tdd.io", "provider": "gitlab"},
{"host": "github.com", "provider": "github"},
{"host": "bit.test.com", "provider": "bitbucket"}
]
}
Steps to reproduce:
- Set git remote to a url similar to the one above
- Select code
- Right click or execute command to copy permalink
- Notice Failure
Expected Behavior:
Copy the url to the clipboard
Actual Behavior:
Fails with error
Side Note
I was able to get this working using a custom task:
{
"label": "Copy GitLab Permalink To Selection",
"command": "REPO_URL=$(git remote get-url origin | sed -e \"s/^git@\\(.*\\):\\(.*\\)\\.git$/https:\\/\\/\\1\\/\\2/\"); COMMIT_SHA=$(git log -1 --format=\"%H\" -- \"${ZED_RELATIVE_FILE}\"); echo \"${REPO_URL}/blob/${COMMIT_SHA}/${ZED_RELATIVE_FILE}#L${ZED_ROW}-$(echo $(($(wc -l <<< \"$ZED_SELECTED_TEXT\") + $ZED_ROW - 1)))\" | xclip -selection clipboard",
"cwd": "${ZED_WORKTREE_ROOT}",
"hide": "always",
"use_new_terminal": false,
"allow_concurrent_runs": true,
"tags": ["git"]
}
Zed Version and System Specs
Zed: v0.204.1 (Zed)
OS: Linux X11 linuxmint 22
Memory: 58.5 GiB
Architecture: x86_64
GPU: AMD Radeon 780M (RADV GFX1103_R1) || radv || Mesa 24.2.8-1ubuntu1~24.04.1
Metadata
Metadata
Assignees
Labels
Type
Projects
Status