aboutsummaryrefslogtreecommitdiffstats
path: root/templates/repo/editor
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2022-02-09 20:28:55 +0000
committerGitHub <noreply@github.com>2022-02-09 20:28:55 +0000
commiteb748f5f3c93e8e347309fc75ea8273c06a5489b (patch)
treefceec474a21fa35437bcf3e90bd549c11976b72e /templates/repo/editor
parent439ad34c71b8777a9dac369c643560b18bc41bab (diff)
downloadgitea-eb748f5f3c93e8e347309fc75ea8273c06a5489b.tar.gz
gitea-eb748f5f3c93e8e347309fc75ea8273c06a5489b.zip
Add apply-patch, basic revert and cherry-pick functionality (#17902)
This code adds a simple endpoint to apply patches to repositories and branches on gitea. This is then used along with the conflicting checking code in #18004 to provide a basic implementation of cherry-pick revert. Now because the buttons necessary for cherry-pick and revert have required us to create a dropdown next to the Browse Source button I've also implemented Create Branch and Create Tag operations. Fix #3880 Fix #17986 Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'templates/repo/editor')
-rw-r--r--templates/repo/editor/cherry_pick.tmpl32
-rw-r--r--templates/repo/editor/patch.tmpl59
2 files changed, 91 insertions, 0 deletions
diff --git a/templates/repo/editor/cherry_pick.tmpl b/templates/repo/editor/cherry_pick.tmpl
new file mode 100644
index 0000000000..9cdda2ea83
--- /dev/null
+++ b/templates/repo/editor/cherry_pick.tmpl
@@ -0,0 +1,32 @@
+{{template "base/head" .}}
+<div class="page-content repository file editor edit">
+ {{template "repo/header" .}}
+ <div class="ui container">
+ {{template "base/alert" .}}
+ <form class="ui edit form" method="post" action="{{.RepoLink}}/_cherrypick/{{.SHA}}/{{.BranchName | PathEscapeSegments}}">
+ {{.CsrfTokenHtml}}
+ <input type="hidden" name="last_commit" value="{{.last_commit}}">
+ <input type="hidden" name="page_has_posted" value="true">
+ <input type="hidden" name="revert" value="{{if eq .CherryPickType "revert"}}true{{else}}false{{end}}">
+ <div class="ui secondary menu">
+ <div class="fitted item treepath">
+ <div class="ui breadcrumb field {{if .Err_TreePath}}error{{end}}">
+ {{$shaurl := printf "%s/commit/%s" $.RepoLink (PathEscape .SHA)}}
+ {{$shalink := printf "<a class=\"ui blue sha label\" href=\"%s\">%s</a>" (Escape $shaurl) (ShortSha .SHA)}}
+ {{if eq .CherryPickType "revert"}}
+ {{.i18n.Tr "repo.editor.revert" $shalink | Str2html}}
+ {{else}}
+ {{.i18n.Tr "repo.editor.cherry_pick" $shalink | Str2html}}
+ {{end}}
+ <a class="section" href="{{$.RepoLink}}">{{.Repository.FullName}}</a>
+ <div class="divider">:</div>
+ <a class="section" href="{{$.BranchLink}}">{{.BranchName}}</a>
+ <span>{{.i18n.Tr "repo.editor.or"}} <a href="{{$shaurl}}">{{.i18n.Tr "repo.editor.cancel_lower"}}</a></span>
+ </div>
+ </div>
+ </div>
+ {{template "repo/editor/commit_form" .}}
+ </form>
+ </div>
+</div>
+{{template "base/footer" .}}
diff --git a/templates/repo/editor/patch.tmpl b/templates/repo/editor/patch.tmpl
new file mode 100644
index 0000000000..cecda907a4
--- /dev/null
+++ b/templates/repo/editor/patch.tmpl
@@ -0,0 +1,59 @@
+{{template "base/head" .}}
+<div class="page-content repository file editor edit">
+ {{template "repo/header" .}}
+ <div class="ui container">
+ {{template "base/alert" .}}
+ <form class="ui edit form" method="post" action="{{.RepoLink}}/_diffpatch/{{.BranchName | PathEscapeSegments}}">
+ {{.CsrfTokenHtml}}
+ <input type="hidden" name="last_commit" value="{{.last_commit}}">
+ <input type="hidden" name="page_has_posted" value="{{.PageHasPosted}}">
+ <div class="ui secondary menu">
+ <div class="fitted item treepath">
+ <div class="ui breadcrumb field {{if .Err_TreePath}}error{{end}}">
+ {{.i18n.Tr "repo.editor.patching"}}
+ <a class="section" href="{{$.RepoLink}}">{{.Repository.FullName}}</a>
+ <div class="divider">:</div>
+ <a class="section" href="{{$.BranchLink}}">{{.BranchName}}</a>
+ <span>{{.i18n.Tr "repo.editor.or"}} <a href="{{$.BranchLink}}">{{.i18n.Tr "repo.editor.cancel_lower"}}</a></span>
+ <input type="hidden" id="tree_path" name="tree_path" value="patch" required>
+ <input id="file-name" type="hidden" value="diff.patch">
+ </div>
+ </div>
+ </div>
+ <div class="field">
+ <div class="ui top attached tabular menu" data-write="write">
+ <a class="active item" data-tab="write">{{svg "octicon-code" 16 "mr-2"}}{{.i18n.Tr "repo.editor.new_patch"}}</a>
+ </div>
+ <div class="ui bottom attached active tab segment" data-tab="write">
+ <textarea id="edit_area" name="content" class="hide" data-id="repo-{{.Repository.Name}}-patch"
+ data-context="{{.RepoLink}}"
+ data-line-wrap-extensions="{{.LineWrapExtensions}}">
+{{.FileContent}}</textarea>
+ <div class="editor-loading is-loading"></div>
+ </div>
+ </div>
+ {{template "repo/editor/commit_form" .}}
+ </form>
+ </div>
+
+ <div class="ui small basic modal" id="edit-empty-content-modal">
+ <div class="ui icon header">
+ <i class="file icon"></i>
+ {{.i18n.Tr "repo.editor.commit_empty_file_header"}}
+ </div>
+ <div class="center content">
+ <p>{{.i18n.Tr "repo.editor.commit_empty_file_text"}}</p>
+ </div>
+ <div class="actions">
+ <div class="ui red basic cancel inverted button">
+ <i class="remove icon"></i>
+ {{.i18n.Tr "repo.editor.cancel"}}
+ </div>
+ <div class="ui green basic ok inverted button">
+ <i class="save icon"></i>
+ {{.i18n.Tr "repo.editor.commit_changes"}}
+ </div>
+ </div>
+ </div>
+</div>
+{{template "base/footer" .}}