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

Add update restriction by date #10437

Closed
GPHemsley-RELX opened this issue Jan 5, 2022 · 3 comments
Closed

Add update restriction by date #10437

GPHemsley-RELX opened this issue Jan 5, 2022 · 3 comments
Labels

Comments

@GPHemsley-RELX
Copy link

Part of the underlying motivation for me filing #10436 was because I am in the middle of an update process that I had to put down for a while, and in the interim new versions of packages have been released. Because I know which versions are new, I am able to exclude them via --with.

However, it would be wonderful if composer were able to do all this for me, given a particular timestamp. I see that composer.lock has a time field, so I presume the data to do this is at least somewhat available.

I'm thinking something along the lines of:

composer update --before '2021-12-17T17:00:00-05:00'

Is this doable?

@Seldaek
Copy link
Member

Seldaek commented Jan 6, 2022

Technically feasible yes, you can hack this up yourself like this:

<?php

class Foo
{
    public static function filterPool($e) 
    {
        $date = new \DateTime('2021-12-17T17:00:00-05:00');
        $pkgs = array_filter($e->getPackages(), fn($pkg) => $pkg->getReleaseDate() === null || $pkg->getReleaseDate() < $date);
        $e->setPackages($pkgs);
    }
}

Hooked up with this in composer.json:

    "scripts": {
        "pre-pool-create": "Foo::filterPool"
    }

Just make sure the Foo class is autoloadable by your composer.json autoload rules, then you should be good to go.

I don't really think this is a common enough need to justify an additional flag though, and messing with the package pool in this way will void warranty to some extent, it may lead to weird error messages being reported if dependency resolution fails, but as long as it finds a solution with the older packages this should work.

@Seldaek Seldaek closed this as completed Jan 6, 2022
@Seldaek Seldaek added the Support label Jan 6, 2022
@GPHemsley-RELX
Copy link
Author

I'm not sure I'm following. I don't want to update composer.json. I just want to put a limit on which packages are updated at the particular time I run composer update. It's not meant to be a permanent thing, and it shouldn't have any significant effect on dependency resolution. It's just like "pretend I ran the command at this point in time".

@Seldaek
Copy link
Member

Seldaek commented Jan 6, 2022

Yes, you would add this temporarily to your composer.json to modify composer so it runs the way you want, and then you remove this again from composer.json when you're done.

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

No branches or pull requests

2 participants