Skip to content

Instantly share code, notes, and snippets.

@dj1020
Created January 10, 2018 06:46
Show Gist options
  • Save dj1020/d1032cec9c67aeddde739c17801e6199 to your computer and use it in GitHub Desktop.
Save dj1020/d1032cec9c67aeddde739c17801e6199 to your computer and use it in GitHub Desktop.
Quick open gitlab/git repo page
getRepoUrl() {
local name='origin'
local gitUrl
local repoUrl
if [ ! -z "$1" ]; then
name="$1"
fi
gitUrl=`git remote get-url $name`
repoUrl=`php -r "echo str_replace([':', 'git@', '.git'], ['/', 'https://', ''], '${gitUrl}'); echo PHP_EOL;"`
echo $repoUrl
}
openGitRepo() {
local repoUrl
repoUrl=`getRepoUrl $1 $2 $3 $4`
echo "Open" $repoUrl
open $repoUrl
}
openGitMrPage() {
local repoUrl
repoUrl=`getRepoUrl $1 $2 $3 $4`
echo "Open" $repoUrl/merge_requests
open $repoUrl/merge_requests
}
openGitTagPage() {
local repoUrl
repoUrl=`getRepoUrl $1 $2 $3 $4`
echo "Open" $repoUrl/tags
open $repoUrl/tags
}
openGitPipelinePage() {
local repoUrl
repoUrl=`getRepoUrl $1 $2 $3 $4`
echo "Open" $repoUrl/pipelines
open $repoUrl/pipelines
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment