Skip to content

Commit 81b1b04

Browse files
committed
fix
1 parent 21e2f94 commit 81b1b04

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

models/migrations/v1_12/v136.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,9 @@ func AddCommitDivergenceToPulls(x *xorm.Engine) error {
8484
log.Error("Missing base repo with id %d for PR ID %d", pr.BaseRepoID, pr.ID)
8585
continue
8686
}
87-
87+
repoStore := repo_model.StorageRepo(repo_model.RelativePath(baseRepo.OwnerName, baseRepo.Name))
8888
gitRefName := fmt.Sprintf("refs/pull/%d/head", pr.Index)
89-
90-
divergence, err := gitrepo.GetDivergingCommits(graceful.GetManager().HammerContext(),
91-
repo_model.StorageRepo(repo_model.RelativePath(baseRepo.OwnerName, baseRepo.Name)),
92-
pr.BaseBranch, gitRefName)
89+
divergence, err := gitrepo.GetDivergingCommits(graceful.GetManager().HammerContext(), repoStore, pr.BaseBranch, gitRefName)
9390
if err != nil {
9491
log.Warn("Could not recalculate Divergence for pull: %d", pr.ID)
9592
pr.CommitsAhead = 0

modules/gitrepo/gitrepo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ type Repository interface {
2020
RelativePath() string // We don't assume how the directory structure of the repository is, so we only need the relative path
2121
}
2222

23-
// RelativePath should be a unix style path like username/reponame.git
24-
// This method should change it according to the current OS.
23+
// repoPath resolves the Repository.RelativePath (which is a unix-style path like "username/reponame.git")
24+
// to a local filesystem path according to setting.RepoRootPath
2525
var repoPath = func(repo Repository) string {
2626
return filepath.Join(setting.RepoRootPath, filepath.FromSlash(repo.RelativePath()))
2727
}

modules/gitrepo/main_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"code.gitea.io/gitea/modules/log"
1212
"code.gitea.io/gitea/modules/setting"
1313
"code.gitea.io/gitea/modules/tempdir"
14+
"code.gitea.io/gitea/modules/test"
1415
)
1516

1617
func TestMain(m *testing.M) {
@@ -21,8 +22,9 @@ func TestMain(m *testing.M) {
2122
defer cleanup()
2223

2324
// resolve repository path relative to the test directory
25+
testRootDir := test.SetupGiteaRoot()
2426
repoPath = func(repo Repository) string {
25-
return filepath.Join("../git/tests/repos", repo.RelativePath())
27+
return filepath.Join(testRootDir, "/modules/git/tests/repos", repo.RelativePath())
2628
}
2729

2830
setting.Git.HomePath = gitHomePath

0 commit comments

Comments
 (0)