From 13ba41539cb9bb66bc1840482dbfddcce9678779 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Sun, 26 Jan 2020 10:45:41 +0000 Subject: [PATCH 01/31] Add apply-patch button This code adds a simple endpoint to apply patches to repositories and branches on gitea. Signed-off-by: Andrew Thornton --- modules/git/diff.go | 11 +- modules/structs/repo_file.go | 8 ++ options/locale/locale_en-US.ini | 4 + routers/api/v1/api.go | 1 + routers/api/v1/repo/commits.go | 1 + routers/api/v1/repo/patch.go | 106 +++++++++++++++++++ routers/web/repo/commit.go | 1 + routers/web/repo/patch.go | 113 ++++++++++++++++++++ routers/web/web.go | 2 + services/repository/files/patch.go | 161 +++++++++++++++++++++++++++++ templates/repo/editor/patch.tmpl | 59 +++++++++++ templates/repo/home.tmpl | 5 + templates/swagger/v1_json.tmpl | 44 ++++++++ 13 files changed, 510 insertions(+), 6 deletions(-) create mode 100644 routers/api/v1/repo/patch.go create mode 100644 routers/web/repo/patch.go create mode 100644 services/repository/files/patch.go create mode 100644 templates/repo/editor/patch.tmpl diff --git a/modules/git/diff.go b/modules/git/diff.go index 3a82cda1ce037..018f250d42c90 100644 --- a/modules/git/diff.go +++ b/modules/git/diff.go @@ -30,13 +30,13 @@ const ( ) // GetRawDiff dumps diff results of repository in given commit ID to io.Writer. -func GetRawDiff(repoPath, commitID string, diffType RawDiffType, writer io.Writer) error { - return GetRawDiffForFile(repoPath, "", commitID, diffType, "", writer) +func GetRawDiff(ctx context.Context, repoPath, commitID string, diffType RawDiffType, writer io.Writer) error { + return GetRawDiffForFile(ctx, repoPath, "", commitID, diffType, "", writer) } // GetRawDiffForFile dumps diff results of file in given commit ID to io.Writer. -func GetRawDiffForFile(repoPath, startCommit, endCommit string, diffType RawDiffType, file string, writer io.Writer) error { - repo, err := OpenRepository(repoPath) +func GetRawDiffForFile(ctx context.Context, repoPath, startCommit, endCommit string, diffType RawDiffType, file string, writer io.Writer) error { + repo, err := OpenRepositoryCtx(ctx, repoPath) if err != nil { return fmt.Errorf("OpenRepository: %v", err) } @@ -223,8 +223,7 @@ func CutDiffAroundLine(originalDiff io.Reader, line int64, old bool, numbersOfLi } } } - err := scanner.Err() - if err != nil { + if err := scanner.Err(); err != nil { return "", err } diff --git a/modules/structs/repo_file.go b/modules/structs/repo_file.go index 71733c90e7045..e2947bf7ac7b0 100644 --- a/modules/structs/repo_file.go +++ b/modules/structs/repo_file.go @@ -50,6 +50,14 @@ type UpdateFileOptions struct { FromPath string `json:"from_path" binding:"MaxSize(500)"` } +// ApplyDiffPatchFileOptions options for applying a diff patch +// Note: `author` and `committer` are optional (if only one is given, it will be used for the other, otherwise the authenticated user will be used) +type ApplyDiffPatchFileOptions struct { + DeleteFileOptions + // required: true + Content string `json:"content"` +} + // FileLinksResponse contains the links for a repo's file type FileLinksResponse struct { Self *string `json:"self"` diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 94d351f0cb14b..2dc4ce5b39d63 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1028,6 +1028,10 @@ editor.add_tmpl = Add '' editor.add = Add '%s' editor.update = Update '%s' editor.delete = Delete '%s' +editor.patch = Apply Patch +editor.patching = Patching: +editor.fail_to_apply_patch = Unable to apply patch '%s' +editor.new_patch = New Patch editor.commit_message_desc = Add an optional extended description… editor.signoff_desc = Add a Signed-off-by trailer by the committer at the end of the commit log message. editor.commit_directly_to_this_branch = Commit directly to the %s branch. diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index 867803f8dd5f9..197a10529afa1 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -971,6 +971,7 @@ func Routes(sessioner func(http.Handler) http.Handler) *web.Route { m.Get("/tags/{sha}", context.RepoRefForAPI, repo.GetAnnotatedTag) m.Get("/notes/{sha}", repo.GetNote) }, reqRepoReader(unit.TypeCode)) + m.Post("/diffpatch", reqRepoWriter(unit.TypeCode), reqToken(), bind(api.ApplyDiffPatchFileOptions{}), repo.ApplyDiffPatch) m.Group("/contents", func() { m.Get("", repo.GetContentsList) m.Get("/*", repo.GetContents) diff --git a/routers/api/v1/repo/commits.go b/routers/api/v1/repo/commits.go index 9907054b831d5..3e4b4010fa869 100644 --- a/routers/api/v1/repo/commits.go +++ b/routers/api/v1/repo/commits.go @@ -251,6 +251,7 @@ func DownloadCommitDiffOrPatch(ctx *context.APIContext) { // "$ref": "#/responses/notFound" repoPath := models.RepoPath(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name) if err := git.GetRawDiff( + ctx, repoPath, ctx.Params(":sha"), git.RawDiffType(ctx.Params(":diffType")), diff --git a/routers/api/v1/repo/patch.go b/routers/api/v1/repo/patch.go new file mode 100644 index 0000000000000..e2ce255fe91e2 --- /dev/null +++ b/routers/api/v1/repo/patch.go @@ -0,0 +1,106 @@ +// Copyright 2020 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package repo + +import ( + "net/http" + "time" + + "code.gitea.io/gitea/models" + "code.gitea.io/gitea/modules/context" + "code.gitea.io/gitea/modules/git" + api "code.gitea.io/gitea/modules/structs" + "code.gitea.io/gitea/modules/web" + "code.gitea.io/gitea/services/repository/files" +) + +// ApplyDiffPatch handles API call for applying a patch +func ApplyDiffPatch(ctx *context.APIContext) { + // swagger:operation POST /repos/{owner}/{repo}/diffpatch repository repoApplyDiffPatch + // --- + // summary: Apply diff patch to repository + // consumes: + // - application/json + // produces: + // - application/json + // parameters: + // - name: owner + // in: path + // description: owner of the repo + // type: string + // required: true + // - name: repo + // in: path + // description: name of the repo + // type: string + // required: true + // - name: body + // in: body + // required: true + // schema: + // "$ref": "#/definitions/UpdateFileOptions" + // responses: + // "200": + // "$ref": "#/responses/FileResponse" + apiOpts := web.GetForm(ctx).(*api.ApplyDiffPatchFileOptions) + + opts := &files.ApplyDiffPatchOptions{ + Content: apiOpts.Content, + SHA: apiOpts.SHA, + Message: apiOpts.Message, + OldBranch: apiOpts.BranchName, + NewBranch: apiOpts.NewBranchName, + Committer: &files.IdentityOptions{ + Name: apiOpts.Committer.Name, + Email: apiOpts.Committer.Email, + }, + Author: &files.IdentityOptions{ + Name: apiOpts.Author.Name, + Email: apiOpts.Author.Email, + }, + Dates: &files.CommitDateOptions{ + Author: apiOpts.Dates.Author, + Committer: apiOpts.Dates.Committer, + }, + Signoff: apiOpts.Signoff, + } + if opts.Dates.Author.IsZero() { + opts.Dates.Author = time.Now() + } + if opts.Dates.Committer.IsZero() { + opts.Dates.Committer = time.Now() + } + + if opts.Message == "" { + opts.Message = "apply-patch" + } + + if !canWriteFiles(ctx.Repo) { + ctx.Error(http.StatusInternalServerError, "ApplyPatch", models.ErrUserDoesNotHaveAccessToRepo{ + UserID: ctx.User.ID, + RepoName: ctx.Repo.Repository.LowerName, + }) + } + + fileResponse, err := files.ApplyDiffPatch(ctx.Repo.Repository, ctx.User, opts) + if err != nil { + if models.IsErrUserCannotCommit(err) || models.IsErrFilePathProtected(err) { + ctx.Error(http.StatusForbidden, "Access", err) + return + } + if models.IsErrBranchAlreadyExists(err) || models.IsErrFilenameInvalid(err) || models.IsErrSHADoesNotMatch(err) || + models.IsErrFilePathInvalid(err) || models.IsErrRepoFileAlreadyExists(err) { + ctx.Error(http.StatusUnprocessableEntity, "Invalid", err) + return + } + if models.IsErrBranchDoesNotExist(err) || git.IsErrBranchNotExist(err) { + ctx.Error(http.StatusNotFound, "BranchDoesNotExist", err) + return + } + ctx.Error(http.StatusInternalServerError, "ApplyPatch", err) + } else { + ctx.JSON(http.StatusCreated, fileResponse) + } +} diff --git a/routers/web/repo/commit.go b/routers/web/repo/commit.go index 993fc1c335f8a..fd69e131a377f 100644 --- a/routers/web/repo/commit.go +++ b/routers/web/repo/commit.go @@ -385,6 +385,7 @@ func RawDiff(ctx *context.Context) { repoPath = models.RepoPath(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name) } if err := git.GetRawDiff( + ctx, repoPath, ctx.Params(":sha"), git.RawDiffType(ctx.Params(":ext")), diff --git a/routers/web/repo/patch.go b/routers/web/repo/patch.go new file mode 100644 index 0000000000000..79325d57a9598 --- /dev/null +++ b/routers/web/repo/patch.go @@ -0,0 +1,113 @@ +// Copyright 2020 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package repo + +import ( + "strings" + + "code.gitea.io/gitea/models" + "code.gitea.io/gitea/modules/base" + "code.gitea.io/gitea/modules/context" + "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/web" + "code.gitea.io/gitea/services/forms" + "code.gitea.io/gitea/services/repository/files" +) + +const ( + tplPatchFile base.TplName = "repo/editor/patch" +) + +// NewDiffPatch render create patch page +func NewDiffPatch(ctx *context.Context) { + ctx.Data["RequireHighlightJS"] = true + + canCommit := renderCommitRights(ctx) + + ctx.Data["TreePath"] = "patch" + + ctx.Data["commit_summary"] = "" + ctx.Data["commit_message"] = "" + if canCommit { + ctx.Data["commit_choice"] = frmCommitChoiceDirect + } else { + ctx.Data["commit_choice"] = frmCommitChoiceNewBranch + } + ctx.Data["new_branch_name"] = GetUniquePatchBranchName(ctx) + ctx.Data["last_commit"] = ctx.Repo.CommitID + ctx.Data["LineWrapExtensions"] = strings.Join(setting.Repository.Editor.LineWrapExtensions, ",") + ctx.Data["BranchLink"] = ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL() + + ctx.HTML(200, tplPatchFile) +} + +// NewDiffPatchPost response for sending patch page +func NewDiffPatchPost(ctx *context.Context) { + form := web.GetForm(ctx).(*forms.EditRepoFileForm) + + canCommit := renderCommitRights(ctx) + branchName := ctx.Repo.BranchName + if form.CommitChoice == frmCommitChoiceNewBranch { + branchName = form.NewBranchName + } + ctx.Data["RequireHighlightJS"] = true + ctx.Data["TreePath"] = "patch" + ctx.Data["BranchLink"] = ctx.Repo.RepoLink + "/src/branch/" + ctx.Repo.BranchName + ctx.Data["FileContent"] = form.Content + ctx.Data["commit_summary"] = form.CommitSummary + ctx.Data["commit_message"] = form.CommitMessage + ctx.Data["commit_choice"] = form.CommitChoice + ctx.Data["new_branch_name"] = form.NewBranchName + ctx.Data["last_commit"] = ctx.Repo.CommitID + ctx.Data["LineWrapExtensions"] = strings.Join(setting.Repository.Editor.LineWrapExtensions, ",") + + if ctx.HasError() { + ctx.HTML(200, tplPatchFile) + return + } + + // Cannot commit to a an existing branch if user doesn't have rights + if branchName == ctx.Repo.BranchName && !canCommit { + ctx.Data["Err_NewBranchName"] = true + ctx.Data["commit_choice"] = frmCommitChoiceNewBranch + ctx.RenderWithErr(ctx.Tr("repo.editor.cannot_commit_to_protected_branch", branchName), tplEditFile, &form) + return + } + + // CommitSummary is optional in the web form, if empty, give it a default message based on add or update + // `message` will be both the summary and message combined + message := strings.TrimSpace(form.CommitSummary) + if len(message) == 0 { + message = ctx.Tr("repo.editor.patch") + } + + form.CommitMessage = strings.TrimSpace(form.CommitMessage) + if len(form.CommitMessage) > 0 { + message += "\n\n" + form.CommitMessage + } + + if _, err := files.ApplyDiffPatch(ctx.Repo.Repository, ctx.User, &files.ApplyDiffPatchOptions{ + LastCommitID: form.LastCommit, + OldBranch: ctx.Repo.BranchName, + NewBranch: branchName, + Message: message, + Content: strings.Replace(form.Content, "\r", "", -1), + }); err != nil { + if models.IsErrBranchAlreadyExists(err) { + // For when a user specifies a new branch that already exists + ctx.Data["Err_NewBranchName"] = true + if branchErr, ok := err.(models.ErrBranchAlreadyExists); ok { + ctx.RenderWithErr(ctx.Tr("repo.editor.branch_already_exists", branchErr.BranchName), tplEditFile, &form) + } else { + ctx.Error(500, err.Error()) + } + } else if models.IsErrCommitIDDoesNotMatch(err) { + ctx.RenderWithErr(ctx.Tr("repo.editor.file_changed_while_editing", ctx.Repo.RepoLink+"/compare/"+form.LastCommit+"..."+ctx.Repo.CommitID), tplPatchFile, &form) + } else { + ctx.RenderWithErr(ctx.Tr("repo.editor.fail_to_apply_patch", err), tplPatchFile, &form) + } + } + ctx.Redirect(ctx.Repo.RepoLink + "/compare/" + ctx.Repo.BranchName + "..." + form.NewBranchName) +} diff --git a/routers/web/web.go b/routers/web/web.go index c52d3483f0b2f..898a57932fb58 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -798,6 +798,8 @@ func RegisterRoutes(m *web.Route) { m.Combo("/_upload/*", repo.MustBeAbleToUpload). Get(repo.UploadFile). Post(bindIgnErr(forms.UploadRepoFileForm{}), repo.UploadFilePost) + m.Combo("/_diffpatch/*").Get(repo.NewDiffPatch). + Post(bindIgnErr(forms.EditRepoFileForm{}), repo.NewDiffPatchPost) }, context.RepoRefByType(context.RepoRefBranch), repo.MustBeEditable) m.Group("", func() { m.Post("/upload-file", repo.UploadFileToServer) diff --git a/services/repository/files/patch.go b/services/repository/files/patch.go new file mode 100644 index 0000000000000..0b870e2124223 --- /dev/null +++ b/services/repository/files/patch.go @@ -0,0 +1,161 @@ +// Copyright 2021 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package files + +import ( + "fmt" + "strings" + + "code.gitea.io/gitea/models" + 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" + api "code.gitea.io/gitea/modules/structs" + repo_service "code.gitea.io/gitea/services/repository" +) + +// ApplyDiffPatchOptions holds the repository diff patch update options +type ApplyDiffPatchOptions struct { + LastCommitID string + OldBranch string + NewBranch string + Message string + Content string + SHA string + Author *IdentityOptions + Committer *IdentityOptions + Dates *CommitDateOptions + Signoff bool +} + +// ApplyDiffPatch applies a patch to the given repository +func ApplyDiffPatch(repo *models.Repository, doer *user_model.User, opts *ApplyDiffPatchOptions) (*structs.FileResponse, error) { + // If no branch name is set, assume master + if opts.OldBranch == "" { + opts.OldBranch = repo.DefaultBranch + } + if opts.NewBranch == "" { + opts.NewBranch = opts.OldBranch + } + + // oldBranch must exist for this operation + if _, err := repo_service.GetBranch(repo, opts.OldBranch); err != nil { + return nil, err + } + + // A NewBranch can be specified for the patch to be applied to. + // Check to make sure the branch does not already exist, otherwise we can't proceed. + // If we aren't branching to a new branch, make sure user can commit to the given branch + if opts.NewBranch != opts.OldBranch { + existingBranch, err := repo_service.GetBranch(repo, opts.NewBranch) + if existingBranch != nil { + return nil, models.ErrBranchAlreadyExists{ + BranchName: opts.NewBranch, + } + } + if err != nil && !git.IsErrBranchNotExist(err) { + return nil, err + } + } else { + protectedBranch, err := repo.GetBranchProtection(opts.OldBranch) + if err != nil { + return nil, err + } + if protectedBranch != nil && !protectedBranch.CanUserPush(doer.ID) { + return nil, models.ErrUserCannotCommit{ + UserName: doer.LowerName, + } + } + if protectedBranch != nil && protectedBranch.RequireSignedCommits { + _, _, _, err := repo.SignCRUDAction(doer, repo.RepoPath(), opts.OldBranch) + if err != nil { + if !models.IsErrWontSign(err) { + return nil, err + } + return nil, models.ErrUserCannotCommit{ + UserName: doer.LowerName, + } + } + } + } + + message := strings.TrimSpace(opts.Message) + + author, committer := GetAuthorAndCommitterUsers(opts.Author, opts.Committer, doer) + + t, err := NewTemporaryUploadRepository(repo) + if err != nil { + log.Error("%v", err) + } + defer t.Close() + if err := t.Clone(opts.OldBranch); err != nil { + return nil, err + } + if err := t.SetDefaultIndex(); err != nil { + return nil, err + } + + // Get the commit of the original branch + commit, err := t.GetBranchCommit(opts.OldBranch) + if err != nil { + return nil, err // Couldn't get a commit for the branch + } + + // Assigned LastCommitID in opts if it hasn't been set + if opts.LastCommitID == "" { + opts.LastCommitID = commit.ID.String() + } else { + lastCommitID, err := t.gitRepo.ConvertToSHA1(opts.LastCommitID) + if err != nil { + return nil, fmt.Errorf("ApplyPatch: Invalid last commit ID: %v", err) + } + opts.LastCommitID = lastCommitID.String() + } + + stdout := &strings.Builder{} + stderr := &strings.Builder{} + + err = git.NewCommand("apply", "--index", "--cached", "--ignore-whitespace", "--whitespace=fix").RunInDirFullPipeline(t.basePath, stdout, stderr, strings.NewReader(opts.Content)) + if err != nil { + return nil, fmt.Errorf("Error: Stdout: %s\nStderr: %s\nErr: %v", stdout.String(), stderr.String(), err) + } + + // Now write the tree + treeHash, err := t.WriteTree() + if err != nil { + return nil, err + } + + // Now commit the tree + var commitHash string + if opts.Dates != nil { + commitHash, err = t.CommitTreeWithDate(author, committer, treeHash, message, opts.Signoff, opts.Dates.Author, opts.Dates.Committer) + } else { + commitHash, err = t.CommitTree(author, committer, treeHash, message, opts.Signoff) + } + if err != nil { + return nil, err + } + + // Then push this tree to NewBranch + if err := t.Push(doer, commitHash, opts.NewBranch); err != nil { + return nil, err + } + + commit, err = t.GetCommit(commitHash) + if err != nil { + return nil, err + } + + fileCommitResponse, _ := GetFileCommitResponse(repo, commit) // ok if fails, then will be nil + verification := GetPayloadCommitVerification(commit) + fileResponse := &api.FileResponse{ + Commit: fileCommitResponse, + Verification: verification, + } + + return fileResponse, nil +} diff --git a/templates/repo/editor/patch.tmpl b/templates/repo/editor/patch.tmpl new file mode 100644 index 0000000000000..aa38ef8889155 --- /dev/null +++ b/templates/repo/editor/patch.tmpl @@ -0,0 +1,59 @@ +{{template "base/head" .}} +
+ {{template "repo/header" .}} +
+ {{template "base/alert" .}} +
+ {{.CsrfTokenHtml}} + + + +
+ +
+ +
+
+
+ {{template "repo/editor/commit_form" .}} +
+
+ + +
+{{template "base/footer" .}} diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index 5ee6cc2df74cf..eddb74cc82099 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -85,6 +85,11 @@ {{.i18n.Tr "repo.editor.upload_file"}} {{end}} + {{if .CanAddFile}} + + {{.i18n.Tr "repo.editor.patch"}} + + {{end}} {{end}} {{if and (ne $n 0) (not .IsViewFile) (not .IsBlame) }} diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 6bbc0934811b6..fbe48eaf101f4 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -3377,6 +3377,50 @@ } } }, + "/repos/{owner}/{repo}/diffpatch": { + "post": { + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "repository" + ], + "summary": "Apply diff patch to repository", + "operationId": "repoApplyDiffPatch", + "parameters": [ + { + "type": "string", + "description": "owner of the repo", + "name": "owner", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "name of the repo", + "name": "repo", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/UpdateFileOptions" + } + } + ], + "responses": { + "200": { + "$ref": "#/responses/FileResponse" + } + } + } + }, "/repos/{owner}/{repo}/editorconfig/{filepath}": { "get": { "produces": [ From d477e5ae362f0a639bc71e0c78775b47c0182401 Mon Sep 17 00:00:00 2001 From: Andrew Thornton Date: Sat, 4 Dec 2021 01:02:42 +0000 Subject: [PATCH 02/31] placate lint Signed-off-by: Andrew Thornton --- routers/web/repo/patch.go | 2 +- services/repository/files/patch.go | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/routers/web/repo/patch.go b/routers/web/repo/patch.go index 79325d57a9598..c217cb9c962d7 100644 --- a/routers/web/repo/patch.go +++ b/routers/web/repo/patch.go @@ -93,7 +93,7 @@ func NewDiffPatchPost(ctx *context.Context) { OldBranch: ctx.Repo.BranchName, NewBranch: branchName, Message: message, - Content: strings.Replace(form.Content, "\r", "", -1), + Content: strings.ReplaceAll(form.Content, "\r", ""), }); err != nil { if models.IsErrBranchAlreadyExists(err) { // For when a user specifies a new branch that already exists diff --git a/services/repository/files/patch.go b/services/repository/files/patch.go index 0b870e2124223..4fce9e6aa7530 100644 --- a/services/repository/files/patch.go +++ b/services/repository/files/patch.go @@ -13,7 +13,6 @@ import ( "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/structs" - api "code.gitea.io/gitea/modules/structs" repo_service "code.gitea.io/gitea/services/repository" ) @@ -152,7 +151,7 @@ func ApplyDiffPatch(repo *models.Repository, doer *user_model.User, opts *ApplyD fileCommitResponse, _ := GetFileCommitResponse(repo, commit) // ok if fails, then will be nil verification := GetPayloadCommitVerification(commit) - fileResponse := &api.FileResponse{ + fileResponse := &structs.FileResponse{ Commit: fileCommitResponse, Verification: verification, } From c3326b2f75b5ca17009f284b792af14d0e366eb8 Mon Sep 17 00:00:00 2001 From: zeripath Date: Sun, 5 Dec 2021 11:59:48 +0000 Subject: [PATCH 03/31] update copyright years --- routers/api/v1/repo/patch.go | 2 +- routers/web/repo/patch.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/routers/api/v1/repo/patch.go b/routers/api/v1/repo/patch.go index e2ce255fe91e2..2bbce912754ae 100644 --- a/routers/api/v1/repo/patch.go +++ b/routers/api/v1/repo/patch.go @@ -1,4 +1,4 @@ -// Copyright 2020 The Gitea Authors. All rights reserved. +// Copyright 2021 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. diff --git a/routers/web/repo/patch.go b/routers/web/repo/patch.go index c217cb9c962d7..ab299b2ee64c2 100644 --- a/routers/web/repo/patch.go +++ b/routers/web/repo/patch.go @@ -1,4 +1,4 @@ -// Copyright 2020 The Gitea Authors. All rights reserved. +// Copyright 2021 The Gitea Authors. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. From d4a4f1fe50d61231ca276945ac715c92a205cb98 Mon Sep 17 00:00:00 2001 From: zeripath Date: Mon, 6 Dec 2021 23:01:38 +0000 Subject: [PATCH 04/31] Update templates/repo/editor/patch.tmpl Co-authored-by: silverwind --- templates/repo/editor/patch.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/editor/patch.tmpl b/templates/repo/editor/patch.tmpl index aa38ef8889155..fd61047749e38 100644 --- a/templates/repo/editor/patch.tmpl +++ b/templates/repo/editor/patch.tmpl @@ -22,7 +22,7 @@