-
Notifications
You must be signed in to change notification settings - Fork 47
fix: filtering gerrit reporitories #1632
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
Changes from 2 commits
5f9106d
edf7251
9fa4702
d530ae5
47d9700
0d26f73
256d162
190a746
69e69fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -101,9 +101,33 @@ export const useProjectStore = defineStore('project', () => { | |
| }); | ||
|
|
||
| // Selected repository URLs | ||
| const selectedReposValues = computed<string[]>(() => | ||
| selectedRepositories.value.map((repo: ProjectRepository) => repo.url), | ||
| ); | ||
| const selectedReposValues = computed<string[]>(() => { | ||
| const hasGerrit = project.value?.connectedPlatforms?.some((platform) => | ||
| platform.toLowerCase().includes('gerrit'), | ||
| ); | ||
| const repos = selectedRepositories.value.map((repo: ProjectRepository) => repo.url); | ||
|
|
||
| if (hasGerrit) { | ||
| // For Gerrit repos, add the query URL format alongside each repo URL | ||
| // Input: https://gerrit.<domain>/<namespace>/<project>/<repo> | ||
| // Output: https://gerrit.<domain>/<namespace>/q/project:<project>/<repo> | ||
| const gerritUrlPattern = /^(https:\/\/gerrit\.[^/]+\/[^/]+)\/(.+)$/; | ||
| const expandedRepos: string[] = []; | ||
|
|
||
| for (const repoUrl of repos) { | ||
| expandedRepos.push(repoUrl); | ||
| const match = repoUrl.match(gerritUrlPattern); | ||
| if (match) { | ||
| const [, baseWithNamespace, projectPath] = match; | ||
| expandedRepos.push(`${baseWithNamespace}/q/project:${projectPath}`); | ||
| } | ||
| } | ||
|
|
||
| return expandedRepos; | ||
| } | ||
|
|
||
| return repos; | ||
| }); | ||
|
||
|
|
||
| // Determine granularity options based on selected date range | ||
| const customRangeGranularity = computed<string[]>(() => | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
selectedReposValuesnow expands Gerrit repos by appending a derived/q/project:URL, but the construction can generate malformed URLs:repoUrlis already in/q/project:form, this will produce/q/project:q/project:....projectPathmay contain/and should be URL-encoded (Gerrit query URLs typically expectproject:foo%2Fbaras a single path segment).Consider guarding against already-query URLs and encoding the project path when generating the query URL.