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

Rework lib/fixup.rb to not use an array for renaming and deleting packages #9784

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Zopolis4
Copy link
Collaborator

Fixes #9783.

lib/fixup.rb could use more work, but this is a start.

Also, js91 is deprecated but the package file is still in-tree?

Tested and working on x86_64.

Run the following to get this pull request's changes locally for testing.

# Reset to an older version of crew and install some renamed and deprecated packages first
CREW_REPO=https://github.com/Zopolis4/chromebrew.git CREW_BRANCH=grout crew update

@@ -54,7 +54,7 @@ def self.remove(pkg, verbose)
device_json['installed_packages'].delete_if { |entry| entry['name'] == pkg.name }

# Update device.json with our changes.
save_json(device_json)
File.write File.join(CREW_CONFIG_PATH, 'device.json'), JSON.pretty_generate(device_json.to_json)
Copy link
Member

Choose a reason for hiding this comment

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

Why change this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The previous code was failing in certain cases-- see attatched issue.

Copy link
Member

Choose a reason for hiding this comment

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

So the save_json function isn't working and that's the root cause?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The save_json function isn't working in this specific case-- not sure why it was working when we weren't running things from lib/fixup.rb. If I had to guess, its probably something to do with the fact that save_json isn't actually available in commands/remove.rb and is only there due to the leakage of us calling it from bin/crew, and that doesn't happen when we call it from lib/fixup.rb inside bin/crew despite not require'ing the function.

This is why I'm trying to split everything out into files, and then use files in lib for shared function implementations. Otherwise debugging these sort of issues gets pretty complicated.

Copy link
Member

Choose a reason for hiding this comment

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

so why not fix save_json?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think there's a problem with save_json-- the problem is that we're using save_json at all.

As I said:

If I had to guess, its probably something to do with the fact that save_json isn't actually available in commands/remove.rb and is only there due to the leakage of us calling it from bin/crew, and that doesn't happen when we call it from lib/fixup.rb inside bin/crew despite not require'ing the function.

@satmandu
Copy link
Member

I don't understand why using an array is bad? Isn't that simpler and cleaner?

@Zopolis4
Copy link
Collaborator Author

It means we have to have an unnecessary pkg_rename: nil or pkg_deprecated: nil for each package, and also we need to pass an unnecessary comments: nil in most cases.

@Zopolis4
Copy link
Collaborator Author

Compare:

  { pkg_name: 'qtwebglplugin', pkg_rename: 'qt5_webglplugin', pkg_deprecated: nil, comments: nil },
pkg_rename('qtwebglplugin', 'qt5_webglplugin')

@satmandu
Copy link
Member

Unit tests are failing.

@Zopolis4
Copy link
Collaborator Author

Fixed.

@Zopolis4 Zopolis4 requested a review from satmandu May 13, 2024 03:33
@satmandu
Copy link
Member

Honestly I'd be happier with the array being put in another file and just read in, as opposed to putting a bunch of deprecrated or whatever calls in a script file.

Is it not preferred to split data and code?

Also, please discuss refactoring in slack before spending a bunch of time implementing. This is a group project, and you need sign-off on how something is being architected from stakeholders. You can't just assume that because you put in the time, that people are going to be cool with it.

@Zopolis4
Copy link
Collaborator Author

Zopolis4 commented May 13, 2024

Honestly I'd be happier with the array being put in another file and just read in, as opposed to putting a bunch of deprecrated or whatever calls in a script file.

I don't see how moving the array into a different file changes anything?

Is it not preferred to split data and code?

My thinking was that this:

pkg_rename('qtwebglplugin', 'qt5_webglplugin')

was preferable to this:

  { pkg_name: 'qtwebglplugin', pkg_rename: 'qt5_webglplugin', pkg_deprecated: nil, comments: nil },

I just don't think an array is suitable for this sort of thing, given that we have to define every variable. In my view, representing this as a function call is better, because we only need to pass the arguments that we have.

This is a group project, and you need sign-off on how something is being architected from stakeholders. You can't just assume that because you put in the time, that people are going to be cool with it.

Not really sure what you're getting at-- this is a pull request, of course I am asking for sign-off here. This is me asking for feedback and comments on my changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lib/fixup.rb does not handle removing deprecated packages properly.
2 participants