Last active
February 19, 2020 13:24
-
-
Save fliphess/568e29244b21f21fdb84de52480bf52b to your computer and use it in GitHub Desktop.
Easy visiting gitlab urls from your commandline on Mac OSX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
function usage() { | |
cat <<EOF | |
Open current git repo in your browser | |
Arguments: | |
--pipe - Show pipeline | |
--cr - Show container registry | |
--mr - Show merge requests | |
EOF | |
exit 1 | |
} | |
GITLINK="$( git-link | sed -e 's/\.git//' )" | |
if [ "$1" == "--help" ] || [ "$1" == "-h" ]; then | |
usage | |
elif [ "$1" == "--pipe" ] ; then | |
GITLINK="$GITLINK/pipelines" | |
elif [ "$1" == "--cr" ] ; then | |
GITLINK="$GITLINK/container_registry" | |
elif [ "$1" == "--mr" ] ; then | |
GITLINK="$GITLINK/merge_requests" | |
fi | |
/usr/bin/open "$GITLINK" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
import sys | |
import subprocess | |
def main(): | |
try: | |
command = "git remote -v | grep ^origin | awk '/push/ {print $2}'" | |
url = subprocess.check_output(command, shell=True) | |
url = url.decode().strip() | |
except Exception as e: | |
print("Error: {}".format(e)) | |
sys.exit(1) | |
if url.startswith('git@'): | |
url = url.replace(':', '/').replace('git@', 'https://') | |
print(url) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment