Closed maxrake closed 5 months ago
The change was tested and works as expected:
```bash ## Show the current released version of `phylum-ci` ❯ phylum-ci --version phylum-ci 0.44.0 ## Run with the current released version of `phylum-ci` ❯ phylum-ci -vv DEBUG Logging initialized to level 10 (DEBUG) DEBUG Phylum CLI version not specified DEBUG Found installed Phylum CLI version: 6.4.0+ DEBUG Minimum supported Phylum CLI version required for install: v6.0.0-rc3 DEBUG Making request to GitHub API URL: https://api.github.com/repos/phylum-dev/cli/releases DEBUG 59 GitHub API requests remaining until window resets at: Tue Jun 4 12:05:07 2024 Specified Phylum CLI version must be from a supported release: v6.5.0, v6.5.0-rc1, v6.4.0, v6.4.0-rc1, v6.3.0, v6.2.0, v6.1.2, v6.1.1, v6.1.1-rc1, v6.1.0, v6.0.1, v6.0.0, v6.0.0-rc3 ## Show the changes in this branch ❯ git diff diff --git a/src/phylum/init/cli.py b/src/phylum/init/cli.py index 1aab344..0690d99 100644 --- a/src/phylum/init/cli.py +++ b/src/phylum/init/cli.py @@ -68,7 +68,7 @@ def get_phylum_cli_version(cli_path: Path) -> str: except subprocess.CalledProcessError as err: msg = "There was an error retrieving the Phylum CLI version" raise PhylumCalledProcessError(err, msg) from err - version = version.removeprefix("phylum ") + version = version.removeprefix("phylum ").removesuffix("+") return version ## Run with the changes in this branch ❯ poetry run phylum-ci -vv DEBUG Logging initialized to level 10 (DEBUG) DEBUG Phylum CLI version not specified DEBUG Found installed Phylum CLI version: 6.4.0 DEBUG Minimum supported Phylum CLI version required for install: v6.0.0-rc3 DEBUG Making request to GitHub API URL: https://api.github.com/repos/phylum-dev/cli/releases DEBUG 58 GitHub API requests remaining until window resets at: Tue Jun 4 12:05:07 2024 INFO Using Phylum CLI version: v6.4.0 DEBUG No CI environment detected INFO Confirming pre-requisites ... DEBUG `git` binary found on the PATH INFO All pre-requisites met DEBUG Existing Phylum CLI instance found: 6.4.0 at /opt/homebrew/bin/phylum WARNING Existing version 6.4.0 does not match specified version v6.4.0 DEBUG Attempting to use existing version ... INFO Version checks succeeded. Using existing version. INFO Using Phylum CLI instance: 6.4.0 at /opt/homebrew/bin/phylum INFO Project name not provided as argument. Checking the `.phylum_project` file ... DEBUG Project name provided in `.phylum_project` file: phylum-ci INFO Attempting to create a Phylum project with the name: phylum-ci ... DEBUG Using Phylum group: phylum_bot INFO Project phylum-ci already exists. Continuing with it ... DEBUG Repository URL not available to set INFO No valid dependency files were provided as arguments. An attempt will be made to detect them. DEBUG Dependency files provided in `.phylum_project` file: [poetry.lock] INFO Parsing poetry.lock as poetry dependency file. Manifests take longer. DEBUG Determining viability of the Phylum sandbox in this environment ... DEBUG Executing command: /opt/homebrew/bin/phylum sandbox --allow-run / true INFO The Phylum sandbox works in this environment and will be enabled DEBUG Using parse command: /opt/homebrew/bin/phylum parse --type poetry /Users/maxrake/dev/phylum/phylum-ci/poetry.lock DEBUG Running command from: /Users/maxrake/dev/phylum/phylum-ci INFO Provided dependency file poetry.lock is a lockfile DEBUG Valid detected dependency files: [poetry.lock] DEBUG Dependency files in use: [poetry.lock] DEBUG Checking poetry.lock for changes ... DEBUG The dependency file poetry.lock has NOT changed WARNING No lockfile has changed. Nothing to do. ```
This fix accounts for the possibility of the Phylum CLI version reporting with a trailing
+
character. This is thecargo_suffix
and indicates when the version was obtained by Cargo instead of git, which happens for homebrew installed instances of the Phylum CLI.The fix here simply removes any trailing
+
character when obtaining the version from aphylum --version
command. This approach allows the rest of the version checking/handling code to remain intact.References:
git_version
crate docsCARGO_PKG_VERSION
envvar docsFixes #432