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

Remove recursion from Complete.hasOrg #2655

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jackkoenig
Copy link

This is primarily to fix an issue where the Sonatype snapshots repository disallows listing the top-level directory, but the recursion appears to have no functional benefit. This should also make complete faster by reducing the number of queries.

Fixes #1700

Many thanks and full credit to @keynmol for doing the real legwork debugging the issue in #1700 (comment).

I'm opening this as a draft PR because I am not sure how best to test this, especially since it relies on peculiarities of the Sonatype snapshots repository, and my limited grepping did not find any tests for the behavior of Complete.

This is primarily to fix an issue where the Sonatype snapshots
repository disallows listing the top-level directory, but the recursion
appears to have no functional benefit. This should also make complete
faster by reducing the number of queries.
@jackkoenig
Copy link
Author

I also suspect that the partial argument to hasOrg may not be needed but I'm already over my skis a bit with this change so I figured I'd start here 🙂

case true =>
check
}
): F[Boolean] =
Copy link
Author

Choose a reason for hiding this comment

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

I recommend hiding whitespace on the diff to see that this is just taking the expression assigned to check and returning it.

@jackkoenig
Copy link
Author

jackkoenig commented Jan 7, 2023

This isn't a complete fix for compete on sonatype snapshots. Complete still doesn't work for organizations, but it works for artifacts and versions which seems like a pretty big improvement to me.

I proved this worked to myself with the following script (running it with and without this change):

#!/usr/bin/env bash -x

CS='mill -s --disable-ticker -i cli.run'
$CS complete-dep --cache localcache --no-default -r sonatype:snapshots edu.berkeley.cs:chisel3_2.12:3.2
$CS complete-dep --cache localcache --no-default -r sonatype:snapshots edu.berkeley.cs:chisel3_2.12:
$CS complete-dep --cache localcache --no-default -r sonatype:snapshots edu.berkeley.cs:chisel3
$CS complete-dep --cache localcache --no-default -r sonatype:snapshots edu.berkeley.cs:
$CS complete-dep --cache localcache --no-default -r sonatype:snapshots edu.berkeley
$CS complete-dep --cache localcache --no-default -r sonatype:snapshots edu
$CS complete-dep --cache localcache --no-default -r sonatype:releases edu.berkeley.cs:chisel3_2.12:3.2
$CS complete-dep --cache localcache --no-default -r sonatype:releases edu.berkeley.cs:chisel3_2.12:
$CS complete-dep --cache localcache --no-default -r sonatype:releases edu.berkeley.cs:chisel3
$CS complete-dep --cache localcache --no-default -r sonatype:releases edu.berkeley.cs:
$CS complete-dep --cache localcache --no-default -r sonatype:releases edu.berkeley
$CS complete-dep --cache localcache --no-default -r sonatype:releases edu

You'll notice that edu.berkeley and edu still don't complete correctly for sonatype:snapshots but the rest do.

Copy link
Member

@alexarchambault alexarchambault left a comment

Choose a reason for hiding this comment

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

Thanks @jackkoenig!

Do you mind if I ponder that a little? IIRC, this recursion was related to caching, with things being properly cached with the recursion, and not correctly cached without it. I don't recall if this still applies though, which what I'd like to check…

@jackkoenig
Copy link
Author

Sorry I missed your response @alexarchambault! Yeah this isn't urgent by any means but I hope some solution eventually makes its way into coursier! Thanks for the great tool 🙂

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.

cs complete for snapsots not working like resolve or bootstrap
2 participants