.drone.yml
, /docs/**/*.txt
@@ -2846,6 +2860,7 @@ emails.updated=メール設定を更新しました
emails.not_updated=メール設定の更新に失敗しました: %v
emails.duplicate_active=メールアドレスは別のユーザーが既に使用中です。
emails.change_email_header=メール設定の更新
+emails.change_email_text=このメールアドレスで更新してもよろしいですか?
orgs.org_manage_panel=組織の管理
orgs.name=名称
@@ -2870,6 +2885,7 @@ packages.package_manage_panel=パッケージ管理
packages.total_size=合計サイズ: %s
packages.unreferenced_size=非参照サイズ: %s
packages.cleanup=期限切れデータを掃除する
+packages.cleanup.success=期限切れのデータを正常にクリーンアップしました
packages.owner=オーナー
packages.creator=作成者
packages.name=名前
@@ -3441,7 +3457,7 @@ owner.settings.chef.keypair.description=Chefレジストリの認証にはキー
[secrets]
secrets=シークレット
description=シークレットは特定のActionsに渡されます。 それ以外で読み出されることはありません。
-none=まだシークレットはありません。
+none=シークレットはまだありません。
creation=シークレットを追加
creation.name_placeholder=大文字小文字の区別なし、英数字とアンダースコアのみ、GITEA_ や GITHUB_ で始まるものは不可
creation.value_placeholder=内容を入力してください。前後の空白は除去されます。
@@ -3516,6 +3532,7 @@ runs.actors_no_select=すべてのアクター
runs.status_no_select=すべてのステータス
runs.no_results=一致する結果はありません。
runs.no_runs=ワークフローはまだ実行されていません。
+runs.empty_commit_message=(空のコミットメッセージ)
workflow.disable=ワークフローを無効にする
workflow.disable_success=ワークフロー '%s' が無効になりました。
diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go
index 1767a7fa674d5..6eb2cc4227429 100644
--- a/routers/api/v1/repo/repo.go
+++ b/routers/api/v1/repo/repo.go
@@ -242,18 +242,18 @@ func CreateUserRepo(ctx *context.APIContext, owner *user_model.User, opt api.Cre
}
repo, err := repo_service.CreateRepository(ctx, ctx.Doer, owner, repo_service.CreateRepoOptions{
- Name: opt.Name,
- Description: opt.Description,
- IssueLabels: opt.IssueLabels,
- Gitignores: opt.Gitignores,
- License: opt.License,
- Readme: opt.Readme,
- IsPrivate: opt.Private,
- AutoInit: opt.AutoInit,
- DefaultBranch: opt.DefaultBranch,
- TrustModel: repo_model.ToTrustModel(opt.TrustModel),
- IsTemplate: opt.Template,
- ObjectFormat: git.ObjectFormatFromID(git.Sha1),
+ Name: opt.Name,
+ Description: opt.Description,
+ IssueLabels: opt.IssueLabels,
+ Gitignores: opt.Gitignores,
+ License: opt.License,
+ Readme: opt.Readme,
+ IsPrivate: opt.Private,
+ AutoInit: opt.AutoInit,
+ DefaultBranch: opt.DefaultBranch,
+ TrustModel: repo_model.ToTrustModel(opt.TrustModel),
+ IsTemplate: opt.Template,
+ ObjectFormatName: git.Sha1ObjectFormat.Name(),
})
if err != nil {
if repo_model.IsErrRepoAlreadyExist(err) {
diff --git a/routers/api/v1/utils/git.go b/routers/api/v1/utils/git.go
index eb82c505440fe..dfb1a130c3711 100644
--- a/routers/api/v1/utils/git.go
+++ b/routers/api/v1/utils/git.go
@@ -81,7 +81,7 @@ func ConvertToObjectID(ctx gocontext.Context, repo *context.Repository, commitID
gitRepo, closer, err := git.RepositoryFromContextOrOpen(ctx, repo.Repository.RepoPath())
if err != nil {
- return objectFormat.Empty(), fmt.Errorf("RepositoryFromContextOrOpen: %w", err)
+ return objectFormat.EmptyObjectID(), fmt.Errorf("RepositoryFromContextOrOpen: %w", err)
}
defer closer.Close()
diff --git a/routers/private/hook_pre_receive.go b/routers/private/hook_pre_receive.go
index 8811809710116..90d8287f06fd2 100644
--- a/routers/private/hook_pre_receive.go
+++ b/routers/private/hook_pre_receive.go
@@ -147,7 +147,7 @@ func preReceiveBranch(ctx *preReceiveContext, oldCommitID, newCommitID string, r
gitRepo := ctx.Repo.GitRepo
objectFormat, _ := gitRepo.GetObjectFormat()
- if branchName == repo.DefaultBranch && newCommitID == objectFormat.Empty().String() {
+ if branchName == repo.DefaultBranch && newCommitID == objectFormat.EmptyObjectID().String() {
log.Warn("Forbidden: Branch: %s is the default branch in %-v and cannot be deleted", branchName, repo)
ctx.JSON(http.StatusForbidden, private.Response{
UserMsg: fmt.Sprintf("branch %s is the default branch and cannot be deleted", branchName),
@@ -175,7 +175,7 @@ func preReceiveBranch(ctx *preReceiveContext, oldCommitID, newCommitID string, r
// First of all we need to enforce absolutely:
//
// 1. Detect and prevent deletion of the branch
- if newCommitID == objectFormat.Empty().String() {
+ if newCommitID == objectFormat.EmptyObjectID().String() {
log.Warn("Forbidden: Branch: %s in %-v is protected from deletion", branchName, repo)
ctx.JSON(http.StatusForbidden, private.Response{
UserMsg: fmt.Sprintf("branch %s is protected from deletion", branchName),
@@ -184,7 +184,7 @@ func preReceiveBranch(ctx *preReceiveContext, oldCommitID, newCommitID string, r
}
// 2. Disallow force pushes to protected branches
- if oldCommitID != objectFormat.Empty().String() {
+ if oldCommitID != objectFormat.EmptyObjectID().String() {
output, _, err := git.NewCommand(ctx, "rev-list", "--max-count=1").AddDynamicArguments(oldCommitID, "^"+newCommitID).RunStdString(&git.RunOpts{Dir: repo.RepoPath(), Env: ctx.env})
if err != nil {
log.Error("Unable to detect force push between: %s and %s in %-v Error: %v", oldCommitID, newCommitID, repo, err)
diff --git a/routers/private/hook_verification.go b/routers/private/hook_verification.go
index 6725205cc6d2c..8b2d0dd848a9d 100644
--- a/routers/private/hook_verification.go
+++ b/routers/private/hook_verification.go
@@ -30,7 +30,7 @@ func verifyCommits(oldCommitID, newCommitID string, repo *git.Repository, env []
var command *git.Command
objectFormat, _ := repo.GetObjectFormat()
- if oldCommitID == objectFormat.Empty().String() {
+ if oldCommitID == objectFormat.EmptyObjectID().String() {
// When creating a new branch, the oldCommitID is empty, by using "newCommitID --not --all":
// List commits that are reachable by following the newCommitID, exclude "all" existing heads/tags commits
// So, it only lists the new commits received, doesn't list the commits already present in the receiving repository
diff --git a/routers/private/hook_verification_test.go b/routers/private/hook_verification_test.go
index 7263ebc4235d3..04445b8eaf36c 100644
--- a/routers/private/hook_verification_test.go
+++ b/routers/private/hook_verification_test.go
@@ -30,9 +30,9 @@ func TestVerifyCommits(t *testing.T) {
verified bool
}{
{"72920278f2f999e3005801e5d5b8ab8139d3641c", "d766f2917716d45be24bfa968b8409544941be32", true},
- {objectFormat.Empty().String(), "93eac826f6188f34646cea81bf426aa5ba7d3bfe", true}, // New branch with verified commit
+ {objectFormat.EmptyObjectID().String(), "93eac826f6188f34646cea81bf426aa5ba7d3bfe", true}, // New branch with verified commit
{"9779d17a04f1e2640583d35703c62460b2d86e0a", "72920278f2f999e3005801e5d5b8ab8139d3641c", false},
- {objectFormat.Empty().String(), "9ce3f779ae33f31fce17fac3c512047b75d7498b", false}, // New branch with unverified commit
+ {objectFormat.EmptyObjectID().String(), "9ce3f779ae33f31fce17fac3c512047b75d7498b", false}, // New branch with unverified commit
}
for _, tc := range testCases {
diff --git a/routers/web/repo/blame.go b/routers/web/repo/blame.go
index db9be51257e7f..b2374e32c2849 100644
--- a/routers/web/repo/blame.go
+++ b/routers/web/repo/blame.go
@@ -315,8 +315,7 @@ func renderBlame(ctx *context.Context, blameParts []git.BlamePart, commitNames m
lexerName = lexerNameForLine
}
- br.EscapeStatus, line = charset.EscapeControlHTML(line, ctx.Locale)
- br.Code = gotemplate.HTML(line)
+ br.EscapeStatus, br.Code = charset.EscapeControlHTML(line, ctx.Locale)
rows = append(rows, br)
escapeStatus = escapeStatus.Or(br.EscapeStatus)
}
diff --git a/routers/web/repo/branch.go b/routers/web/repo/branch.go
index b6de5bf800e2d..c543160f42040 100644
--- a/routers/web/repo/branch.go
+++ b/routers/web/repo/branch.go
@@ -158,7 +158,7 @@ func RestoreBranchPost(ctx *context.Context) {
if err := repo_service.PushUpdate(
&repo_module.PushUpdateOptions{
RefFullName: git.RefNameFromBranch(deletedBranch.Name),
- OldCommitID: objectFormat.Empty().String(),
+ OldCommitID: objectFormat.EmptyObjectID().String(),
NewCommitID: deletedBranch.CommitID,
PusherID: ctx.Doer.ID,
PusherName: ctx.Doer.Name,
diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go
index 5b1638d3f5f53..f3b95b68fe5a2 100644
--- a/routers/web/repo/compare.go
+++ b/routers/web/repo/compare.go
@@ -317,7 +317,7 @@ func ParseCompareInfo(ctx *context.Context) *CompareInfo {
ci.BaseBranch = baseCommit.ID.String()
ctx.Data["BaseBranch"] = ci.BaseBranch
baseIsCommit = true
- } else if ci.BaseBranch == objectFormat.Empty().String() {
+ } else if ci.BaseBranch == objectFormat.EmptyObjectID().String() {
if isSameRepo {
ctx.Redirect(ctx.Repo.RepoLink + "/compare/" + util.PathEscapeSegments(ci.HeadBranch))
} else {
diff --git a/routers/web/repo/githttp.go b/routers/web/repo/githttp.go
index dd47bd79d94e1..6d3dd5a3fe629 100644
--- a/routers/web/repo/githttp.go
+++ b/routers/web/repo/githttp.go
@@ -329,7 +329,7 @@ func dummyInfoRefs(ctx *context.Context) {
}
}()
- if err := git.InitRepository(ctx, tmpDir, true, git.ObjectFormatFromID(git.Sha1)); err != nil {
+ if err := git.InitRepository(ctx, tmpDir, true, git.Sha1ObjectFormat.Name()); err != nil {
log.Error("Failed to init bare repo for git-receive-pack cache: %v", err)
return
}
diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go
index 7a2976f8dcaac..b16e28383629e 100644
--- a/routers/web/repo/repo.go
+++ b/routers/web/repo/repo.go
@@ -278,18 +278,18 @@ func CreatePost(ctx *context.Context) {
}
} else {
repo, err = repo_service.CreateRepository(ctx, ctx.Doer, ctxUser, repo_service.CreateRepoOptions{
- Name: form.RepoName,
- Description: form.Description,
- Gitignores: form.Gitignores,
- IssueLabels: form.IssueLabels,
- License: form.License,
- Readme: form.Readme,
- IsPrivate: form.Private || setting.Repository.ForcePrivate,
- DefaultBranch: form.DefaultBranch,
- AutoInit: form.AutoInit,
- IsTemplate: form.Template,
- TrustModel: repo_model.ToTrustModel(form.TrustModel),
- ObjectFormat: form.ObjectFormat,
+ Name: form.RepoName,
+ Description: form.Description,
+ Gitignores: form.Gitignores,
+ IssueLabels: form.IssueLabels,
+ License: form.License,
+ Readme: form.Readme,
+ IsPrivate: form.Private || setting.Repository.ForcePrivate,
+ DefaultBranch: form.DefaultBranch,
+ AutoInit: form.AutoInit,
+ IsTemplate: form.Template,
+ TrustModel: repo_model.ToTrustModel(form.TrustModel),
+ ObjectFormatName: form.ObjectFormatName,
})
if err == nil {
log.Trace("Repository created [%d]: %s/%s", repo.ID, ctxUser.Name, repo.Name)
diff --git a/routers/web/repo/setting/webhook.go b/routers/web/repo/setting/webhook.go
index 8c232a4cb8d43..ab3c70006f795 100644
--- a/routers/web/repo/setting/webhook.go
+++ b/routers/web/repo/setting/webhook.go
@@ -662,7 +662,7 @@ func TestWebhook(ctx *context.Context) {
return
}
commit = &git.Commit{
- ID: objectFormat.NewEmptyID(),
+ ID: objectFormat.EmptyObjectID(),
Author: ghost.NewGitSig(),
Committer: ghost.NewGitSig(),
CommitMessage: "This is a fake commit",
diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go
index 70556185bb53b..9cf0dff5d8e2f 100644
--- a/routers/web/repo/view.go
+++ b/routers/web/repo/view.go
@@ -9,6 +9,7 @@ import (
gocontext "context"
"encoding/base64"
"fmt"
+ "html/template"
"image"
"io"
"net/http"
@@ -317,19 +318,18 @@ func renderReadmeFile(ctx *context.Context, subfolder string, readmeFile *git.Tr
}, rd)
if err != nil {
log.Error("Render failed for %s in %-v: %v Falling back to rendering source", readmeFile.Name(), ctx.Repo.Repository, err)
- buf := &bytes.Buffer{}
- ctx.Data["EscapeStatus"], _ = charset.EscapeControlStringReader(rd, buf, ctx.Locale)
- ctx.Data["FileContent"] = buf.String()
+ delete(ctx.Data, "IsMarkup")
}
- } else {
+ }
+
+ if ctx.Data["IsMarkup"] != true {
ctx.Data["IsPlainText"] = true
- buf := &bytes.Buffer{}
- ctx.Data["EscapeStatus"], err = charset.EscapeControlStringReader(rd, buf, ctx.Locale)
+ content, err := io.ReadAll(rd)
if err != nil {
- log.Error("Read failed: %v", err)
+ log.Error("Read readme content failed: %v", err)
}
-
- ctx.Data["FileContent"] = buf.String()
+ contentEscaped := template.HTMLEscapeString(util.UnsafeBytesToString(content))
+ ctx.Data["EscapeStatus"], ctx.Data["FileContent"] = charset.EscapeControlHTML(template.HTML(contentEscaped), ctx.Locale)
}
if !fInfo.isLFSFile && ctx.Repo.CanEnableEditor(ctx, ctx.Doer) {
@@ -493,7 +493,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
buf, _ := io.ReadAll(rd)
// The Open Group Base Specification: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html
- // empty: 0 lines; "a": 1 line, 1 incomplete-line; "a\n": 1 line; "a\nb": 1 line, 1 incomplete-line;
+ // empty: 0 lines; "a": 1 incomplete-line; "a\n": 1 line; "a\nb": 1 line, 1 incomplete-line;
// Gitea uses the definition (like most modern editors):
// empty: 0 lines; "a": 1 line; "a\n": 2 lines; "a\nb": 2 lines;
// When rendering, the last empty line is not rendered in UI, while the line-number is still counted, to tell users that the file contains a trailing EOL.
@@ -620,7 +620,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
}
}
-func markupRender(ctx *context.Context, renderCtx *markup.RenderContext, input io.Reader) (escaped *charset.EscapeStatus, output string, err error) {
+func markupRender(ctx *context.Context, renderCtx *markup.RenderContext, input io.Reader) (escaped *charset.EscapeStatus, output template.HTML, err error) {
markupRd, markupWr := io.Pipe()
defer markupWr.Close()
done := make(chan struct{})
@@ -628,7 +628,7 @@ func markupRender(ctx *context.Context, renderCtx *markup.RenderContext, input i
sb := &strings.Builder{}
// We allow NBSP here this is rendered
escaped, _ = charset.EscapeControlReader(markupRd, sb, ctx.Locale, charset.RuneNBSP)
- output = sb.String()
+ output = template.HTML(sb.String())
close(done)
}()
err = markup.Render(renderCtx, input, markupWr)
diff --git a/services/agit/agit.go b/services/agit/agit.go
index e354b9169a201..bc68372570402 100644
--- a/services/agit/agit.go
+++ b/services/agit/agit.go
@@ -39,7 +39,7 @@ func ProcReceive(ctx context.Context, repo *repo_model.Repository, gitRepo *git.
objectFormat, _ := gitRepo.GetObjectFormat()
for i := range opts.OldCommitIDs {
- if opts.NewCommitIDs[i] == objectFormat.Empty().String() {
+ if opts.NewCommitIDs[i] == objectFormat.EmptyObjectID().String() {
results = append(results, private.HookProcReceiveRefResult{
OriginalRef: opts.RefFullNames[i],
OldOID: opts.OldCommitIDs[i],
@@ -153,7 +153,7 @@ func ProcReceive(ctx context.Context, repo *repo_model.Repository, gitRepo *git.
results = append(results, private.HookProcReceiveRefResult{
Ref: pr.GetGitRefName(),
OriginalRef: opts.RefFullNames[i],
- OldOID: objectFormat.Empty().String(),
+ OldOID: objectFormat.EmptyObjectID().String(),
NewOID: opts.NewCommitIDs[i],
})
continue
diff --git a/services/convert/git_commit_test.go b/services/convert/git_commit_test.go
index d8c1fdfed78a7..73cb5e8c7170b 100644
--- a/services/convert/git_commit_test.go
+++ b/services/convert/git_commit_test.go
@@ -19,12 +19,12 @@ import (
func TestToCommitMeta(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
headRepo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
- sha1 := git.ObjectFormatFromID(git.Sha1)
+ sha1 := git.Sha1ObjectFormat
signature := &git.Signature{Name: "Test Signature", Email: "test@email.com", When: time.Unix(0, 0)}
tag := &git.Tag{
Name: "Test Tag",
- ID: sha1.Empty(),
- Object: sha1.Empty(),
+ ID: sha1.EmptyObjectID(),
+ Object: sha1.EmptyObjectID(),
Type: "Test Type",
Tagger: signature,
Message: "Test Message",
@@ -34,8 +34,8 @@ func TestToCommitMeta(t *testing.T) {
assert.NotNil(t, commitMeta)
assert.EqualValues(t, &api.CommitMeta{
- SHA: sha1.Empty().String(),
- URL: util.URLJoin(headRepo.APIURL(), "git/commits", sha1.Empty().String()),
+ SHA: sha1.EmptyObjectID().String(),
+ URL: util.URLJoin(headRepo.APIURL(), "git/commits", sha1.EmptyObjectID().String()),
Created: time.Unix(0, 0),
}, commitMeta)
}
diff --git a/services/forms/repo_form.go b/services/forms/repo_form.go
index f6ef97dfdc3b6..86599000a5882 100644
--- a/services/forms/repo_form.go
+++ b/services/forms/repo_form.go
@@ -13,7 +13,6 @@ import (
issues_model "code.gitea.io/gitea/models/issues"
project_model "code.gitea.io/gitea/models/project"
"code.gitea.io/gitea/modules/context"
- "code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/web/middleware"
@@ -54,7 +53,7 @@ type CreateRepoForm struct {
TrustModel string
ForkSingleBranch string
- ObjectFormat git.ObjectFormat
+ ObjectFormatName string
}
// Validate validates the fields
diff --git a/services/gitdiff/gitdiff.go b/services/gitdiff/gitdiff.go
index 05d4a0555fc6c..0f6e2b6c17d5b 100644
--- a/services/gitdiff/gitdiff.go
+++ b/services/gitdiff/gitdiff.go
@@ -285,15 +285,15 @@ type DiffInline struct {
// DiffInlineWithUnicodeEscape makes a DiffInline with hidden unicode characters escaped
func DiffInlineWithUnicodeEscape(s template.HTML, locale translation.Locale) DiffInline {
- status, content := charset.EscapeControlHTML(string(s), locale)
- return DiffInline{EscapeStatus: status, Content: template.HTML(content)}
+ status, content := charset.EscapeControlHTML(s, locale)
+ return DiffInline{EscapeStatus: status, Content: content}
}
// DiffInlineWithHighlightCode makes a DiffInline with code highlight and hidden unicode characters escaped
func DiffInlineWithHighlightCode(fileName, language, code string, locale translation.Locale) DiffInline {
highlighted, _ := highlight.Code(fileName, language, code)
status, content := charset.EscapeControlHTML(highlighted, locale)
- return DiffInline{EscapeStatus: status, Content: template.HTML(content)}
+ return DiffInline{EscapeStatus: status, Content: content}
}
// GetComputedInlineDiffFor computes inline diff for the given line.
@@ -1120,7 +1120,7 @@ func GetDiff(ctx context.Context, gitRepo *git.Repository, opts *DiffOptions, fi
return nil, err
}
- if (len(opts.BeforeCommitID) == 0 || opts.BeforeCommitID == objectFormat.Empty().String()) && commit.ParentCount() == 0 {
+ if (len(opts.BeforeCommitID) == 0 || opts.BeforeCommitID == objectFormat.EmptyObjectID().String()) && commit.ParentCount() == 0 {
cmdDiff.AddArguments("diff", "--src-prefix=\\a/", "--dst-prefix=\\b/", "-M").
AddArguments(opts.WhitespaceBehavior...).
AddDynamicArguments(objectFormat.EmptyTree().String()).
@@ -1229,7 +1229,7 @@ func GetDiff(ctx context.Context, gitRepo *git.Repository, opts *DiffOptions, fi
}
diffPaths := []string{opts.BeforeCommitID + separator + opts.AfterCommitID}
- if len(opts.BeforeCommitID) == 0 || opts.BeforeCommitID == objectFormat.Empty().String() {
+ if len(opts.BeforeCommitID) == 0 || opts.BeforeCommitID == objectFormat.EmptyObjectID().String() {
diffPaths = []string{objectFormat.EmptyTree().String(), opts.AfterCommitID}
}
diff.NumFiles, diff.TotalAddition, diff.TotalDeletion, err = git.GetDiffShortStat(gitRepo.Ctx, repoPath, nil, diffPaths...)
@@ -1267,7 +1267,7 @@ func GetPullDiffStats(gitRepo *git.Repository, opts *DiffOptions) (*PullDiffStat
}
diffPaths := []string{opts.BeforeCommitID + separator + opts.AfterCommitID}
- if len(opts.BeforeCommitID) == 0 || opts.BeforeCommitID == objectFormat.Empty().String() {
+ if len(opts.BeforeCommitID) == 0 || opts.BeforeCommitID == objectFormat.EmptyObjectID().String() {
diffPaths = []string{objectFormat.EmptyTree().String(), opts.AfterCommitID}
}
diff --git a/services/gitdiff/highlightdiff.go b/services/gitdiff/highlightdiff.go
index f1e2b1d3cb31a..35d48445504ae 100644
--- a/services/gitdiff/highlightdiff.go
+++ b/services/gitdiff/highlightdiff.go
@@ -93,10 +93,10 @@ func (hcd *highlightCodeDiff) diffWithHighlight(filename, language, codeA, codeB
highlightCodeA, _ := highlight.Code(filename, language, codeA)
highlightCodeB, _ := highlight.Code(filename, language, codeB)
- highlightCodeA = hcd.convertToPlaceholders(highlightCodeA)
- highlightCodeB = hcd.convertToPlaceholders(highlightCodeB)
+ convertedCodeA := hcd.convertToPlaceholders(string(highlightCodeA))
+ convertedCodeB := hcd.convertToPlaceholders(string(highlightCodeB))
- diffs := diffMatchPatch.DiffMain(highlightCodeA, highlightCodeB, true)
+ diffs := diffMatchPatch.DiffMain(convertedCodeA, convertedCodeB, true)
diffs = diffMatchPatch.DiffCleanupEfficiency(diffs)
for i := range diffs {
diff --git a/services/migrations/common.go b/services/migrations/common.go
index 278c156b036cb..d88518899d052 100644
--- a/services/migrations/common.go
+++ b/services/migrations/common.go
@@ -49,7 +49,7 @@ func CheckAndEnsureSafePR(pr *base.PullRequest, commonCloneBaseURL string, g bas
// SECURITY: SHAs Must be a SHA
// FIXME: hash only a SHA1
- CommitType := git.ObjectFormatFromID(git.Sha1)
+ CommitType := git.Sha1ObjectFormat
if pr.MergeCommitSHA != "" && !CommitType.IsValid(pr.MergeCommitSHA) {
WarnAndNotice("PR #%d in %s has invalid MergeCommitSHA: %s", pr.Number, g, pr.MergeCommitSHA)
pr.MergeCommitSHA = ""
diff --git a/services/migrations/gitea_uploader_test.go b/services/migrations/gitea_uploader_test.go
index b6c9b814772a5..3dec3a26fc4a9 100644
--- a/services/migrations/gitea_uploader_test.go
+++ b/services/migrations/gitea_uploader_test.go
@@ -232,7 +232,7 @@ func TestGiteaUploadUpdateGitForPullRequest(t *testing.T) {
//
fromRepo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
baseRef := "master"
- assert.NoError(t, git.InitRepository(git.DefaultContext, fromRepo.RepoPath(), false, fromRepo.ObjectFormat))
+ assert.NoError(t, git.InitRepository(git.DefaultContext, fromRepo.RepoPath(), false, fromRepo.ObjectFormatName))
err := git.NewCommand(git.DefaultContext, "symbolic-ref").AddDynamicArguments("HEAD", git.BranchPrefix+baseRef).Run(&git.RunOpts{Dir: fromRepo.RepoPath()})
assert.NoError(t, err)
assert.NoError(t, os.WriteFile(filepath.Join(fromRepo.RepoPath(), "README.md"), []byte(fmt.Sprintf("# Testing Repository\n\nOriginally created in: %s", fromRepo.RepoPath())), 0o644))
diff --git a/services/mirror/mirror_pull.go b/services/mirror/mirror_pull.go
index b3ecf2fc54e1a..6f03e14ab08bd 100644
--- a/services/mirror/mirror_pull.go
+++ b/services/mirror/mirror_pull.go
@@ -484,7 +484,7 @@ func SyncPullMirror(ctx context.Context, repoID int64) bool {
}
notify_service.SyncPushCommits(ctx, m.Repo.MustOwner(ctx), m.Repo, &repo_module.PushUpdateOptions{
RefFullName: result.refName,
- OldCommitID: objectFormat.Empty().String(),
+ OldCommitID: objectFormat.EmptyObjectID().String(),
NewCommitID: commitID,
}, repo_module.NewPushCommits())
notify_service.SyncCreateRef(ctx, m.Repo.MustOwner(ctx), m.Repo, result.refName, commitID)
diff --git a/services/packages/cargo/index.go b/services/packages/cargo/index.go
index 48bd0a4d80a25..9514e35bedd9a 100644
--- a/services/packages/cargo/index.go
+++ b/services/packages/cargo/index.go
@@ -271,7 +271,7 @@ func alterRepositoryContent(ctx context.Context, doer *user_model.User, repo *re
if !git.IsErrBranchNotExist(err) || !repo.IsEmpty {
return err
}
- if err := t.Init(repo.ObjectFormat); err != nil {
+ if err := t.Init(repo.ObjectFormatName); err != nil {
return err
}
} else {
diff --git a/services/pull/pull.go b/services/pull/pull.go
index a16d1be1c1cbd..6094a4ed31b9e 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 fde8673a2403f..36bdbde55c7a3 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 {
diff --git a/services/release/release.go b/services/release/release.go
index 4cd520e82f965..fc91171fba6ae 100644
--- a/services/release/release.go
+++ b/services/release/release.go
@@ -89,14 +89,14 @@ func createTag(ctx context.Context, gitRepo *git.Repository, rel *repo_model.Rel
objectFormat, _ := gitRepo.GetObjectFormat()
commits := repository.NewPushCommits()
commits.HeadCommit = repository.CommitToPushCommit(commit)
- commits.CompareURL = rel.Repo.ComposeCompareURL(objectFormat.Empty().String(), commit.ID.String())
+ commits.CompareURL = rel.Repo.ComposeCompareURL(objectFormat.EmptyObjectID().String(), commit.ID.String())
refFullName := git.RefNameFromTag(rel.TagName)
notify_service.PushCommits(
ctx, rel.Publisher, rel.Repo,
&repository.PushUpdateOptions{
RefFullName: refFullName,
- OldCommitID: objectFormat.Empty().String(),
+ OldCommitID: objectFormat.EmptyObjectID().String(),
NewCommitID: commit.ID.String(),
}, commits)
notify_service.CreateRef(ctx, rel.Publisher, rel.Repo, refFullName, commit.ID.String())
@@ -335,7 +335,7 @@ func DeleteReleaseByID(ctx context.Context, repo *repo_model.Repository, rel *re
&repository.PushUpdateOptions{
RefFullName: refName,
OldCommitID: rel.Sha1,
- NewCommitID: objectFormat.Empty().String(),
+ NewCommitID: objectFormat.EmptyObjectID().String(),
}, repository.NewPushCommits())
notify_service.DeleteRef(ctx, doer, repo, refName)
diff --git a/services/repository/branch.go b/services/repository/branch.go
index b797917757ede..dca938444aa35 100644
--- a/services/repository/branch.go
+++ b/services/repository/branch.go
@@ -408,7 +408,7 @@ func DeleteBranch(ctx context.Context, doer *user_model.User, repo *repo_model.R
&repo_module.PushUpdateOptions{
RefFullName: git.RefNameFromBranch(branchName),
OldCommitID: commit.ID.String(),
- NewCommitID: objectFormat.Empty().String(),
+ NewCommitID: objectFormat.EmptyObjectID().String(),
PusherID: doer.ID,
PusherName: doer.Name,
RepoUserName: repo.OwnerName,
diff --git a/services/repository/check.go b/services/repository/check.go
index 23c4f79bf2045..b874ede51fdbc 100644
--- a/services/repository/check.go
+++ b/services/repository/check.go
@@ -192,7 +192,7 @@ func ReinitMissingRepositories(ctx context.Context) error {
default:
}
log.Trace("Initializing %d/%d...", repo.OwnerID, repo.ID)
- if err := git.InitRepository(ctx, repo.RepoPath(), true, repo.ObjectFormat); err != nil {
+ if err := git.InitRepository(ctx, repo.RepoPath(), true, repo.ObjectFormatName); err != nil {
log.Error("Unable (re)initialize repository %d at %s. Error: %v", repo.ID, repo.RepoPath(), err)
if err2 := system_model.CreateRepositoryNotice("InitRepository [%d]: %v", repo.ID, err); err2 != nil {
log.Error("CreateRepositoryNotice: %v", err2)
diff --git a/services/repository/create.go b/services/repository/create.go
index a41904eb7cdf0..bcf2c85c21817 100644
--- a/services/repository/create.go
+++ b/services/repository/create.go
@@ -27,23 +27,23 @@ import (
// CreateRepoOptions contains the create repository options
type CreateRepoOptions struct {
- Name string
- Description string
- OriginalURL string
- GitServiceType api.GitServiceType
- Gitignores string
- IssueLabels string
- License string
- Readme string
- DefaultBranch string
- IsPrivate bool
- IsMirror bool
- IsTemplate bool
- AutoInit bool
- Status repo_model.RepositoryStatus
- TrustModel repo_model.TrustModelType
- MirrorInterval string
- ObjectFormat git.ObjectFormat
+ Name string
+ Description string
+ OriginalURL string
+ GitServiceType api.GitServiceType
+ Gitignores string
+ IssueLabels string
+ License string
+ Readme string
+ DefaultBranch string
+ IsPrivate bool
+ IsMirror bool
+ IsTemplate bool
+ AutoInit bool
+ Status repo_model.RepositoryStatus
+ TrustModel repo_model.TrustModelType
+ MirrorInterval string
+ ObjectFormatName string
}
func prepareRepoCommit(ctx context.Context, repo *repo_model.Repository, tmpDir, repoPath string, opts CreateRepoOptions) error {
@@ -135,7 +135,7 @@ func prepareRepoCommit(ctx context.Context, repo *repo_model.Repository, tmpDir,
// InitRepository initializes README and .gitignore if needed.
func initRepository(ctx context.Context, repoPath string, u *user_model.User, repo *repo_model.Repository, opts CreateRepoOptions) (err error) {
- if err = repo_module.CheckInitRepository(ctx, repo.OwnerName, repo.Name, opts.ObjectFormat); err != nil {
+ if err = repo_module.CheckInitRepository(ctx, repo.OwnerName, repo.Name, opts.ObjectFormatName); err != nil {
return err
}
@@ -210,10 +210,6 @@ func CreateRepositoryDirectly(ctx context.Context, doer, u *user_model.User, opt
opts.DefaultBranch = setting.Repository.DefaultBranch
}
- if opts.ObjectFormat == nil {
- opts.ObjectFormat = git.ObjectFormatFromID(git.Sha1)
- }
-
// Check if label template exist
if len(opts.IssueLabels) > 0 {
if _, err := repo_module.LoadTemplateLabelsByDisplayName(opts.IssueLabels); err != nil {
@@ -239,7 +235,7 @@ func CreateRepositoryDirectly(ctx context.Context, doer, u *user_model.User, opt
TrustModel: opts.TrustModel,
IsMirror: opts.IsMirror,
DefaultBranch: opts.DefaultBranch,
- ObjectFormat: opts.ObjectFormat,
+ ObjectFormatName: opts.ObjectFormatName,
}
var rollbackRepo *repo_model.Repository
diff --git a/services/repository/files/cherry_pick.go b/services/repository/files/cherry_pick.go
index 0085e88d55274..e88ea16119799 100644
--- a/services/repository/files/cherry_pick.go
+++ b/services/repository/files/cherry_pick.go
@@ -11,6 +11,7 @@ import (
"code.gitea.io/gitea/models"
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
+ "code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/services/pull"
@@ -66,7 +67,7 @@ func CherryPick(ctx context.Context, repo *repo_model.Repository, doer *user_mod
}
parent, err := commit.ParentID(0)
if err != nil {
- parent = repo.ObjectFormat.EmptyTree()
+ parent = git.ObjectFormatFromName(repo.ObjectFormatName).EmptyTree()
}
base, right := parent.String(), commit.ID.String()
diff --git a/services/repository/files/temp_repo.go b/services/repository/files/temp_repo.go
index 0b5aaba1544ad..6a0b7b675c81e 100644
--- a/services/repository/files/temp_repo.go
+++ b/services/repository/files/temp_repo.go
@@ -77,8 +77,8 @@ func (t *TemporaryUploadRepository) Clone(branch string) error {
}
// Init the repository
-func (t *TemporaryUploadRepository) Init(objectFormat git.ObjectFormat) error {
- if err := git.InitRepository(t.ctx, t.basePath, false, objectFormat); err != nil {
+func (t *TemporaryUploadRepository) Init(objectFormatName string) error {
+ if err := git.InitRepository(t.ctx, t.basePath, false, objectFormatName); err != nil {
return err
}
gitRepo, err := git.OpenRepository(t.ctx, t.basePath)
diff --git a/services/repository/files/update.go b/services/repository/files/update.go
index d202717ef5706..dd8d9ee42563d 100644
--- a/services/repository/files/update.go
+++ b/services/repository/files/update.go
@@ -155,8 +155,7 @@ func ChangeRepoFiles(ctx context.Context, repo *repo_model.Repository, doer *use
if !git.IsErrBranchNotExist(err) || !repo.IsEmpty {
return nil, err
}
- objectFormat, _ := gitRepo.GetObjectFormat()
- if err := t.Init(objectFormat); err != nil {
+ if err := t.Init(repo.ObjectFormatName); err != nil {
return nil, err
}
hasOldBranch = false
diff --git a/services/repository/files/upload.go b/services/repository/files/upload.go
index 8be8773544779..61e38b55a3705 100644
--- a/services/repository/files/upload.go
+++ b/services/repository/files/upload.go
@@ -91,7 +91,7 @@ func UploadRepoFiles(ctx context.Context, repo *repo_model.Repository, doer *use
if !git.IsErrBranchNotExist(err) || !repo.IsEmpty {
return err
}
- if err = t.Init(repo.ObjectFormat); err != nil {
+ if err = t.Init(repo.ObjectFormatName); err != nil {
return err
}
hasOldBranch = false
diff --git a/services/repository/push.go b/services/repository/push.go
index 3003933c34bcf..3bc7a78cb955d 100644
--- a/services/repository/push.go
+++ b/services/repository/push.go
@@ -111,7 +111,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
log.Trace("pushUpdates: %-v %s %s %s", repo, opts.OldCommitID, opts.NewCommitID, opts.RefFullName)
if opts.IsNewRef() && opts.IsDelRef() {
- return fmt.Errorf("old and new revisions are both %s", objectFormat.Empty())
+ return fmt.Errorf("old and new revisions are both %s", objectFormat.EmptyObjectID())
}
if opts.RefFullName.IsTag() {
if pusher == nil || pusher.ID != opts.PusherID {
@@ -131,7 +131,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
&repo_module.PushUpdateOptions{
RefFullName: git.RefNameFromTag(tagName),
OldCommitID: opts.OldCommitID,
- NewCommitID: objectFormat.Empty().String(),
+ NewCommitID: objectFormat.EmptyObjectID().String(),
}, repo_module.NewPushCommits())
delTags = append(delTags, tagName)
@@ -144,13 +144,13 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
commits := repo_module.NewPushCommits()
commits.HeadCommit = repo_module.CommitToPushCommit(newCommit)
- commits.CompareURL = repo.ComposeCompareURL(objectFormat.Empty().String(), opts.NewCommitID)
+ commits.CompareURL = repo.ComposeCompareURL(objectFormat.EmptyObjectID().String(), opts.NewCommitID)
notify_service.PushCommits(
ctx, pusher, repo,
&repo_module.PushUpdateOptions{
RefFullName: opts.RefFullName,
- OldCommitID: objectFormat.Empty().String(),
+ OldCommitID: objectFormat.EmptyObjectID().String(),
NewCommitID: opts.NewCommitID,
}, commits)
@@ -234,7 +234,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
}
oldCommitID := opts.OldCommitID
- if oldCommitID == objectFormat.Empty().String() && len(commits.Commits) > 0 {
+ if oldCommitID == objectFormat.EmptyObjectID().String() && len(commits.Commits) > 0 {
oldCommit, err := gitRepo.GetCommit(commits.Commits[len(commits.Commits)-1].Sha1)
if err != nil && !git.IsErrNotExist(err) {
log.Error("unable to GetCommit %s from %-v: %v", oldCommitID, repo, err)
@@ -250,11 +250,11 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
}
}
- if oldCommitID == objectFormat.Empty().String() && repo.DefaultBranch != branch {
+ if oldCommitID == objectFormat.EmptyObjectID().String() && repo.DefaultBranch != branch {
oldCommitID = repo.DefaultBranch
}
- if oldCommitID != objectFormat.Empty().String() {
+ if oldCommitID != objectFormat.EmptyObjectID().String() {
commits.CompareURL = repo.ComposeCompareURL(oldCommitID, opts.NewCommitID)
} else {
commits.CompareURL = ""
diff --git a/services/wiki/wiki.go b/services/wiki/wiki.go
index ecda926ec1e2d..f98854c8dd5f6 100644
--- a/services/wiki/wiki.go
+++ b/services/wiki/wiki.go
@@ -36,7 +36,7 @@ func InitWiki(ctx context.Context, repo *repo_model.Repository) error {
return nil
}
- if err := git.InitRepository(ctx, repo.WikiPath(), true, git.ObjectFormatFromID(git.Sha1)); err != nil {
+ if err := git.InitRepository(ctx, repo.WikiPath(), true, repo.ObjectFormatName); err != nil {
return fmt.Errorf("InitRepository: %w", err)
} else if err = repo_module.CreateDelegateHooks(repo.WikiPath()); err != nil {
return fmt.Errorf("createDelegateHooks: %w", err)
diff --git a/services/wiki/wiki_test.go b/services/wiki/wiki_test.go
index 9981fb42583f3..277fa086ac13c 100644
--- a/services/wiki/wiki_test.go
+++ b/services/wiki/wiki_test.go
@@ -302,7 +302,7 @@ func TestPrepareWikiFileName_FirstPage(t *testing.T) {
// Now create a temporaryDirectory
tmpDir := t.TempDir()
- err := git.InitRepository(git.DefaultContext, tmpDir, true, git.ObjectFormatFromID(git.Sha1))
+ err := git.InitRepository(git.DefaultContext, tmpDir, true, git.Sha1ObjectFormat.Name())
assert.NoError(t, err)
gitRepo, err := git.OpenRepository(git.DefaultContext, tmpDir)
diff --git a/templates/admin/config.tmpl b/templates/admin/config.tmpl
index 7eb9d086e61cc..1cc4b7bb09ae5 100644
--- a/templates/admin/config.tmpl
+++ b/templates/admin/config.tmpl
@@ -151,8 +151,6 @@
{{if .FileContent}}{{.FileContent | Safe}}{{end}}+
{{if .FileContent}}{{.FileContent}}{{end}}{{else if not .IsTextSource}}
{{$code | Safe}}
{{$code}}