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

Remove reference to removed VersionCheckFile #1481

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

twneale
Copy link
Collaborator

@twneale twneale commented Dec 19, 2024

Fix Version Check Path Bug

The version check code has a reference to a removed variable still present. This PR deletes it and closes #1480

🗣 Description

Deleted two lines of code writing out the version check file, which was removed for Kraken.

💭 Motivation and context

Currently this bug causes a error and stack trace on import.

🧪 Testing

Installed from PSGallery and imported ScubaGear.

✅ Pre-approval checklist

  • This PR has an informative and human-readable title.
  • PR targets the correct parent branch (e.g., main or release-name) for merge.
  • Changes are limited to a single goal - eschew scope creep!
  • Changes are sized such that they do not touch excessive number of files.
  • All future TODOs are captured in issues, which are referenced in code comments.
  • These code changes follow the ScubaGear content style guide.
  • Related issues these changes resolve are linked preferably via closing keywords.
  • All relevant type-of-change labels added.
  • All relevant project fields are set.
  • All relevant repo and/or project documentation updated to reflect these changes.
  • Unit tests added/updated to cover PowerShell and Rego changes.
  • Functional tests added/updated to cover PowerShell and Rego changes.
  • All relevant functional tests passed.
  • All automated checks (e.g., linting, static analysis, unit/smoke tests) passed.

✅ Pre-merge checklist

  • PR passed smoke test check.

  • Feature branch has been rebased against changes from parent branch, as needed

    Use Rebase branch button below or use this reference to rebase from the command line.

  • Resolved all merge conflicts on branch

  • Notified merge coordinator that PR is ready for merge via comment mention

  • Demonstrate changes to the team for questions and comments.
    (Note: Only required for issues of size Medium or larger)

✅ Post-merge checklist

  • Feature branch deleted after merge to clean up repository.
  • Verified that all checks pass on parent branch (e.g., main or release-name) after merge.

@twneale twneale added the bug This issue or pull request addresses broken functionality label Dec 19, 2024
@twneale twneale self-assigned this Dec 19, 2024
@twneale twneale requested review from schrolla and tkol2022 December 19, 2024 19:34
@schrolla schrolla changed the title Deleted reference to removed VersionCheckFile Remove reference to removed VersionCheckFile Dec 19, 2024
@schrolla
Copy link
Collaborator

@twneale Testing section should also include how the reviewers can test the code. Also, have you tested it when running from the ZIP to see if it's fully resolved there too?

@schrolla schrolla modified the milestones: Kraken, Lionfish Dec 19, 2024
Copy link
Collaborator

@schrolla schrolla left a comment

Choose a reason for hiding this comment

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

The removal of the test code is perfect. But while reviewing I had some other suggestions and a possible bug that requires more extensive changes. See comments below.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe the function Invoke-CheckScubaGearVersionPSGallery will fail if more than one version of ScubaGear is installed as the Get-Module will return an array rather than a single object causing the .Version field access to fail on the array and throw an exception.
I think a better approach would be to check if an array is returned, and select the highest version in the list as the installed version. Also, InstalledHighestVersion might be a better var name in this case as CurrentVersion is ambigious.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Recommend the function Invoke-CheckScubaGearVersionPSGallery name remove the PSGallery portion as, on fail, it checks GitHub as well, so it's really just the overall check. If you want a PSGallery specific function, then factor that out of the current function and call it as such using the return code to determine if the GitHub function needs to be called.

PowerShell/ScubaGear/CheckVersion.ps1 Outdated Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

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

The GitHub version check should be the same as the PSGallery check by coercing the version strings into System.Version types and comparing rather than relying on a string -ne operator. Both for consistency, and to allow pre-release versions that are newer than the Github release to not trigger the message.

Improved verbiage

Co-authored-by: Addam Schroll <108814318+schrolla@users.noreply.github.com>
@twneale twneale requested review from buidav and removed request for tkol2022 December 23, 2024 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue or pull request addresses broken functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ScubaGear throws warning during update check due to null path
2 participants