Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions scripts/env/cd
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,20 @@ __gvmp_find_closest_dot_go_pkgset() {
__gvmp_read_dot_go_version() {
local filepath="${1}"
local version=""
local regex='^(go([0-9]+(\.[0-9]+)*))$'
local regex='^((go)?([0-9]+(\.[0-9]+)*))$'

while IFS=$'\n' read -r _line; do
# skip comment lines
[[ "${_line}" =~ \#.* ]] && continue

# looking for pattern "go1.2[.3]"

Choose a reason for hiding this comment

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

Suggested change
# looking for pattern "go1.2[.3]"
# looking for pattern "[go]1.2[.3]"

if [[ "${_line}" =~ ${regex} ]]; then
version="${_line}"
if [[ "${_line}" = go* ]]; then
version="${_line}"
else
# if the version is not prefixed with "go" add it

Choose a reason for hiding this comment

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

just an icing on the cake - should we print the fact that we've added prefix?

version="go${_line}"
fi
Comment on lines +192 to +197

Choose a reason for hiding this comment

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

Suggested change
if [[ "${_line}" = go* ]]; then
version="${_line}"
else
# if the version is not prefixed with "go" add it
version="go${_line}"
fi
version="go${_line#go}"

break
fi
done <<< "$(cat "${filepath}")"
Expand Down