Created
August 22, 2018 04:18
-
-
Save sompylasar/2de2f3292646250c297637fece4c0fb7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/bash | |
set -eu | |
REPO_PATH=$1 | |
SHA=$2 | |
if [[ ! -d "${REPO_PATH}" ]]; then | |
exit -1 | |
fi | |
if [[ -z "${SHA}" ]]; then | |
exit -2 | |
fi | |
REPO_GITHUB_URL=`cd "${REPO_PATH}" && git remote get-url origin` | |
REPO_GITHUB_URL_SSH_PREFIX="[email protected]:" | |
REPO_GITHUB_URL_SSH_SUFFIX=".git" | |
REPO_GITHUB_URL_HTTPS_PREFIX="https://github.com/" | |
REPO_GITHUB_PATH=${REPO_GITHUB_URL} | |
REPO_GITHUB_PATH=${REPO_GITHUB_PATH/#$REPO_GITHUB_URL_SSH_PREFIX} | |
REPO_GITHUB_PATH=${REPO_GITHUB_PATH/%$REPO_GITHUB_URL_SSH_SUFFIX} | |
REPO_GITHUB_PATH=${REPO_GITHUB_PATH/#$REPO_GITHUB_URL_HTTPS_PREFIX} | |
URL="https://github.com/${REPO_GITHUB_PATH}/commit/${SHA}" | |
echo "${URL}" | |
open "${URL}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment