AutoYADM commit: 2025-04-03 16:20:18
This commit is contained in:
parent
d469713db1
commit
a770120992
1 changed files with 4 additions and 4 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue