Skip to content

Commit

Permalink
fix github search branch in code info api (#3989)
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Zhao <[email protected]>
  • Loading branch information
PetrusZ authored Feb 11, 2025
1 parent 745ff8f commit e70683b
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions pkg/microservice/aslan/core/code/client/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package github

import (
"context"
"fmt"
"regexp"

github2 "github.com/google/go-github/v35/github"
e "github.com/koderover/zadig/v2/pkg/tool/errors"
Expand Down Expand Up @@ -57,10 +59,13 @@ func (c *Client) ListBranches(opt client.ListOpt) ([]*client.Branch, error) {
}
var res []*client.Branch
for _, o := range bList {
res = append(res, &client.Branch{
Name: o.GetName(),
Protected: o.GetProtected(),
})
matched, _ := regexp.MatchString(fmt.Sprintf(`%s`, opt.Key), o.GetName())
if matched {
res = append(res, &client.Branch{
Name: o.GetName(),
Protected: o.GetProtected(),
})
}
}
return res, nil
}
Expand All @@ -72,11 +77,14 @@ func (c *Client) ListTags(opt client.ListOpt) ([]*client.Tag, error) {
}
var res []*client.Tag
for _, o := range tags {
res = append(res, &client.Tag{
Name: o.GetName(),
ZipballURL: o.GetZipballURL(),
TarballURL: o.GetTarballURL(),
})
matched, _ := regexp.MatchString(fmt.Sprintf(`%s`, opt.Key), o.GetName())
if matched {
res = append(res, &client.Tag{
Name: o.GetName(),
ZipballURL: o.GetZipballURL(),
TarballURL: o.GetTarballURL(),
})
}
}
return res, nil
}
Expand Down

0 comments on commit e70683b

Please sign in to comment.