Skip to content

Instantly share code, notes, and snippets.

@mu-hun
Last active October 21, 2021 03:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mu-hun/e8e51034f2a48178b740ac1ab0429cf6 to your computer and use it in GitHub Desktop.
Save mu-hun/e8e51034f2a48178b740ac1ab0429cf6 to your computer and use it in GitHub Desktop.
Open Azure repo in Browser from git remote url
function az() {
open `git remote get-url origin |
perl -pe 's#^git\@ssh\.dev\.azure\.com:v3/(.*)/(.*)$|^https://.*@dev.azure.com/(.*)/_git/(.*)$#https://dev.azure.com/\1\3/_git/\2\4#g'`
}

Open Azure repo in Browser from git remote url

  • git@ssh.dev.azure.com:v3/x86chi/repo ➡️ https://dev.azure.com/x86chi/_git/repo
  • https://x86chi@dev.azure.com/x86chi/_git/repo ➡️ https://dev.azure.com/x86chi/_git/repo
@simnalamburt
Copy link

simnalamburt commented Oct 20, 2021

두 케이스 모두 처리해주면서, perl과 git을 각각 1회씩만 호출하는 버전

function az() {
  git remote get-url origin |
    perl -pe 's#^git\@ssh\.dev\.azure\.com:v3/(.*)/(.*)$|^https://.*@dev.azure.com/(.*)/_git/(.*)$#https://dev.azure.com/\1\3/_git/\2\4#g'
}

아래와 같이 두 케이스 모두 잘 처리하는것을 확인할 수 있음

# Test
perl -pe 's#^git\@ssh\.dev\.azure\.com:v3/(.*)/(.*)$|^https://.*@dev.azure.com/(.*)/_git/(.*)$#https://dev.azure.com/\1\3/_git/\2\4#g' <<'EOF'
git@ssh.dev.azure.com:v3/x86chi/repo
https://x86chi@dev.azure.com/x86chi/_git/repo
EOF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment