forked from gitea/gitea
Use repo object format name instead of detecting from git repository (#29702)
It's unnecessary to detect the repository object format from git repository. Just use the repository's object format name.
This commit is contained in:
parent
851bd18234
commit
3c6fc25a77
|
@ -91,11 +91,9 @@ func genesisChanges(ctx context.Context, repo *repo_model.Repository, revision s
|
||||||
return nil, runErr
|
return nil, runErr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
objectFormat := git.ObjectFormatFromName(repo.ObjectFormatName)
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
objectFormat, err := git.GetObjectFormatOfRepo(ctx, repo.RepoPath())
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
changes.Updates, err = parseGitLsTreeOutput(objectFormat, stdout)
|
changes.Updates, err = parseGitLsTreeOutput(objectFormat, stdout)
|
||||||
return &changes, err
|
return &changes, err
|
||||||
}
|
}
|
||||||
|
@ -174,10 +172,8 @@ func nonGenesisChanges(ctx context.Context, repo *repo_model.Repository, revisio
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
objectFormat, err := git.GetObjectFormatOfRepo(ctx, repo.RepoPath())
|
objectFormat := git.ObjectFormatFromName(repo.ObjectFormatName)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
changes.Updates, err = parseGitLsTreeOutput(objectFormat, lsTreeStdout)
|
changes.Updates, err = parseGitLsTreeOutput(objectFormat, lsTreeStdout)
|
||||||
return &changes, err
|
return &changes, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,12 +148,7 @@ func RestoreBranchPost(ctx *context.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
objectFormat, err := git.GetObjectFormatOfRepo(ctx, ctx.Repo.Repository.RepoPath())
|
objectFormat := git.ObjectFormatFromName(ctx.Repo.Repository.ObjectFormatName)
|
||||||
if err != nil {
|
|
||||||
log.Error("RestoreBranch: CreateBranch: %w", err)
|
|
||||||
ctx.Flash.Error(ctx.Tr("repo.branch.restore_failed", deletedBranch.Name))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Don't return error below this
|
// Don't return error below this
|
||||||
if err := repo_service.PushUpdate(
|
if err := repo_service.PushUpdate(
|
||||||
|
|
|
@ -656,12 +656,7 @@ func TestWebhook(ctx *context.Context) {
|
||||||
commit := ctx.Repo.Commit
|
commit := ctx.Repo.Commit
|
||||||
if commit == nil {
|
if commit == nil {
|
||||||
ghost := user_model.NewGhostUser()
|
ghost := user_model.NewGhostUser()
|
||||||
objectFormat, err := git.GetObjectFormatOfRepo(ctx, ctx.Repo.Repository.RepoPath())
|
objectFormat := git.ObjectFormatFromName(ctx.Repo.Repository.ObjectFormatName)
|
||||||
if err != nil {
|
|
||||||
ctx.Flash.Error("GetObjectFormatOfRepo: " + err.Error())
|
|
||||||
ctx.Status(http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
commit = &git.Commit{
|
commit = &git.Commit{
|
||||||
ID: objectFormat.EmptyObjectID(),
|
ID: objectFormat.EmptyObjectID(),
|
||||||
Author: ghost.NewGitSig(),
|
Author: ghost.NewGitSig(),
|
||||||
|
|
|
@ -479,10 +479,7 @@ func SyncPullMirror(ctx context.Context, repoID int64) bool {
|
||||||
log.Error("SyncMirrors [repo: %-v]: unable to GetRefCommitID [ref_name: %s]: %v", m.Repo, result.refName, err)
|
log.Error("SyncMirrors [repo: %-v]: unable to GetRefCommitID [ref_name: %s]: %v", m.Repo, result.refName, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
objectFormat, err := git.GetObjectFormatOfRepo(ctx, m.Repo.RepoPath())
|
objectFormat := git.ObjectFormatFromName(m.Repo.ObjectFormatName)
|
||||||
if err != nil {
|
|
||||||
log.Error("SyncMirrors [repo: %-v]: unable to GetHashTypeOfRepo: %v", m.Repo, err)
|
|
||||||
}
|
|
||||||
notify_service.SyncPushCommits(ctx, m.Repo.MustOwner(ctx), m.Repo, &repo_module.PushUpdateOptions{
|
notify_service.SyncPushCommits(ctx, m.Repo.MustOwner(ctx), m.Repo, &repo_module.PushUpdateOptions{
|
||||||
RefFullName: result.refName,
|
RefFullName: result.refName,
|
||||||
OldCommitID: objectFormat.EmptyObjectID().String(),
|
OldCommitID: objectFormat.EmptyObjectID().String(),
|
||||||
|
|
|
@ -337,7 +337,7 @@ func AddTestPullRequestTask(doer *user_model.User, repoID int64, branch string,
|
||||||
}
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
for _, pr := range prs {
|
for _, pr := range prs {
|
||||||
objectFormat, _ := git.GetObjectFormatOfRepo(ctx, pr.BaseRepo.RepoPath())
|
objectFormat := git.ObjectFormatFromName(pr.BaseRepo.ObjectFormatName)
|
||||||
if newCommitID != "" && newCommitID != objectFormat.EmptyObjectID().String() {
|
if newCommitID != "" && newCommitID != objectFormat.EmptyObjectID().String() {
|
||||||
changed, err := checkIfPRContentChanged(ctx, pr, oldCommitID, newCommitID)
|
changed, err := checkIfPRContentChanged(ctx, pr, oldCommitID, newCommitID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -326,10 +326,7 @@ func DeleteReleaseByID(ctx context.Context, repo *repo_model.Repository, rel *re
|
||||||
}
|
}
|
||||||
|
|
||||||
refName := git.RefNameFromTag(rel.TagName)
|
refName := git.RefNameFromTag(rel.TagName)
|
||||||
objectFormat, err := git.GetObjectFormatOfRepo(ctx, repo.RepoPath())
|
objectFormat := git.ObjectFormatFromName(repo.ObjectFormatName)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
notify_service.PushCommits(
|
notify_service.PushCommits(
|
||||||
ctx, doer, repo,
|
ctx, doer, repo,
|
||||||
&repository.PushUpdateOptions{
|
&repository.PushUpdateOptions{
|
||||||
|
|
Loading…
Reference in New Issue