Do not list repositories if the repository filters are not regexes#354
Open
JRBANCEL wants to merge 1 commit intoAzure:mainfrom
Open
Do not list repositories if the repository filters are not regexes#354JRBANCEL wants to merge 1 commit intoAzure:mainfrom
JRBANCEL wants to merge 1 commit intoAzure:mainfrom
Conversation
6b7a2b1 to
9978f88
Compare
Contributor
Author
|
@Wwwsylvia, @estebanreyl, @northtyphoon, @sajayantony, @shizhMSFT, @wangxiaoxuan273, @wju-MSFT can someone PTAL? |
Contributor
|
This is a nice optimization. Sorry for the late response, I missed the original ping. |
Contributor
Author
|
@estebanreyl are you going to look at this? If not who can? |
estebanreyl
reviewed
Feb 25, 2025
| var allRepoNames []string | ||
|
|
||
| // Bypass listing the repositories if there are no regex in the repository name filters | ||
| notRegexRegex := regexp2.MustCompile(`^[a-z0-9-\/]+$`, defaultRegexpOptions) |
Contributor
There was a problem hiding this comment.
Nit. Regular characters are still considered a valid regex, however in this case a search is not necessary. In light of that and the fact that using notRegexRegex is a bit redundant, maybe check for if this is a single repo name? like isSingleRepoNameRegex?
| if err != nil { | ||
| return nil, err | ||
| } | ||
| if !notRegex { |
Contributor
There was a problem hiding this comment.
This creates an odd double negative. Following what I noted above, maybe use isSingleRepoName?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose of the PR
As explained in #353, listing all the repositories can possibly never complete, or with the workaround from that PR, it can still take hours in large ACRs.
The problem is that in a very common scenario (the repository not being a regex), there is absolutely no need to list the repositories in the first place.
This PR simply checks that none of the repository parts of the provided filters are regex and if that's the case, use those as repository names instead of calling the potentially very expensive
GetAllRepositoryNames.We use this in our ACRs with ACR tasks for each known large repositories like
purge --filter '<REPOSITORY>:.*'and it is instantaneous instead of taking hours.