Skip to content

Reuse the existing repo as implied one should add it into group#1390

Merged
jdcasey merged 4 commits intoCommonjava:masterfrom
sswguo:implied_existing_repo
Oct 23, 2019
Merged

Reuse the existing repo as implied one should add it into group#1390
jdcasey merged 4 commits intoCommonjava:masterfrom
sswguo:implied_existing_repo

Conversation

@sswguo
Copy link
Copy Markdown
Contributor

@sswguo sswguo commented Oct 18, 2019

@sswguo sswguo requested review from jdcasey and pkocandr October 18, 2019 08:32
{
logger.debug( "Found existing RemoteRepositories: {}", rrs );

for ( final RemoteRepository rr : rrs )
Copy link
Copy Markdown
Contributor

@pkocandr pkocandr Oct 18, 2019

Choose a reason for hiding this comment

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

I wouldn't add all of them which is what happens here, right? This does not make much sense. I would find the one with matching releases/snapshots flags and also with empty pathMaskPatterns (which is how new ones are created, right?). If no such repo exists, I would fall back to creating a new one. Does it sound right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that makes sense, updated.

@sswguo sswguo force-pushed the implied_existing_repo branch from 874a1c1 to eb9b870 Compare October 21, 2019 06:11
Copy link
Copy Markdown
Contributor

@pkocandr pkocandr left a comment

Choose a reason for hiding this comment

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

Just minor enhancement could be done, but apart from that it looks ok.

if ( rrs != null && !rrs.isEmpty() )
{
rrs = rrs.stream()
.filter( rr -> rr.isAllowReleases() == repo.isReleasesEnabled() )
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be better to compare with the ref instance? It should match, but who knows... :-)

rrs = rrs.stream()
.filter( rr -> rr.isAllowReleases() == repo.isReleasesEnabled() )
.filter( rr -> rr.isAllowSnapshots() == repo.isSnapshotsEnabled() )
.filter( rr -> rr.getPathMaskPatterns() == null || rr.getPathMaskPatterns().isEmpty() )
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also here I would tend to compare the value with the one in ref since we already have it available here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it's better to add that condition too, to avoid to create a duplicate one with the same pathMaskPatterns.

Copy link
Copy Markdown
Member

@jdcasey jdcasey left a comment

Choose a reason for hiding this comment

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

I think we need to be more careful about aggregating with pre-existing metadata / information.

e );
}

final RemoteRepository ref = creator.createFrom( gav, repo, LoggerFactory.getLogger( creator.getClass() ) );
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What's the purpose of this variable? It looks like we're cloning it below, if there are no matching remote repositories (by URL). Is this just to get the creation check done up front?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That looks so, because we use this variable in several places, except the matching part, but also the following if section and else section. Just want to abstract it here not create it several times.

rr.setMetadata( METADATA_ORIGIN, IMPLIED_REPO_ORIGIN );
try
{
rr.setMetadata( IMPLIED_BY_STORES, mapper.writeValueAsString(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think if we're reusing an existing remote repo, we should add the current job key to any existing job keys, so we don't lose the old information (if it's already there).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, merging here looks good.

@sswguo
Copy link
Copy Markdown
Contributor Author

sswguo commented Oct 22, 2019

I think this should be something like

(CollectionUtils.isEmpty(rr.getPathMaskPatterns()) && CollectionUtils.isEmpty(ref.getPathMaskPatterns()))
    || rr.getPathMaskPatterns().equals(ref.getPathMaskPatterns())

because it should be empty only if the value in ref is empty.

Yeah, that's it.

@jdcasey jdcasey merged commit 8b69574 into Commonjava:master Oct 23, 2019
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.

3 participants