-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Git blame and URL #3035
Comments
Blame information I think could fit well into the core. See also #227 For opening the repo url, if you mean just opening up the main repository page, you can do that currently with a binding like [keys.normal]
space.o = ":sh gh repo view --web" for github repos. Provider-specific features (like in the plugin should not be in core: provider-specific logic like how to format git forge URLs is undesirable for core unless it's based on an open standard (which does not seem to exist for any of the popular git forges). |
For github i was thinking something like this where you can just get the repo open on a browser pointing to the exact file, branch and line. I think despite this being provider it's quite easily extendable and could work even before there are plugins. Later it could just be moved to plugins once they are available? |
I think that would be handy in a plugin but that's the provider-specific logic that I think is distasteful to add to core. I think it's ok in a git-lens-like plugin that focuses on it and can be added I suspect without too much effort in a fork. I'd prefer that it wouldn't be merged in here though, even temporarily. IMO, code that belongs in plugins shouldn't be added to core unless it can help advance other core features. File tree (#200) is a good example of this which was scoped as a plugin but is making its way into core (#2377). It adds a tree UI component that could be re-used else-where like in DAP or #1075. |
Since Is that currently possible, @the-mikedavis ? If not, that does seem like a generally useful enhancement. |
there could be some special vars that would get interpolated before running the command, eg: |
Hmm no I don't think we have any replacements set up yet but I think those would be a welcome contribution if they work across operating systems 👍 |
Thanks to the great work done by @obxhdx #196 (comment) and https://www.reddit.com/r/HelixEditor/comments/13x9a3z/integrating_fuzzylive_grepping_into_helix_my/ I was able to take what was done there and hack in a Git Blame in a similar fashion with Wezterm. Dependencies:
ConfigsHelix Config B = ":pipe-to wezterm cli split-pane -- helix-git-blame"
Shell Script in my path #!/usr/bin/env bash
# ~/bin/helix-git-blame
HELIX_PANE_ID=$(wezterm cli get-pane-direction Up)
FILE_LINE=$(wezterm cli get-text --pane-id $HELIX_PANE_ID)
RES=$(echo $FILE_LINE | rg -e "(?:NOR|INS|SEL)\s+(\S*)\s[^│]* (\d+):*.*" -o --replace '$1 $2')
FILE=$(echo $RES | choose 0)
LINE=$(echo $RES | choose 1)
git blame -L $LINE,+100 $FILE --color-by-age --color-lines |
fzf --ansi \
--border \
--delimiter ':' \
--height '100%' \
--multi \
--print-query --exit-0 \
--scrollbar '▍' Demo |
@icecreammatt Thanks and i made a working copy of it for those that using tmux like me. config.toml
helix-git-blame
|
I adapted this idea to open the current line as a link to github / gitlab (other sites should be easy to add). :) #!/usr/bin/env bash
HELIX_PANE_ID=$(wezterm cli get-pane-direction Up)
FILE_LINE=$(wezterm cli get-text --pane-id "$HELIX_PANE_ID")
RES=$(echo "$FILE_LINE" | rg -e "(?:NOR|INS|SEL)\s+(\S*)\s[^│]* (\d+):*.*" -o --replace '$1 $2')
FILE_PATH=$(echo "$RES" | choose 0)
LINE_NUMBER=$(echo "$RES" | choose 1)
# Extract the current Git branch name
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
# Extract the base URL for the remote repository (GitLab or GitHub)
REMOTE_URL=$(git remote get-url origin)
# Determine if the remote URL is for GitLab or GitHub
if [[ $REMOTE_URL == *"gitlab.com"* ]]; then
# GitLab
BASE_URL=$(echo "$REMOTE_URL" | sed -e 's/[email protected]://' -e 's/.git$//' -e 's/:/\//g')
COMPLETE_URL="https://gitlab.com/${BASE_URL}/-/blame/${BRANCH_NAME}/${FILE_PATH}#L${LINE_NUMBER}"
elif [[ $REMOTE_URL == *"github.com"* ]]; then
# GitHub
BASE_URL=$(echo "$REMOTE_URL" | sed -e 's/[email protected]://' -e 's/.git$//' -e 's/:/\//g')
COMPLETE_URL="https://github.com/${BASE_URL}/blame/${BRANCH_NAME}/${FILE_PATH}#L${LINE_NUMBER}"
else
echo "Remote repository is not supported. Only GitLab and GitHub URLs are supported."
exit 1
fi
# Open in the default web browser
xdg-open "$COMPLETE_URL" || open "$COMPLETE_URL" has to be run like this (to get the current line and filename): gitopen_demo.mp4 |
is there any progress on this? |
gitoxide, a rust implementation in rust, now provides a rust library interface to You can read a bit about it here in Byron's 2024 retrospective post (subheading "A very first gix blame"). I would really appreciate it if someone would take a stab at implementing it in helix. |
maybe i can take a look. Will keep this on radar and if i have some time I'll try to implement smth
|
Describe your feature request
Would be great to add a git blame hint (toggle on config)
As part of this, being able to go to the repo url with a key bind is very useful.
Both of these are provided by this vscode extension
Happy to also give a hand with this if the maintainers agree with this belonging on the editor itself as opposed to a plugin later (I feel like in the latter case we could add it now and move it out later)
The text was updated successfully, but these errors were encountered: