mirror of
https://github.com/go-gitea/gitea.git
synced 2024-09-21 10:28:01 +00:00
Fix bug
This commit is contained in:
parent
3ecf362783
commit
078edf8615
@ -29,14 +29,15 @@ func GetBranchCommitID(ctx context.Context, repo Repository, branch string) (str
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
defer gitRepo.Close()
|
defer gitRepo.Close()
|
||||||
return gitRepo.GetRefCommitID(branch)
|
return gitRepo.GetRefCommitID(git.BranchPrefix + branch)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDefaultBranch sets default branch of repository.
|
// SetDefaultBranch sets default branch of repository.
|
||||||
func SetDefaultBranch(ctx context.Context, repo Repository, name string) error {
|
func SetDefaultBranch(ctx context.Context, repo Repository, name string) error {
|
||||||
cmd := git.NewCommand(ctx, "symbolic-ref", "HEAD").
|
cmd := git.NewCommand(ctx, "symbolic-ref", "HEAD").
|
||||||
AddDynamicArguments(git.BranchPrefix + name)
|
AddDynamicArguments(git.BranchPrefix + name)
|
||||||
return RunGitCmd(ctx, repo, cmd, &git.RunOpts{})
|
_, _, err := RunGitCmdStdString(ctx, repo, cmd, &git.RunOpts{})
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDefaultBranch gets default branch of repository.
|
// GetDefaultBranch gets default branch of repository.
|
||||||
|
@ -6,6 +6,7 @@ package gitrepo
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"code.gitea.io/gitea/modules/git"
|
"code.gitea.io/gitea/modules/git"
|
||||||
@ -48,7 +49,8 @@ func repositoryFromContext(ctx context.Context, repo Repository) *git.Repository
|
|||||||
}
|
}
|
||||||
|
|
||||||
if gitRepo, ok := value.(*git.Repository); ok && gitRepo != nil {
|
if gitRepo, ok := value.(*git.Repository); ok && gitRepo != nil {
|
||||||
if strings.HasSuffix(gitRepo.Path, repoRelativePath(repo)) {
|
relativePath := filepath.Join(strings.ToLower(repo.GetOwnerName()), strings.ToLower(repo.GetName()))
|
||||||
|
if strings.HasSuffix(gitRepo.Path, relativePath) {
|
||||||
return gitRepo
|
return gitRepo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user