-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rename get_crate_version to get_crate_latest_version
- Loading branch information
Showing
2 changed files
with
12 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
function get_crate_version() { | ||
|
||
# function: get_crate_latest_version | ||
# arg#1: crate name | ||
# returns: latest version number on crates.io | ||
# | ||
# this calls crates.io REST api via curl, that listing all versions of specified crate. | ||
# `jq` query filter for not yanked and extract version number. | ||
# sort semver and takes last one. | ||
function get_crate_latest_version() { | ||
curl -L https://crates.io/api/v1/crates/$1/versions | jq -r '.versions[] | select( .yanked == false) | .num' | sort --version-sort | tail -n 1 | ||
} | ||
|
||
export -f get_crate_version | ||
export -f get_crate_latest_version |