From e5b51eb26a25f064647d93f5510f0871dcf3d688 Mon Sep 17 00:00:00 2001 From: Sam Coe Date: Tue, 24 Aug 2021 10:32:13 -0700 Subject: [PATCH] Compatibility with gh 2.0.0 --- README | 1 - README.md | 21 +++++++++++++++++++++ gh-repo-explore | 40 ++++++++++++++++++++++++++++++++++++++++ go.mod | 6 +++--- go.sum | 11 ++++++----- 5 files changed, 70 insertions(+), 9 deletions(-) delete mode 100644 README create mode 100644 README.md create mode 100755 gh-repo-explore diff --git a/README b/README deleted file mode 100644 index 372ecff..0000000 --- a/README +++ /dev/null @@ -1 +0,0 @@ -gh-repo-explore diff --git a/README.md b/README.md new file mode 100644 index 0000000..5b03db2 --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# gh repo-explore + +A [gh](https://github.com/cli/cli) extension for interactively exploring a repo without cloning the entire repo. + +## installation + +```sh +gh extension install samcoe/gh-repo-explore +``` + +## usage + +```sh +# explore a repo +gh repo-explore samcoe/gh-repo-explore + +# explore specific branch of a repo +gh repo-explore samcoe/gh-repo-explore --branch trunk +``` + +Supports `--hostname` flag to explore repos on hosts other than `github.com`. diff --git a/gh-repo-explore b/gh-repo-explore new file mode 100755 index 0000000..2416bd3 --- /dev/null +++ b/gh-repo-explore @@ -0,0 +1,40 @@ +#!/bin/bash +set -e + +extensionPath="$(dirname "$0")" +arch="$(uname -m)" + +if uname -a | grep Msys > /dev/null; then + if [ $arch = "x86_64" ]; then + exec "${extensionPath}/dist/gh-repo-explore_windows_amd64/gh-repo-explore" "$@" + elif [ $arch = "i686" ]; then + exec "${extensionPath}/dist/gh-repo-explore_windows_386/gh-repo-explore" "$@" + elif [ $arch = "i386" ]; then + exec "${extensionPath}/dist/gh-repo-explore_windows_386/gh-repo-explore" "$@" + fi +elif uname -a | grep Darwin > /dev/null; then + if [ $arch = "x86_64" ]; then + exec "${extensionPath}/dist/gh-repo-explore_darwin_amd64/gh-repo-explore" "$@" + fi +elif uname -a | grep Linux > /dev/null; then + if [ $arch = "x86_64" ]; then + exec "${extensionPath}/dist/gh-repo-explore_linux_amd64/gh-repo-explore" "$@" + elif [ $arch = "i686" ]; then + exec "${extensionPath}/dist/gh-repo-explore_linux_386/gh-repo-explore" "$@" + elif [ $arch = "i386" ]; then + exec "${extensionPath}/dist/gh-repo-explore_linux_386/gh-repo-explore" "$@" + fi +fi + +if [ "$(which go)" = "" ]; then + echo "go must be installed to use this gh extension on this platform" + exit 1 +fi + +exe="cmd.out" + +cd "${extensionPath}" > /dev/null +go build -o "${exe}" +cd - > /dev/null + +exec "${extensionPath}/${exe}" "$@" diff --git a/go.mod b/go.mod index 67710eb..23b75be 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/samcoe/gh-repo-explore go 1.16 require ( - github.com/alecthomas/chroma v0.9.1 - github.com/gdamore/tcell/v2 v2.3.3 - github.com/rivo/tview v0.0.0-20210601084449-25fe82727029 + github.com/alecthomas/chroma v0.9.2 + github.com/gdamore/tcell/v2 v2.4.0 + github.com/rivo/tview v0.0.0-20210624165335-29d673af0ce2 ) diff --git a/go.sum b/go.sum index 6716a5a..c58285f 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 h1:smF2tmSOzy2Mm+0dGI2AIUHY+w0BUc+4tn40djz7+6U= github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI= -github.com/alecthomas/chroma v0.9.1 h1:cBmvQqRImzR5aWqdMxYZByND4S7BCS/g0svZb28h0Dc= -github.com/alecthomas/chroma v0.9.1/go.mod h1:eMuEnpA18XbG/WhOWtCzJHS7WqEtDAI+HxdwoW0nVSk= +github.com/alecthomas/chroma v0.9.2 h1:yU1sE2+TZbLIQPMk30SolL2Hn53SR/Pv750f7qZ/XMs= +github.com/alecthomas/chroma v0.9.2/go.mod h1:eMuEnpA18XbG/WhOWtCzJHS7WqEtDAI+HxdwoW0nVSk= github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 h1:JHZL0hZKJ1VENNfmXvHbgYlbUOvpzYzvy2aZU5gXVeo= github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0= github.com/alecthomas/kong v0.2.4/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE= @@ -15,8 +15,9 @@ github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko= github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= -github.com/gdamore/tcell/v2 v2.3.3 h1:RKoI6OcqYrr/Do8yHZklecdGzDTJH9ACKdfECbRdw3M= github.com/gdamore/tcell/v2 v2.3.3/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU= +github.com/gdamore/tcell/v2 v2.4.0 h1:W6dxJEmaxYvhICFoTY3WrLLEXsQ11SaFnKGVEXW57KM= +github.com/gdamore/tcell/v2 v2.4.0/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU= github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= @@ -28,8 +29,8 @@ github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRC github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rivo/tview v0.0.0-20210601084449-25fe82727029 h1:6dS+di2EacbrIFK+h/NxaKZMiWvUDYKleaIWYuBVEMo= -github.com/rivo/tview v0.0.0-20210601084449-25fe82727029/go.mod h1:IxQujbYMAh4trWr0Dwa8jfciForjVmxyHpskZX6aydQ= +github.com/rivo/tview v0.0.0-20210624165335-29d673af0ce2 h1:I5N0WNMgPSq5NKUFspB4jMJ6n2P0ipz5FlOlB4BXviQ= +github.com/rivo/tview v0.0.0-20210624165335-29d673af0ce2/go.mod h1:IxQujbYMAh4trWr0Dwa8jfciForjVmxyHpskZX6aydQ= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=