diff --git a/.config/helix/scripts/get_git_provider_url.fish b/.config/helix/scripts/get_git_provider_url.fish index 4d49582a..9ce59c4f 100755 --- a/.config/helix/scripts/get_git_provider_url.fish +++ b/.config/helix/scripts/get_git_provider_url.fish @@ -17,19 +17,19 @@ function get_git_provider_url --argument filename line_number # Determine the provider (GitHub, GitLab, etc.) if string match -q '*github.com*' $remote_url set provider github + set repo_path (echo $remote_url | perl -nE 'say $2 if /\.com(:|\/)(.*)\.git/') else if string match -q '*gitlab.com*' $remote_url set provider gitlab + set repo_path (echo $remote_url | perl -nE 'say $2 if /\.com(:|\/)(.*)\.git/') else if string match -q '*git.sr.ht*' $remote_url set provider srht + set repo_path (string match -r '.*:(~.+)' $remote_url) else echo "Error: Unsupported git provider." return 1 end # Extract the repo path and branch - set repo_path (echo $remote_url | perl -nE 'say $2 if /\.com(:|\/)(.*)\.git/') - echo $repo_path - return set branch (git rev-parse --abbrev-ref HEAD) # Generate the URL based on the provider @@ -39,7 +39,7 @@ function get_git_provider_url --argument filename line_number case gitlab echo "https://gitlab.com/$repo_path/-/blob/$branch/$filename#L$line_number" case srht - echo "https://git.sr.ht/$repo_path/-/blob/$branch/$filename#L$line_number" + echo "https://git.sr.ht/$repo_path/tree/$branch/item/$filename#L$line_number" end end