Skip to content

Commit

Permalink
Support using Golang release candidates when install_std is set exp…
Browse files Browse the repository at this point in the history
…licitly (#266)

* Support using Golang release candidates when `install_std` is set explicitly

`semver_check` cannot handle Go release candidate versions like
`1.23rc2`, and so the if statement here would produce an error like:

```
plz-out/gen/go/build_defs/go.build_defs:48:26: error: failed to parse version: Invalid Semantic Version

    if version != "" and semver_check(version, ">= 1.20.0") and install_std is None:
```

This moves the check for `install_std` being explicitly set to before
the semver check, which allows skipping it.

* Make nullness check first, and strip off the RC for checking the version constraint
  • Loading branch information
toastwaffle authored Jul 18, 2024
1 parent eb6671a commit 66fd813
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Version 1.17.5
--------------
* Support using Golang release candidates when `install_std` is set explicitly

Version 1.17.4
--------------
* Prevent modfile from being exposed to downstream actions
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.17.4
1.17.5
6 changes: 5 additions & 1 deletion build_defs/go.build_defs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def go_toolchain(name:str, url:str|dict = '', version:str = '', hashes:list = []
hashes = hashes,
)

if version != "" and semver_check(version, ">= 1.20.0") and install_std is None:
if install_std is None and version != "" and semver_check(_strip_version_rc(version), ">= 1.20.0"):
install_std = True

return _go_toolchain(
Expand Down Expand Up @@ -1804,3 +1804,7 @@ def _stdlib():
stdlib = stdlib.removeprefix('///')
stdlib = f'///{CONFIG.OS}_{CONFIG.ARCH}{stdlib}'
return [stdlib]

def _strip_version_rc(version):
"""Removes an rcX suffix from a version string."""
return version.split('rc')[0]

0 comments on commit 66fd813

Please sign in to comment.