Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trim kerl list releases #465

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
_KERL_REL=git
;;
*)
_VERSION=$(./kerl list releases | grep "^${_VERSION}" | tail -1)
_VERSION=$(./kerl list releases all | grep "^${_VERSION}" | tail -1)
_KERL_REL=${_VERSION}
;;
esac
Expand Down
34 changes: 23 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,20 @@ List the available releases:
<!-- markdownlint-disable MD007 # line-length -->
```console
$ kerl list releases
24.0-rc1
...
24.3.4.13
25.0-rc1
...
25.3.2.3
26.0-rc1
...
26.0.2
Run '/usr/local/bin/kerl update releases' to update this list from erlang.org

17.5.6.10
18.3.4.11
19.3.6.13
20.3.8.26
21.3.8.24
22.3.4.26
23.3.4.19
* 24.3.4.13
* 25.3.2.6
* 26.1
Run './kerl update releases' to update this list from erlang.org
Run './kerl list releases all' to view all available releases
Note: * means "currently supported"
```
<!-- markdownlint-enable MD007 # line-length -->

Expand Down Expand Up @@ -699,11 +703,19 @@ list of Erlang/OTP tags from the official Erlang/OTP GitHub repository.
### `list`

```console
$ kerl list <releases|builds|installations>
$ kerl list <releases|builds|installations> [all]
```

Lists the releases, builds or installations available.

When listing releases (without option `all`), the following applies:

- no release candidates are shown
- no "very old" releases are shown (depends on the current `kerl` version)
- versions included in the support policy are flagged with `*`

**Note**: using `all` means all available releases are shown without filters.

### `delete`

```console
Expand Down
68 changes: 59 additions & 9 deletions kerl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ if [ -n "$KERL_DEBUG" ]; then
fi

KERL_VERSION='3.1.0'
OLDEST_OTP_LISTED='17'
OLDEST_OTP_SUPPORTED='24'

ERLANG_DOWNLOAD_URL='https://erlang.org/download'
KERL_CONFIG_STORAGE_FILENAME='.kerl_config'
Expand Down Expand Up @@ -1922,9 +1924,41 @@ maybe_remove() {
}

list_print() {
if [ -f "$KERL_BASE_DIR/otp_$1" ]; then
if [ "$(\wc -l "$KERL_BASE_DIR/otp_$1")" != '0' ]; then
cat "$KERL_BASE_DIR/otp_$1"
list_type=$1 # releases | builds | installations
maybe_all=$2

list=$KERL_BASE_DIR/otp_${list_type}
if [ -f "$list" ]; then
if [ "$(\wc -l "$list")" != '0' ]; then
if [ "${list_type}" = releases ] && [ "$maybe_all" != all ]; then
awk -v oldest_listed="$OLDEST_OTP_LISTED" \
-v oldest_supported="$OLDEST_OTP_SUPPORTED" \
-v last_major="$OLDEST_OTP_LISTED" '
{
full_version=$0
split(full_version, version_components, ".")
major=version_components[1]
if (major >= oldest_listed && !/-rc/ && !/^R/) {
if (major > last_major) {
if (last_major >= oldest_supported) {
printf "* "
}

printf "%s\n",last_full_version
}
last_major=major
last_full_version=full_version
}
}
END {
if (!/-rc/) {
printf "* %s\n",$0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put the asterisk behind the version tag

Suggested change
printf "* %s\n",$0
printf "%s *\n",$0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll accept the suggestion, but also change the README at the same time, so I can't commit from this one 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
}' "$list"
else
cat "$KERL_BASE_DIR/otp_$1"
paulo-ferraz-oliveira marked this conversation as resolved.
Show resolved Hide resolved
fi

return 0
fi
fi
Expand Down Expand Up @@ -1962,7 +1996,7 @@ path_usage() {
}

list_usage() {
stderr "usage: $0 list <releases|builds|installations>"
stderr "usage: $0 list <releases|builds|installations> [all]"
}

delete_usage() {
Expand Down Expand Up @@ -2526,20 +2560,36 @@ upgrade)
fi
;;
list)
if [ $# -ne 2 ]; then
list_usage
exit 1
fi
case "$2" in
releases)
if [ $# -ne 2 ] && [ $# -ne 3 ]; then
list_usage
exit 1
fi
if [ $# -eq 3 ] && [ "$3" != 'all' ]; then
list_usage
exit 1
fi
check_releases
list_print "$2"
list_print "$2" "$3"
l=t stderr "Run '$0 update releases' to update this list from erlang.org"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're touching this area of code, I think this message should not mention the erlang.org website any more (since it really parses tags from github by default)

Suggested change
l=t stderr "Run '$0 update releases' to update this list from erlang.org"
l=t stderr "Run '$0 update releases' to update this list"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if [ $# -eq 2 ]; then
l=t stderr "Run '$0 list releases all' to view all available releases"
l=t stderr "Note: * means \"currently supported\""
fi
;;
builds)
if [ $# -ne 2 ]; then
list_usage
exit 1
fi
list_print "$2"
;;
installations)
if [ $# -ne 2 ]; then
list_usage
exit 1
fi
list_print "$2"
;;
*)
Expand Down