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

fix bug on update_package.py #1162

Merged
merged 1 commit into from
Nov 22, 2024
Merged

fix bug on update_package.py #1162

merged 1 commit into from
Nov 22, 2024

Conversation

sara-rn
Copy link
Contributor

@sara-rn sara-rn commented Nov 8, 2024

fix issue #1142 for when --update-type is GITHUB_URL

@sara-rn sara-rn linked an issue Nov 8, 2024 that may be closed by this pull request
@sara-rn sara-rn force-pushed the main branch 2 times, most recently from a318015 to 85cec09 Compare November 11, 2024 12:50
@@ -37,7 +37,10 @@ def get_latest_version(org, project, version):
print(f"GitHub API response not ok: {response.status_code}")
return None
latest_version = response.json()["tag_name"]
return latest_version
if latest_version.startswith('v'):
Copy link
Member

Choose a reason for hiding this comment

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

@naacbin introduced the support for packages whose version is preceded by v in #1067, but it seems the v was only taken into account when matching the url in the file and not to get the latest version, so it seems like the fix has never worked.

What is really getting me confused is that I see upx being correctly updated by our bot in acec181 before #1067, how is this possible? 🕵️‍♀️

Copy link
Member

Choose a reason for hiding this comment

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

I still don't understand how it could work in acec181, but I think the change should fix the issue, so I think we can merge it. But I would still be interested in understanding how this broke, so please if someone (maybe @naacbin) has any clue let me know!

scripts/utils/update_package.py Outdated Show resolved Hide resolved
scripts/utils/update_package.py Outdated Show resolved Hide resolved
@Ana06 Ana06 requested a review from naacbin November 12, 2024 08:26
@Ana06 Ana06 added 🐛 bug Something isn't working 🏃 CI Related to CI labels Nov 15, 2024
Copy link
Member

@Ana06 Ana06 left a comment

Choose a reason for hiding this comment

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

@sara-rn can you please squash the commits? 😄

Copy link
Member

@Ana06 Ana06 left a comment

Choose a reason for hiding this comment

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

@sara-rn you have kept all commit messages in the squashed commit. Can you please reword the commit message to explain why the change is needed? For example:

Fix version bug in update_package.py

The regex to match the current tool version in `update_github_url ` does not 
include the `v`. However the function `get_latest_version` does include the `v` 
producing a URL with a duplicated `v` when replacing the current by the latest
version. Remove the `v` in `get_latest_version` to fix the issue.

You can do this with git commit --amend (easier in this case) or with git rebase -i HEAD~1 + r (which can be used to change the commit message of commits messages that are not the last one too).

I recommend reading https://cbea.ms/git-commit for more info on best practices to write good commit messages. 😉

@@ -37,7 +37,10 @@ def get_latest_version(org, project, version):
print(f"GitHub API response not ok: {response.status_code}")
return None
latest_version = response.json()["tag_name"]
return latest_version
if latest_version.startswith('v'):
Copy link
Member

Choose a reason for hiding this comment

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

I still don't understand how it could work in acec181, but I think the change should fix the issue, so I think we can merge it. But I would still be interested in understanding how this broke, so please if someone (maybe @naacbin) has any clue let me know!

The regex to match the current tool version in `update_github_url ` does not
include the `v`. However the function `get_latest_version` does include the `v`
producing a URL with a duplicated `v` when replacing the current by the latest
version. Remove the `v` in `get_latest_version` to fix the issue.
Copy link
Member

@Ana06 Ana06 left a comment

Choose a reason for hiding this comment

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

Thanks @sara-rn

@Ana06 Ana06 merged commit af8f530 into mandiant:main Nov 22, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working 🏃 CI Related to CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bot hasn't updated sclauncher
2 participants