-
Notifications
You must be signed in to change notification settings - Fork 22
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
[all][update.rb] feat: additional Update options #734
base: staging
Are you sure you want to change the base?
Conversation
lib/util/update.rb
Outdated
remote_repo = "https://raw.githubusercontent.com/elanthia-online/lich-5/refs/tags/v#{version}/lib/#{requested_file}" | ||
remote_repo = nil unless validate_url_request(remote_repo) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs correction to be:
remote_repo = "https://raw.githubusercontent.com/elanthia-online/lich-5/refs/tags/v#{version}/lib"
remote_repo = nil unless validate_url_request(File.join(remote_repo, requested_file))
Otherwise the follow-up download will have a double requested file at the end of the URL. Also wouldn't hurt to move the validation to after the case statement and then do a validate_url_request then before the File.delete section (after bad extension)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like the preceding feedback point, this also will simply error out if the specific URL doesn't exist - whether it's by version or by file, with an error message. However, in re-reviewing to ensure I had my fact correct, I believe there is a problem here to address. Specifically, with all of our subdirs, the above does not account for namespace / folder location nor is there any captured input from the user. While this fails out appropriately for a file misnamed in the lib folder, if fails out inappropriately for a file in a subfolder in lib.
I'll have to consider that solution. I'm not a huge fan of --lib=commons/gtk.rb
and all that might entail. I'm also not sure I'm interested in walking a specific version tree hunting for a file location either. Choices, choices. It's current location is intended to ensure no file activities (inluding zero byte file creation) occur before the determination is made. I'll look over it again, while solving the subfolder debacle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it does respect namespace/folder as you'd be passing it as --library=util\update.rb
in the path which is another reason why we need to ensure no "spaces" in library filenames or folder paths. The issue I see here is that you're appending the FILE to the end of the base URL here, and then further down below, doing that again via:
file.write URI.parse(File.join(remote_repo, requested_file)).open.read
So the remote_repo there has requested file already attached. So need to not do that in this section that I've attached the review comment too, similar to the other case sections are doing.
Also corrects rubocop error
This is a fundamental change to our update methodology. New feature is
;lich5-update --install --version=<tag> --lib=<file.rb>
--install is required to ensure this is really what the user wants
--version is required and must match an existing tag
--lib is optional and is intended to allow point update.
This needs thorough testing, but - I would strongly recommend you not test it against your existing cloned Lich. It does delete files / folders, making the commit status an absolute mess.
And remember during your testing, if you see something you didn't like,
;lich5-update --revert
is your best friend.