Skip to content

Commit 23d0dfe

Browse files
authored
fix: get default branch from github (#5919)
1 parent 33773b7 commit 23d0dfe

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

engine/vcs/github/client_branch.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,14 @@ func (g *githubClient) Branches(ctx context.Context, fullname string, filters sd
100100

101101
// Branch returns only detail of a branch
102102
func (g *githubClient) Branch(ctx context.Context, fullname string, filters sdk.VCSBranchFilters) (*sdk.VCSBranch, error) {
103+
if filters.Default {
104+
repo, err := g.repoByFullname(ctx, fullname)
105+
if err != nil {
106+
return nil, err
107+
}
108+
filters.BranchName = repo.DefaultBranch
109+
}
110+
103111
cacheBranchKey := cache.Key("vcs", "github", "branches", g.OAuthToken, "/repos/"+fullname+"/branch/"+filters.BranchName)
104112
repo, err := g.repoByFullname(ctx, fullname)
105113
if err != nil {

0 commit comments

Comments
 (0)