Skip to content

Commit

Permalink
Make install scripts use the latest tag for scripted installation, no…
Browse files Browse the repository at this point in the history
…t `main`
  • Loading branch information
hugsy authored Sep 12, 2023
1 parent 5d49c22 commit 309af2b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 4 additions & 2 deletions scripts/gef-extras.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
#
set -e

usage() { echo "Usage: $0 [-b <main|OtherBranchName>] [-p <path_to_install>]" 1>&2; exit 1; }
usage() { echo "Usage: $0 [-b <OtherBranchName|tag>] [-p <path_to_install>]" 1>&2; exit 1; }

branch="main"
latest_tag=$(curl -s "https://api.github.com/repos/hugsy/gef/tags" | grep "name" | head -1 | sed -e 's/"name": "\([^"]*\)",/\1/' -e 's/\s*//')

branch=${latest_tag}
while getopts ":b:p:" o; do
case "${o}" in
b)
Expand Down
7 changes: 6 additions & 1 deletion scripts/gef.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

set -e

branch="main"
curl_found=0
wget_found=0

Expand All @@ -22,13 +21,19 @@ if [ -f "${HOME}/.gdbinit" ]; then
fi

if [ $wget_found -eq 1 ]; then
latest_tag=$(wget -q -O- "https://api.github.com/repos/hugsy/gef/tags" | grep "name" | head -1 | sed -e 's/"name": "\([^"]*\)",/\1/' -e 's/\s*//')

# Get the hash of the commit
branch="${latest_tag}"
ref=$(wget -q -O- https://api.github.com/repos/hugsy/gef/git/ref/heads/${branch} | grep '"sha"' | tr -s ' ' | cut -d ' ' -f 3 | tr -d "," | tr -d '"')

# Download the file
wget -q "https://github.com/hugsy/gef/raw/${branch}/gef.py" -O "${HOME}/.gef-${ref}.py"
elif [ $curl_found -eq 1 ]; then
latest_tag=$(curl -s "https://api.github.com/repos/hugsy/gef/tags" | grep "name" | head -1 | sed -e 's/"name": "\([^"]*\)",/\1/' -e 's/\s*//')

# Get the hash of the commit
branch="${latest_tag}"
ref=$(curl --silent https://api.github.com/repos/hugsy/gef/git/ref/heads/${branch} | grep '"sha"' | tr -s ' ' | cut -d ' ' -f 3 | tr -d "," | tr -d '"')

# Download the file
Expand Down

0 comments on commit 309af2b

Please sign in to comment.