remove git-hub functions
This commit is contained in:
parent
a1a56ac63f
commit
dcc3265987
2 changed files with 0 additions and 80 deletions
|
@ -1,58 +0,0 @@
|
|||
#
|
||||
# Opens a GitHub repository in the default browser.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
if ! is-true "$(git rev-parse --is-inside-work-tree 2> /dev/null)"; then
|
||||
print "$0: not a repository work tree: $PWD" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
local remotes remote references reference file url
|
||||
|
||||
remote="${1:-origin}"
|
||||
remotes=($(git config --get-regexp 'remote.*.url' | cut -d. -f2))
|
||||
|
||||
if (( $remotes[(i)$remote] == $#remotes + 1 )); then
|
||||
print "$0: remote not found: $remote" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
url=$(
|
||||
git config --get "remote.${remote}.url" \
|
||||
| sed -En "s/(git|https?)(@|:\/\/)github.com(:|\/)(.+)\/(.+).git/https:\/\/github.com\/\4\/\5/p"
|
||||
)
|
||||
|
||||
reference="${${2:-$(git-branch-current)}:-HEAD}"
|
||||
references=(
|
||||
HEAD
|
||||
${$(git ls-remote --heads --tags "$remote" | awk '{print $2}')##refs/(heads|tags)/}
|
||||
)
|
||||
|
||||
if (( $references[(i)$reference] == $#references + 1 )); then
|
||||
print "$0: branch or tag not found: $reference" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ "$reference" == 'HEAD' ]]; then
|
||||
reference="$(git rev-parse HEAD 2>/dev/null)"
|
||||
fi
|
||||
|
||||
file="$3"
|
||||
|
||||
if [[ -n "$url" ]]; then
|
||||
url="${url}/tree/${reference}/${file}"
|
||||
|
||||
if (( $+commands[$BROWSER] )); then
|
||||
"$BROWSER" "$url"
|
||||
return 0
|
||||
else
|
||||
print "$0: browser not set or set to a non-existent browser" >&2
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
print "$0: not a Git repository or remote not set" >&2
|
||||
return 1
|
||||
fi
|
|
@ -1,22 +0,0 @@
|
|||
#
|
||||
# Shortens GitHub URLs.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
local url="$1"
|
||||
|
||||
if [[ "$url" == '-' ]]; then
|
||||
read url <&0
|
||||
fi
|
||||
|
||||
if [[ -z "$url" ]]; then
|
||||
print "usage: $0 [ url | - ]" >&2
|
||||
fi
|
||||
|
||||
if (( $+commands[curl] )); then
|
||||
curl -s -i 'http://git.io' -F "url=$url" | sed -n 's/^Location: //p'
|
||||
else
|
||||
print "$0: command not found: curl" >&2
|
||||
fi
|
Loading…
Reference in a new issue