Skip to content

Commit

Permalink
fix github search branch in code info api
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Zhao <[email protected]>
  • Loading branch information
PetrusZ committed Feb 11, 2025
1 parent 745ff8f commit afd83b0
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 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 Down

0 comments on commit afd83b0

Please sign in to comment.