summaryrefslogtreecommitdiffstats
path: root/services/pull
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2023-12-17 19:56:08 +0800
committerGitHub <noreply@github.com>2023-12-17 11:56:08 +0000
commit408a4842240e7dd906e682196bd4254d6c76fcb9 (patch)
treeec3962d5769a5891a24b4d79f725673fc1e46e35 /services/pull
parent7fb6b5147038649bfaa26147a6173cf99b322a30 (diff)
downloadgitea-408a4842240e7dd906e682196bd4254d6c76fcb9.tar.gz
gitea-408a4842240e7dd906e682196bd4254d6c76fcb9.zip
Adjust object format interface (#28469)
- Remove `ObjectFormatID` - Remove function `ObjectFormatFromID`. - Use `Sha1ObjectFormat` directly but not a pointer because it's an empty struct. - Store `ObjectFormatName` in `repository` struct
Diffstat (limited to 'services/pull')
-rw-r--r--services/pull/pull.go2
-rw-r--r--services/pull/temp_repo.go9
2 files changed, 3 insertions, 8 deletions
diff --git a/services/pull/pull.go b/services/pull/pull.go
index a16d1be1c1..6094a4ed31 100644
--- a/services/pull/pull.go
+++ b/services/pull/pull.go
@@ -328,7 +328,7 @@ func AddTestPullRequestTask(doer *user_model.User, repoID int64, branch string,
if err == nil {
for _, pr := range prs {
objectFormat, _ := git.GetObjectFormatOfRepo(ctx, pr.BaseRepo.RepoPath())
- if newCommitID != "" && newCommitID != objectFormat.Empty().String() {
+ if newCommitID != "" && newCommitID != objectFormat.EmptyObjectID().String() {
changed, err := checkIfPRContentChanged(ctx, pr, oldCommitID, newCommitID)
if err != nil {
log.Error("checkIfPRContentChanged: %v", err)
diff --git a/services/pull/temp_repo.go b/services/pull/temp_repo.go
index fde8673a24..36bdbde55c 100644
--- a/services/pull/temp_repo.go
+++ b/services/pull/temp_repo.go
@@ -93,14 +93,8 @@ func createTemporaryRepoForPR(ctx context.Context, pr *issues_model.PullRequest)
baseRepoPath := pr.BaseRepo.RepoPath()
headRepoPath := pr.HeadRepo.RepoPath()
- objectFormat, err := git.GetObjectFormatOfRepo(ctx, baseRepoPath)
- if err != nil {
- log.Error("Unable to fetch ObjectFormat of repository %s: %v", baseRepoPath, err)
- cancel()
- return nil, nil, err
- }
- if err := git.InitRepository(ctx, tmpBasePath, false, objectFormat); err != nil {
+ if err := git.InitRepository(ctx, tmpBasePath, false, pr.BaseRepo.ObjectFormatName); err != nil {
log.Error("Unable to init tmpBasePath for %-v: %v", pr, err)
cancel()
return nil, nil, err
@@ -174,6 +168,7 @@ func createTemporaryRepoForPR(ctx context.Context, pr *issues_model.PullRequest)
}
trackingBranch := "tracking"
+ objectFormat := git.ObjectFormatFromName(pr.BaseRepo.ObjectFormatName)
// Fetch head branch
var headBranch string
if pr.Flow == issues_model.PullRequestFlowGithub {