fix(sync): apply tag filters before destination mapping (#4003)

* fix(sync): apply tag filters before destination mapping

Signed-off-by: Akash Kumar <meakash7902@gmail.com>

* fix(sync): return stable pointer from getContentByUpstreamRepo

Iterate by index and return &cm.contents[i] so callers get the slice
element rather than a copy of the loop variable, matching the existing
GetContentByLocalRepo helper.

Signed-off-by: Akash Kumar <meakash7902@gmail.com>

---------

Signed-off-by: Akash Kumar <meakash7902@gmail.com>
This commit is contained in:
Akash Kumar
2026-04-27 10:57:46 +05:30
committed by GitHub
parent 9e13be8b61
commit bb5b77aeaa
2 changed files with 49 additions and 3 deletions
+5 -3
View File
@@ -50,7 +50,7 @@ func (cm ContentManager) MatchesContent(repo string) bool {
// FilterTags filters a repo tags based on content config rules (semver, regex).
func (cm ContentManager) FilterTags(repo string, tags []string) ([]string, error) {
content := cm.GetContentByLocalRepo(repo)
content := cm.getContentByUpstreamRepo(repo)
var err error
// filter based on tags rules
@@ -106,7 +106,9 @@ func (cm ContentManager) GetRepoSource(repo string) string {
// utilies functions.
func (cm ContentManager) getContentByUpstreamRepo(repo string) *syncconf.Content {
for _, content := range cm.contents {
for i := range cm.contents {
content := &cm.contents[i]
var prefix string
// handle prefixes starting with '/'
if strings.HasPrefix(content.Prefix, "/") {
@@ -125,7 +127,7 @@ func (cm ContentManager) getContentByUpstreamRepo(repo string) *syncconf.Content
}
if matched {
return &content
return content
}
}