Skip to content

Commit

Permalink
Merge pull request #18 from RakuyoKit/archive/1.2.2
Browse files Browse the repository at this point in the history
feat: Try to use git command to implement `list-all` command
  • Loading branch information
rakuyoMo authored May 13, 2024
2 parents 3f82583 + bf19b7c commit 200e4f1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
2 changes: 1 addition & 1 deletion bin/list-all
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ plugin_dir=$(dirname "$(dirname "$current_script_path")")
# shellcheck source=./lib/utils.bash
source "${plugin_dir}/lib/utils.bash"

list_all_versions | xargs echo
list_all_versions | sort_versions | xargs echo
25 changes: 7 additions & 18 deletions lib/utils.bash
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,15 @@ fail() {
exit 1
}

curl_opts=(-fsSL)

if [ -n "${GITHUB_API_TOKEN:-}" ]; then
curl_opts=("${curl_opts[@]}" -H "Authorization: token $GITHUB_API_TOKEN")
fi
sort_versions() {
sed 'h; s/[+-]/./g; s/.p\([[:digit:]]\)/.z\1/; s/$/.z/; G; s/\n/ /' |
LC_ALL=C sort -t. -k 1,1 -k 2,2n -k 3,3n -k 4,4n -k 5,5n | awk '{print $2}'
}

list_all_versions() {
RELEASES_URL="https://api.github.com/repos/${SOURCES_REPO_NAME}/releases"

curl_cmd="curl -s"
if [ -n "${GITHUB_API_TOKEN:-}" ]; then
curl_cmd="$curl_cmd -H \"Authorization: token $GITHUB_API_TOKEN\""
fi

# Fetch list of releases and get names of each release tag
eval "$curl_cmd $RELEASES_URL" |
grep tag_name |
sed 's/"tag_name": //g;s/"//g;s/,//g' |
(tac 2>/dev/null || tail -r) |
xargs
git ls-remote --tags --refs "https://github.com/${SOURCES_REPO_NAME}" |
grep -o 'refs/tags/.*' | cut -d/ -f3- |
sed 's/^v//'
}

download_style_file() {
Expand Down

0 comments on commit 200e4f1

Please sign in to comment.