Skip to content

Commit 078edf8

Browse files
committed
Fix bug
1 parent 3ecf362 commit 078edf8

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

modules/gitrepo/branch.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@ func GetBranchCommitID(ctx context.Context, repo Repository, branch string) (str
2929
return "", err
3030
}
3131
defer gitRepo.Close()
32-
return gitRepo.GetRefCommitID(branch)
32+
return gitRepo.GetRefCommitID(git.BranchPrefix + branch)
3333
}
3434

3535
// SetDefaultBranch sets default branch of repository.
3636
func SetDefaultBranch(ctx context.Context, repo Repository, name string) error {
3737
cmd := git.NewCommand(ctx, "symbolic-ref", "HEAD").
3838
AddDynamicArguments(git.BranchPrefix + name)
39-
return RunGitCmd(ctx, repo, cmd, &git.RunOpts{})
39+
_, _, err := RunGitCmdStdString(ctx, repo, cmd, &git.RunOpts{})
40+
return err
4041
}
4142

4243
// GetDefaultBranch gets default branch of repository.

modules/gitrepo/gitrepo.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package gitrepo
66
import (
77
"context"
88
"io"
9+
"path/filepath"
910
"strings"
1011

1112
"code.gitea.io/gitea/modules/git"
@@ -48,7 +49,8 @@ func repositoryFromContext(ctx context.Context, repo Repository) *git.Repository
4849
}
4950

5051
if gitRepo, ok := value.(*git.Repository); ok && gitRepo != nil {
51-
if strings.HasSuffix(gitRepo.Path, repoRelativePath(repo)) {
52+
relativePath := filepath.Join(strings.ToLower(repo.GetOwnerName()), strings.ToLower(repo.GetName()))
53+
if strings.HasSuffix(gitRepo.Path, relativePath) {
5254
return gitRepo
5355
}
5456
}

0 commit comments

Comments
 (0)