|
|
@ -5,6 +5,7 @@ |
|
|
|
package utils |
|
|
|
package utils |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
|
|
|
|
"fmt" |
|
|
|
"net/http" |
|
|
|
"net/http" |
|
|
|
|
|
|
|
|
|
|
|
"code.gitea.io/gitea/modules/context" |
|
|
|
"code.gitea.io/gitea/modules/context" |
|
|
@ -35,12 +36,7 @@ func ResolveRefOrSha(ctx *context.APIContext, ref string) string { |
|
|
|
// GetGitRefs return git references based on filter
|
|
|
|
// GetGitRefs return git references based on filter
|
|
|
|
func GetGitRefs(ctx *context.APIContext, filter string) ([]*git.Reference, string, error) { |
|
|
|
func GetGitRefs(ctx *context.APIContext, filter string) ([]*git.Reference, string, error) { |
|
|
|
if ctx.Repo.GitRepo == nil { |
|
|
|
if ctx.Repo.GitRepo == nil { |
|
|
|
var err error |
|
|
|
return nil, "", fmt.Errorf("no open git repo found in context") |
|
|
|
ctx.Repo.GitRepo, err = git.OpenRepository(ctx, ctx.Repo.Repository.RepoPath()) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return nil, "OpenRepository", err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
defer ctx.Repo.GitRepo.Close() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if len(filter) > 0 { |
|
|
|
if len(filter) > 0 { |
|
|
|
filter = "refs/" + filter |
|
|
|
filter = "refs/" + filter |
|
|
|