Skip to content

Commit

Permalink
updated git.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
HariSekhon committed May 9, 2024
1 parent f0c5e7b commit 9ebcc37
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions .bash.d/git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ git_url_base(){
local filter="${1:-.*}"
git remote -v |
{ grep "$filter" || : ; }|
awk '/git@|https:/{print $2}' |
awk '/git@|https:\/\/|ssh:\/\//{print $2}' |
head -n1 |
sed 's|^ssh://||;
s|^https://.*@||;
Expand All @@ -192,7 +192,9 @@ git_url_base(){
s|^|https://|;
s/\.git$//;
# Azure DevOps only puts this in https urls, not ssh, so strip for standardizing output
s|/_git/|/|;
# Update: actually dont do this because we cannot differentiate internal Azure DevOps
# by internal fqdn urls so it is better to leave this in
#s|/_git/|/|;
' |
perl -pe 's/:(?!\/\/)/\//'
}
Expand All @@ -206,7 +208,12 @@ gitbrowse(){
url_base="$(git_url_base "origin")"
fi
if [ -z "$url_base" ]; then
echo "git remote url not found for filter '$filter' or 'origin'"
echo -n "git remote url not found for filter '$filter'"
if [ "$filter" != "origin" ]; then
echo " or 'origin'"
else
echo
fi
return 1
fi
if [[ "$url_base" =~ github.com ]]; then
Expand All @@ -225,7 +232,9 @@ gitbrowse(){
url_base+="/-/blob/$default_branch/README.md"
fi
elif [[ "$url_base" =~ dev.azure.com ]]; then
url_base="${url_base%/*}/_git/${url_base##*/}"
# don't re-add this as it's no longer stripped out in git_url_base
# because we cannot differentiate internal Azure Devops by fqdn so need to leave it in
#url_base="${url_base%/*}/_git/${url_base##*/}"
if [ -z "$path" ]; then
url_base+="?path=/README.md&_a=preview"
fi
Expand Down

0 comments on commit 9ebcc37

Please sign in to comment.