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

Have "rebar3 plugins upgrade" work without specifying plugin name #2521

Merged

Conversation

paulo-ferraz-oliveira
Copy link
Contributor

@paulo-ferraz-oliveira paulo-ferraz-oliveira commented Mar 28, 2021

Closes #2491.

As per the doc.s and a validation (over Slack), about the expected behaviour, this pull request aims at having rebar3 plugins upgrade (no target plugin) work.

@paulo-ferraz-oliveira paulo-ferraz-oliveira force-pushed the feature/rebar3_plugins_upgrade branch from 27c92d7 to de8bb90 Compare March 28, 2021 23:51
@paulo-ferraz-oliveira
Copy link
Contributor Author

Assumptions:

  1. global plugins are not to be updated with this command,
  2. local plugins (once found) will exist at least until the end of the execution of the command (which is why I foldl acc'ing on {ok, State}).

{_, LocalPluginsNames} = rebar_prv_plugins:list_local_plugins(State),
lists:foldl(
fun (LocalPluginName, {ok, StateAcc}) ->
upgrade(atom_to_list(LocalPluginName), StateAcc)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is going to be rather slow or costly... you're calling the whole upgrade procedure for each plugin one at a time, including analysis. I can merge this since it's better than the current behaviour, but I'd look in seeing if we could improve this at some point by letting the code from lines 70 to 80 handle a larger set of applications in a list to build them at once.
It's not urgent since people upgrade plugins rather rarely, but the code is currently suboptimal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, it's not urgent; and I will look into possibilities to improve it (this was mainly a first dirty approach to prove the concept). For context's sake: I've it plugged to CI, which means that I'm currently forced to know, beforehand, which plugins I want to upgrade and then do it. If it's in a generic Makefile, for example (whose consumers I know not what plugins chose), I could easily just call rebar3 plugins upgrade and let rebar3 take care of it. I'll change to draft to signal it's still ongoing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fred, while looking at this I just saw I'm not taking profiles into account, but it seems to work OK (still didn't do the proposed changes); is the state updated previously to make sure the profiles are those from the input?

Otherwise, I don't understand

    Profiles = rebar_state:current_profiles(State),
    case find_plugin(Plugin, Profiles, State) of
        not_found ->
            Dep = find_plugin(Plugin, [global], State);
        Dep ->
            Dep
    end,

Copy link
Collaborator

Choose a reason for hiding this comment

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

the global profile is one magic thing that is super odd. Otherwise, the merging of state and handling of profiles should be transparent and nobody should need to care about them. It's why we aim at people not needing to know which profiles they run under.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool, then I guess I might "bypass" those lines in my analysis, as you propose only looking at the 70-80 range.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We shouldn't block this PR on these improvements, they're more of a follow-up. Having something working slow is better than something that doesn't work at all in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm ready to merge this whenever you're happy to take it out of draft mode.

Oh, cool. I'm OK to do that just now.

src/rebar_prv_plugins.erl Outdated Show resolved Hide resolved
@paulo-ferraz-oliveira paulo-ferraz-oliveira marked this pull request as draft March 29, 2021 19:27
Copy link
Collaborator

@ferd ferd left a comment

Choose a reason for hiding this comment

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

I'm ready to merge this whenever you're happy to take it out of draft mode.

@paulo-ferraz-oliveira paulo-ferraz-oliveira marked this pull request as ready for review April 2, 2021 14:20
@ferd ferd changed the title Have "rebar3 plugins upgrade" keep its promise Have "rebar3 plugins upgrade" work without specifying plugin name Apr 2, 2021
@ferd ferd merged commit c102379 into erlang:master Apr 2, 2021
@paulo-ferraz-oliveira paulo-ferraz-oliveira deleted the feature/rebar3_plugins_upgrade branch May 3, 2021 23:26
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.

Potentially misleading rebar3 help plugins upgrade doc.
2 participants