mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-14 01:35:55 +09:00
Web editor: improve delete file process
This commit is contained in:
1 parent
dad5c15520
commit
0114fdcba4
19 files changed
+217
-174
No files matched your search
@@ -3,7 +3,7 @@ Gogs - Go Git Service [
|
||||
|
||||
##### Current tip version: 0.9.90 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions)
|
||||
##### Current tip version: 0.9.91 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions)
|
||||
|
||||
| Web | UI | Preview |
|
||||
|:-------------:|:-------:|:-------:|
|
||||
|
||||
+2
-1
@@ -506,7 +506,8 @@ func runWeb(ctx *cli.Context) error {
|
||||
m.Post("/_preview/*", bindIgnErr(auth.EditPreviewDiffForm{}), repo.DiffPreviewPost)
|
||||
m.Combo("/_upload/*").Get(repo.UploadFile).
|
||||
Post(bindIgnErr(auth.UploadRepoFileForm{}), repo.UploadFilePost)
|
||||
m.Post("/_delete/*", bindIgnErr(auth.DeleteRepoFileForm{}), repo.DeleteFilePost)
|
||||
m.Combo("/_delete/*").Get(repo.DeleteFile).
|
||||
Post(bindIgnErr(auth.DeleteRepoFileForm{}), repo.DeleteFilePost)
|
||||
// m.Post("/upload-file", repo.UploadFileToServer)
|
||||
// m.Post("/upload-remove", bindIgnErr(auth.RemoveUploadFileForm{}), repo.RemoveUploadFileFromServer)
|
||||
}, reqRepoWriter, context.RepoRef(), func(ctx *context.Context) {
|
||||
|
||||
@@ -426,30 +426,31 @@ file_view_raw = View Raw
|
||||
file_permalink = Permalink
|
||||
file_too_large = This file is too large to be shown
|
||||
|
||||
cancel = Cancel
|
||||
cancel_lower = cancel
|
||||
or = or
|
||||
new_file = New file
|
||||
upload_files = Upload files
|
||||
find_file = Find file
|
||||
commit_changes = Commit Changes
|
||||
default_commit_message = Add an optional extended description...
|
||||
last_commit_info = %s edited this file %s
|
||||
delete_this_file = Delete this file
|
||||
edit_file = Edit file
|
||||
delete_confirm_message = Are you sure you want to delete this file?
|
||||
delete_commit_message = Write a note about this delete (optional)
|
||||
unable_to_update_file = Unable to update this file, error occurred
|
||||
must_be_writer = You must have write access to make or propose changes to this file
|
||||
filename_help = To add directory, just type it and press /. To remove a directory, go to the beginning of the field and press backspace.
|
||||
new_branch = new branch
|
||||
editor.new_file = New file
|
||||
editor.cannot_edit_non_text_files = Cannot edit non-text files
|
||||
editor.edit_this_file = Edit this file
|
||||
editor.must_be_on_a_branch = You must be on a branch to make or propose changes to this file
|
||||
editor.fork_before_edit = You must fork this repository before editing the file
|
||||
editor.delete_this_file = Delete this file
|
||||
editor.must_have_write_access = You must have write access to make or propose changes to this file
|
||||
editor.file_delete_success = File '%s' has been deleted successfully!
|
||||
editor.commit_changes = Commit Changes
|
||||
editor.add_tmpl = Add '%s/<filename>'
|
||||
editor.add = Add '%s'
|
||||
editor.update = Update '%s'
|
||||
editor.delete = Delete '%s'
|
||||
editor.commit_message_desc = Add an optional extended description...
|
||||
editor.commit_directly_to_this_branch = Commit directly to the <strong class="branch-name">%s</strong> branch.
|
||||
editor.create_new_branch = Create a <strong>new branch</strong> for this commit and start a pull request.
|
||||
editor.new_branch_name_desc = New branch name...
|
||||
editor.cancel = Cancel
|
||||
editor.filename_cannot_be_empty = Filename cannot be empty.
|
||||
editor.branch_already_exists = Branch '%s' already exists in this repository.
|
||||
editor.directory_is_a_file = Entry '%s' in the parent path is a file not a directory in this repository.
|
||||
@@ -457,12 +458,8 @@ editor.filename_is_a_directory = The filename '%s' is an existing directory in t
|
||||
editor.file_editing_no_longer_exists = The file '%s' you are editing no longer exists in the repository.
|
||||
editor.file_changed_while_editing = File content has been changed since you started editing. <a target="_blank" href="%s">Click here</a> to see what have been changed or <strong>press commit again</strong> to overwrite those changes.
|
||||
editor.file_already_exists = A file with name '%s' already exists in this repository.
|
||||
editor.add = Add '%s'
|
||||
editor.update = Update '%s'
|
||||
editor.failed_to_upload_files = An error occurred while updating file: %v
|
||||
editor.no_changes_to_show = There are no changes to show.
|
||||
create_branch = Create branch
|
||||
from = from
|
||||
upload_file = Upload file
|
||||
add_files_to_dir = Add files to %s
|
||||
add_subdir = Add subdirectory...
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
const APP_VER = "0.9.90.0828"
|
||||
const APP_VER = "0.9.91.0828"
|
||||
|
||||
func init() {
|
||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||
|
||||
+18
-23
@@ -95,14 +95,6 @@ func (repo *Repository) UpdateRepoFile(doer *User, opts UpdateRepoFileOptions) (
|
||||
}
|
||||
}
|
||||
|
||||
if len(opts.Message) == 0 {
|
||||
if opts.IsNewFile {
|
||||
opts.Message = "Add '" + opts.NewTreeName + "'"
|
||||
} else {
|
||||
opts.Message = "Update '" + opts.NewTreeName + "'"
|
||||
}
|
||||
}
|
||||
|
||||
localPath := repo.LocalCopyPath()
|
||||
filePath := path.Join(localPath, opts.NewTreeName)
|
||||
os.MkdirAll(path.Dir(filePath), os.ModePerm)
|
||||
@@ -228,7 +220,8 @@ func (repo *Repository) GetDiffPreview(branch, treePath, content string) (diff *
|
||||
|
||||
type DeleteRepoFileOptions struct {
|
||||
LastCommitID string
|
||||
Branch string
|
||||
OldBranch string
|
||||
NewBranch string
|
||||
TreePath string
|
||||
Message string
|
||||
}
|
||||
@@ -237,21 +230,23 @@ func (repo *Repository) DeleteRepoFile(doer *User, opts DeleteRepoFileOptions) (
|
||||
repoWorkingPool.CheckIn(com.ToStr(repo.ID))
|
||||
defer repoWorkingPool.CheckOut(com.ToStr(repo.ID))
|
||||
|
||||
localPath := repo.LocalCopyPath()
|
||||
if err = discardLocalRepoBranchChanges(localPath, opts.Branch); err != nil {
|
||||
return fmt.Errorf("discardLocalRepoBranchChanges [branch: %s]: %v", opts.Branch, err)
|
||||
} else if err = repo.UpdateLocalCopyBranch(opts.Branch); err != nil {
|
||||
return fmt.Errorf("UpdateLocalCopyBranch [branch: %s]: %v", opts.Branch, err)
|
||||
if err = repo.DiscardLocalRepoBranchChanges(opts.OldBranch); err != nil {
|
||||
return fmt.Errorf("DiscardLocalRepoBranchChanges [branch: %s]: %v", opts.OldBranch, err)
|
||||
} else if err = repo.UpdateLocalCopyBranch(opts.OldBranch); err != nil {
|
||||
return fmt.Errorf("UpdateLocalCopyBranch [branch: %s]: %v", opts.OldBranch, err)
|
||||
}
|
||||
|
||||
if opts.OldBranch != opts.NewBranch {
|
||||
if err := repo.CheckoutNewBranch(opts.OldBranch, opts.NewBranch); err != nil {
|
||||
return fmt.Errorf("CheckoutNewBranch [old_branch: %s, new_branch: %s]: %v", opts.OldBranch, opts.NewBranch, err)
|
||||
}
|
||||
}
|
||||
|
||||
localPath := repo.LocalCopyPath()
|
||||
if err = os.Remove(path.Join(localPath, opts.TreePath)); err != nil {
|
||||
return fmt.Errorf("Remove: %v", err)
|
||||
}
|
||||
|
||||
if len(opts.Message) == 0 {
|
||||
opts.Message = "Delete file '" + opts.TreePath + "'"
|
||||
}
|
||||
|
||||
if err = git.AddChanges(localPath, true); err != nil {
|
||||
return fmt.Errorf("git add --all: %v", err)
|
||||
} else if err = git.CommitChanges(localPath, git.CommitChangesOptions{
|
||||
@@ -259,8 +254,8 @@ func (repo *Repository) DeleteRepoFile(doer *User, opts DeleteRepoFileOptions) (
|
||||
Message: opts.Message,
|
||||
}); err != nil {
|
||||
return fmt.Errorf("CommitChanges: %v", err)
|
||||
} else if err = git.Push(localPath, "origin", opts.Branch); err != nil {
|
||||
return fmt.Errorf("git push origin %s: %v", opts.Branch, err)
|
||||
} else if err = git.Push(localPath, "origin", opts.NewBranch); err != nil {
|
||||
return fmt.Errorf("git push origin %s: %v", opts.NewBranch, err)
|
||||
}
|
||||
|
||||
gitRepo, err := git.OpenRepository(repo.RepoPath())
|
||||
@@ -268,9 +263,9 @@ func (repo *Repository) DeleteRepoFile(doer *User, opts DeleteRepoFileOptions) (
|
||||
log.Error(4, "OpenRepository: %v", err)
|
||||
return nil
|
||||
}
|
||||
commit, err := gitRepo.GetBranchCommit(opts.Branch)
|
||||
commit, err := gitRepo.GetBranchCommit(opts.NewBranch)
|
||||
if err != nil {
|
||||
log.Error(4, "GetBranchCommit [branch: %s]: %v", opts.Branch, err)
|
||||
log.Error(4, "GetBranchCommit [branch: %s]: %v", opts.NewBranch, err)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -283,7 +278,7 @@ func (repo *Repository) DeleteRepoFile(doer *User, opts DeleteRepoFileOptions) (
|
||||
PusherName: doer.Name,
|
||||
RepoOwnerID: repo.MustOwner().ID,
|
||||
RepoName: repo.Name,
|
||||
RefFullName: git.BRANCH_PREFIX + opts.Branch,
|
||||
RefFullName: git.BRANCH_PREFIX + opts.NewBranch,
|
||||
OldCommitID: opts.LastCommitID,
|
||||
NewCommitID: commit.ID.String(),
|
||||
Commits: pushCommits,
|
||||
|
||||
@@ -337,6 +337,9 @@ func (f *RemoveUploadFileForm) Validate(ctx *macaron.Context, errs binding.Error
|
||||
|
||||
type DeleteRepoFileForm struct {
|
||||
CommitSummary string `binding:"MaxSize(100)`
|
||||
CommitMessage string
|
||||
CommitChoice string `binding:"Required;MaxSize(50)"`
|
||||
NewBranchName string `binding:"AlphaDashDot;MaxSize(100)"`
|
||||
}
|
||||
|
||||
func (f *DeleteRepoFileForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
|
||||
|
||||
@@ -4346,7 +4346,7 @@ func confLocaleLocale_deDeIni() (*asset, error) {
|
||||
return a, nil
|
||||
}
|
||||
|
||||
var _confLocaleLocale_enUsIni = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xac\xbd\xfb\x72\xdb\x48\x92\x2f\xfc\x3f\x9e\x02\xed\x09\x87\xed\x08\x99\x1d\x3d\xb3\xdf\x25\x3a\xfa\xf2\xa9\xe5\xf6\x65\xd7\xb2\xb5\x96\x7a\xe6\x9b\xd3\xe1\x60\x83\x24\x44\x62\x4d\x02\x1c\x00\xb4\xac\x99\x98\x37\x38\x0f\x70\x9e\xef\x3c\xc9\xc9\xfc\x65\x66\x55\x16\x00\x4a\x76\xcf\xfa\x0f\x8b\xa8\xca\xba\x67\x65\xe5\xad\xb2\x8a\xfd\x7e\xbe\x2a\xbb\x65\xfe\x7d\x7e\x9a\xef\x8b\xaa\xde\x96\x5d\x97\x77\xe5\xf6\xfa\xe9\xa6\xe9\xfa\x72\x95\xbf\xa8\x7a\xfa\x6e\x3f\x56\xcb\x32\xcb\x36\xcd\xae\x24\xd0\x97\xf4\x27\x5b\x15\xdd\x66\xd1\x14\xed\x8a\x12\x9e\xd9\xef\xac\xfc\xb4\xdf\x36\x2d\x03\xfd\x2c\xbf\xb2\x4d\xb9\xdd\x73\x19\xfa\x93\x75\xd5\xba\x9e\x57\x35\x7d\x5e\xd2\xaf\xfc\x55\x2d\x29\xcd\xa1\xb7\xa4\xb7\x87\x5e\xd2\x0e\x7b\x4b\xfa\x65\x9f\xb5\xe5\xba\xa2\xde\xb4\x94\xf4\x4e\x7f\x66\x37\xe5\xa2\xab\x7a\x6e\xe9\x2f\xf2\x2b\xfb\x58\xb6\x5d\xd5\x70\xed\x7f\x96\x5f\xd9\xbe\x58\x33\xc0\x05\xfd\xc9\xfa\x72\xb7\xdf\x16\x28\x70\xa5\x3f\xb3\x6d\x51\xaf\x0f\x02\xf3\x5a\x7f\x66\xcb\xb6\xa4\xac\x79\x5d\xde\x50\xea\x19\x3e\x66\xb3\x59\x76\xa0\x49\x98\xef\xdb\xe6\xba\xda\x96\xf3\xa2\x5e\xcd\x77\x32\xcc\x5f\x28\x3d\xd7\xf4\x9c\xd2\x73\x4e\xc7\x10\xca\x15\x0d\x75\x5e\x74\x3a\x0e\x9a\x4b\x1a\x79\xd1\x65\xa8\xaa\x2e\x76\x56\x9a\x7f\x66\xe5\xae\xa8\xb6\x3c\x6b\xfc\x97\xfa\xdd\x75\x37\x0d\xa6\xf6\x42\x7f\xd2\x1c\xcc\xfb\xdb\x7d\x89\x29\x78\x7a\x45\xbf\xb2\x65\xb1\xef\x97\x9b\x82\xbb\x29\xbf\x32\x02\xda\x37\x34\x17\x4d\x7b\x0b\x38\xfb\xc8\x9a\x76\x5d\xd4\xd5\xdf\x8b\x5e\xe6\xe7\xad\xfb\xcc\x76\x55\xdb\x36\x3c\xb5\xe7\xf8\x91\xd1\xc8\xe7\x5c\x0f\xa5\xbc\xa1\x49\x70\xb5\x70\xce\xae\x5a\xb7\x32\x8b\x9c\x79\x8e\x2f\xae\x45\xf2\xb4\x26\xc9\x0a\xb5\x5d\x37\xed\x07\x4d\x7d\xce\x3f\x07\x55\x52\xe7\x34\x37\xed\x57\x51\xd3\x7a\x68\xee\x39\x3e\x12\x80\x2e\x2b\x56\x3b\x9a\xe1\x7d\x51\x97\x3c\x75\xa7\xfc\x45\xf3\x45\x5f\x59\xb1\x5c\x36\x87\xba\x9f\x77\x65\xdf\x57\xf5\x9a\xd7\xe0\x54\x92\xf2\x4b\x4d\xca\x5c\x5e\x48\xbb\x6d\x0e\x61\x95\x29\xfd\xaf\xf4\x99\x5f\xc8\xa7\xe4\xb9\x42\xc8\x0c\x25\xa9\xc9\xbe\xfa\x58\xf5\x55\x29\x8d\xd9\x47\xb6\x3f\x6c\xb7\x34\x9f\x7f\x3b\x94\x5d\xcf\x59\x17\xf4\x4d\x33\x20\xdf\x59\xd5\x75\x07\x94\x78\x85\x1f\x19\x2d\x6a\xbd\xc4\x70\xce\xf0\x23\xcb\x7e\xad\xea\xae\x2f\xb6\xdb\xf7\x99\xfe\x60\x60\xf9\x25\xf3\xd4\x57\x3d\x3a\xab\x89\xf9\x65\x5f\xee\x3b\x9e\xe8\xfc\x79\xd5\x76\xfd\xd3\xbe\x22\x54\x7b\x77\xa8\xb3\x55\xb3\xfc\x40\x48\xcc\x1b\x12\x5b\xe9\xd5\x75\x4e\x63\x7a\x44\x68\xdc\x1e\xea\x9a\x46\x91\xbf\x68\x68\x64\xd4\x4c\xb5\x2a\xf3\x67\x80\x3e\xc9\xf7\xdb\xb2\xe8\x08\xa4\x2c\x56\xf9\x77\x45\xde\x17\xed\xba\xec\xbf\x7f\x30\x5f\xd0\xe6\xf9\xf0\x20\xdf\xb4\xe5\xf5\xf7\x0f\x1e\x76\x0f\x7e\x78\x71\xa0\x62\xdb\xaa\x2e\xbb\xef\xbe\x2e\x7e\xc8\x97\x05\xe5\xd0\x58\x6f\xf3\x45\x79\xcd\x7b\x85\xda\xca\x09\x49\xeb\x35\xef\x93\xdb\x7e\xc3\x0d\xd2\x82\xd1\x8f\x2e\xe7\x8d\xfa\x55\xc6\xb3\x44\x1b\x79\xbe\x5a\x18\x51\x42\x87\x90\xdc\xd2\x2c\x9d\xdf\x5e\xfe\xe7\xeb\x93\xfc\x82\x28\xd3\xba\x2d\xf1\x9b\xfe\xa3\x12\x7f\xca\x69\xb4\x57\xd5\xb3\x9f\x66\x19\x95\xb5\x09\x79\x56\xf4\xc5\x82\xfb\x1e\x16\x89\x33\x65\x0f\x85\x3c\xec\x24\xa6\x75\xa0\x6b\x5d\x8f\xdd\xa9\x3b\x73\x72\x1f\x52\x1d\xba\x79\x43\x1d\x6f\x78\x07\x53\x7a\x98\xd9\x0b\x99\x33\xaa\x2a\x7f\xf5\xe6\xcd\xdb\x67\x3f\xe5\x65\xbd\xa6\x99\xc9\x6f\xaa\x7e\x93\x1f\xfa\xeb\xff\x77\xbe\x2e\xeb\xb2\x2d\xb6\xf3\x65\xc5\x93\xd2\x12\x5e\xe5\x34\x4b\x32\xc4\x59\xd6\x75\x5b\x22\x30\x2b\x6e\xe5\xf2\xf2\x75\x7e\x4e\x3f\xa9\x33\x54\x96\x3b\xd2\x6f\xb2\xee\x6f\x5b\x9e\xa8\xd0\xe0\xd5\xa6\xcc\x81\xb3\x00\x6a\xae\x87\xf3\x92\xaf\xb4\xaf\xb3\xfc\xbb\x45\xfb\x83\xeb\x5f\xb1\xe8\x9a\xed\xa1\xd7\x92\x37\x9b\xb2\xc6\x42\x11\x2a\xb5\x3d\x51\x2b\xa3\xfd\xb3\xac\x6c\xdb\x39\xd1\xcd\xfe\x96\x97\x47\xfb\x72\xac\x15\xa9\x8c\x50\xb9\x6e\x7a\x5a\xfe\x1c\xe5\xa4\x8a\xaa\xfe\x58\x6c\xab\x15\x2d\x52\x9c\xc8\xb4\x2c\x12\x57\x0d\xad\x37\x97\x26\x8c\x6e\x6e\x30\x45\xb4\xc1\x88\xac\xe7\x0f\x66\x0f\x40\x67\x1f\x3c\x7d\x30\xcb\xea\x66\x2e\x44\x80\x29\xf2\xaa\xea\x8a\x05\x51\x67\x39\x2d\x5a\x23\x76\x7f\x65\xbc\x93\xae\x28\x44\x9e\x40\xf0\x9a\xf0\x09\x04\xc2\xcf\x48\x59\x10\x99\x06\x2d\x51\x2a\xe2\xc7\x6e\x24\x27\xe0\x85\x50\x9d\x90\x30\x1a\x73\x66\x0b\x6d\x58\x79\xba\xdf\x6f\xab\xa5\x34\xfd\x42\xf2\x22\x82\xf2\x79\xac\x93\xe2\xe1\x80\x60\x96\xe7\xd0\x8c\x7a\xcd\x54\x29\x4f\xc8\x3b\xca\x6f\x4a\xda\x71\x9b\xc3\x5a\xce\xa4\x6d\x73\x58\x7d\x85\xc3\xc1\x56\x2e\x92\xe0\xfc\x5d\x43\x1d\x06\x56\x05\x80\xd8\xc4\x29\x11\x14\x66\x01\xda\x72\xd7\xf4\x3c\x71\x5a\x8c\xc9\xdc\x4d\x45\x99\x34\xd2\xae\xf8\x48\x87\x5b\xdf\xc8\x56\x5e\xd1\x56\x5d\x72\xc5\xb3\x8c\xc8\xca\x5c\xb7\x13\xd1\x1f\xd9\x52\x96\x96\xe2\x2e\xa0\x76\x07\xda\x85\x1b\xaa\x8c\x27\x9e\xf9\x10\xaa\x72\xaa\x9f\x18\x12\xd5\x03\xea\x40\x3b\xbe\xa1\x33\x93\x17\xfa\x19\x7e\xe8\xb7\xaf\x9f\x7a\x55\x5c\x5f\x53\xaf\x3a\xda\x4d\x2f\xf3\xe5\xb6\xa1\xad\xf8\xcb\xbb\xd7\x1d\x6f\xb4\xcd\x7c\xdf\xb4\xe0\x3f\x28\xeb\x82\x7e\x86\x34\x37\xd1\x0c\x51\x1f\x76\x0b\xfa\xba\xd9\x54\xcb\x8d\x4c\x3b\x97\xe0\xfd\x41\xa9\xdLine truncated
|
||||
var _confLocaleLocale_enUsIni = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xac\xbd\xfb\x72\xdb\x48\x92\x2f\xfc\x3f\x9e\x02\xed\x09\x87\xed\x08\x99\x1d\x3d\xb3\xdf\x25\x3a\xfa\xf2\xa9\xe5\xf6\x65\xd7\xb2\xb5\x96\x7a\xe6\x9b\xd3\xe1\x60\x83\x24\x44\x62\x4d\x02\x1c\x00\xb4\xac\x99\x98\x37\x38\x0f\x70\x9e\xef\x3c\xc9\xc9\xfc\x65\x66\x55\x16\x00\x4a\x76\xcf\xfa\x0f\x8b\xa8\xca\xba\x67\x65\xe5\xad\xb2\x8a\xfd\x7e\xbe\x2a\xbb\x65\xfe\x7d\x7e\x9a\xef\x8b\xaa\xde\x96\x5d\x97\x77\xe5\xf6\xfa\xe9\xa6\xe9\xfa\x72\x95\xbf\xa8\x7a\xfa\x6e\x3f\x56\xcb\x32\xcb\x36\xcd\xae\x24\xd0\x97\xf4\x27\x5b\x15\xdd\x66\xd1\x14\xed\x8a\x12\x9e\xd9\xef\xac\xfc\xb4\xdf\x36\x2d\x03\xfd\x2c\xbf\xb2\x4d\xb9\xdd\x73\x19\xfa\x93\x75\xd5\xba\x9e\x57\x35\x7d\x5e\xd2\xaf\xfc\x55\x2d\x29\xcd\xa1\xb7\xa4\xb7\x87\x5e\xd2\x0e\x7b\x4b\xfa\x65\x9f\xb5\xe5\xba\xa2\xde\xb4\x94\xf4\x4e\x7f\x66\x37\xe5\xa2\xab\x7a\x6e\xe9\x2f\xf2\x2b\xfb\x58\xb6\x5d\xd5\x70\xed\x7f\x96\x5f\xd9\xbe\x58\x33\xc0\x05\xfd\xc9\xfa\x72\xb7\xdf\x16\x28\x70\xa5\x3f\xb3\x6d\x51\xaf\x0f\x02\xf3\x5a\x7f\x66\xcb\xb6\xa4\xac\x79\x5d\xde\x50\xea\x19\x3e\x66\xb3\x59\x76\xa0\x49\x98\xef\xdb\xe6\xba\xda\x96\xf3\xa2\x5e\xcd\x77\x32\xcc\x5f\x28\x3d\xd7\xf4\x9c\xd2\x73\x4e\xc7\x10\xca\x15\x0d\x75\x5e\x74\x3a\x0e\x9a\x4b\x1a\x79\xd1\x65\xa8\xaa\x2e\x76\x56\x9a\x7f\x66\xe5\xae\xa8\xb6\x3c\x6b\xfc\x97\xfa\xdd\x75\x37\x0d\xa6\xf6\x42\x7f\xd2\x1c\xcc\xfb\xdb\x7d\x89\x29\x78\x7a\x45\xbf\xb2\x65\xb1\xef\x97\x9b\x82\xbb\x29\xbf\x32\x02\xda\x37\x34\x17\x4d\x7b\x0b\x38\xfb\xc8\x9a\x76\x5d\xd4\xd5\xdf\x8b\x5e\xe6\xe7\xad\xfb\xcc\x76\x55\xdb\x36\x3c\xb5\xe7\xf8\x91\xd1\xc8\xe7\x5c\x0f\xa5\xbc\xa1\x49\x70\xb5\x70\xce\xae\x5a\xb7\x32\x8b\x9c\x79\x8e\x2f\xae\x45\xf2\xb4\x26\xc9\x0a\xb5\x5d\x37\xed\x07\x4d\x7d\xce\x3f\x07\x55\x52\xe7\x34\x37\xed\x57\x51\xd3\x7a\x68\xee\x39\x3e\x12\x80\x2e\x2b\x56\x3b\x9a\xe1\x7d\x51\x97\x3c\x75\xa7\xfc\x45\xf3\x45\x5f\x59\xb1\x5c\x36\x87\xba\x9f\x77\x65\xdf\x57\xf5\x9a\xd7\xe0\x54\x92\xf2\x4b\x4d\xca\x5c\x5e\x48\xbb\x6d\x0e\x61\x95\x29\xfd\xaf\xf4\x99\x5f\xc8\xa7\xe4\xb9\x42\xc8\x0c\x25\xa9\xc9\xbe\xfa\x58\xf5\x55\x29\x8d\xd9\x47\xb6\x3f\x6c\xb7\x34\x9f\x7f\x3b\x94\x5d\xcf\x59\x17\xf4\x4d\x33\x20\xdf\x59\xd5\x75\x07\x94\x78\x85\x1f\x19\x2d\x6a\xbd\xc4\x70\xce\xf0\x23\xcb\x7e\xad\xea\xae\x2f\xb6\xdb\xf7\x99\xfe\x60\x60\xf9\x25\xf3\xd4\x57\x3d\x3a\xab\x89\xf9\x65\x5f\xee\x3b\x9e\xe8\xfc\x79\xd5\x76\xfd\xd3\xbe\x22\x54\x7b\x77\xa8\xb3\x55\xb3\xfc\x40\x48\xcc\x1b\x12\x5b\xe9\xd5\x75\x4e\x63\x7a\x44\x68\xdc\x1e\xea\x9a\x46\x91\xbf\x68\x68\x64\xd4\x4c\xb5\x2a\xf3\x67\x80\x3e\xc9\xf7\xdb\xb2\xe8\x08\xa4\x2c\x56\xf9\x77\x45\xde\x17\xed\xba\xec\xbf\x7f\x30\x5f\xd0\xe6\xf9\xf0\x20\xdf\xb4\xe5\xf5\xf7\x0f\x1e\x76\x0f\x7e\x78\x71\xa0\x62\xdb\xaa\x2e\xbb\xef\xbe\x2e\x7e\xc8\x97\x05\xe5\xd0\x58\x6f\xf3\x45\x79\xcd\x7b\x85\xda\xca\x09\x49\xeb\x35\xef\x93\xdb\x7e\xc3\x0d\xd2\x82\xd1\x8f\x2e\xe7\x8d\xfa\x55\xc6\xb3\x44\x1b\x79\xbe\x5a\x18\x51\x42\x87\x90\xdc\xd2\x2c\x9d\xdf\x5e\xfe\xe7\xeb\x93\xfc\x82\x28\xd3\xba\x2d\xf1\x9b\xfe\xa3\x12\x7f\xca\x69\xb4\x57\xd5\xb3\x9f\x66\x19\x95\xb5\x09\x79\x56\xf4\xc5\x82\xfb\x1e\x16\x89\x33\x65\x0f\x85\x3c\xec\x24\xa6\x75\xa0\x6b\x5d\x8f\xdd\xa9\x3b\x73\x72\x1f\x52\x1d\xba\x79\x43\x1d\x6f\x78\x07\x53\x7a\x98\xd9\x0b\x99\x33\xaa\x2a\x7f\xf5\xe6\xcd\xdb\x67\x3f\xe5\x65\xbd\xa6\x99\xc9\x6f\xaa\x7e\x93\x1f\xfa\xeb\xff\x77\xbe\x2e\xeb\xb2\x2d\xb6\xf3\x65\xc5\x93\xd2\x12\x5e\xe5\x34\x4b\x32\xc4\x59\xd6\x75\x5b\x22\x30\x2b\x6e\xe5\xf2\xf2\x75\x7e\x4e\x3f\xa9\x33\x54\x96\x3b\xd2\x6f\xb2\xee\x6f\x5b\x9e\xa8\xd0\xe0\xd5\xa6\xcc\x81\xb3\x00\x6a\xae\x87\xf3\x92\xaf\xb4\xaf\xb3\xfc\xbb\x45\xfb\x83\xeb\x5f\xb1\xe8\x9a\xed\xa1\xd7\x92\x37\x9b\xb2\xc6\x42\x11\x2a\xb5\x3d\x51\x2b\xa3\xfd\xb3\xac\x6c\xdb\x39\xd1\xcd\xfe\x96\x97\x47\xfb\x72\xac\x15\xa9\x8c\x50\xb9\x6e\x7a\x5a\xfe\x1c\xe5\xa4\x8a\xaa\xfe\x58\x6c\xab\x15\x2d\x52\x9c\xc8\xb4\x2c\x12\x57\x0d\xad\x37\x97\x26\x8c\x6e\x6e\x30\x45\xb4\xc1\x88\xac\xe7\x0f\x66\x0f\x40\x67\x1f\x3c\x7d\x30\xcb\xea\x66\x2e\x44\x80\x29\xf2\xaa\xea\x8a\x05\x51\x67\x39\x2d\x5a\x23\x76\x7f\x65\xbc\x93\xae\x28\x44\x9e\x40\xf0\x9a\xf0\x09\x04\xc2\xcf\x48\x59\x10\x99\x06\x2d\x51\x2a\xe2\xc7\x6e\x24\x27\xe0\x85\x50\x9d\x90\x30\x1a\x73\x66\x0b\x6d\x58\x79\xba\xdf\x6f\xab\xa5\x34\xfd\x42\xf2\x22\x82\xf2\x79\xac\x93\xe2\xe1\x80\x60\x96\xe7\xd0\x8c\x7a\xcd\x54\x29\x4f\xc8\x3b\xca\x6f\x4a\xda\x71\x9b\xc3\x5a\xce\xa4\x6d\x73\x58\x7d\x85\xc3\xc1\x56\x2e\x92\xe0\xfc\x5d\x43\x1d\x06\x56\x05\x80\xd8\xc4\x29\x11\x14\x66\x01\xda\x72\xd7\xf4\x3c\x71\x5a\x8c\xc9\xdc\x4d\x45\x99\x34\xd2\xae\xf8\x48\x87\x5b\xdf\xc8\x56\x5e\xd1\x56\x5d\x72\xc5\xb3\x8c\xc8\xca\x5c\xb7\x13\xd1\x1f\xd9\x52\x96\x96\xe2\x2e\xa0\x76\x07\xda\x85\x1b\xaa\x8c\x27\x9e\xf9\x10\xaa\x72\xaa\x9f\x18\x12\xd5\x03\xea\x40\x3b\xbe\xa1\x33\x93\x17\xfa\x19\x7e\xe8\xb7\xaf\x9f\x7a\x55\x5c\x5f\x53\xaf\x3a\xda\x4d\x2f\xf3\xe5\xb6\xa1\xad\xf8\xcb\xbb\xd7\x1d\x6f\xb4\xcd\x7c\xdf\xb4\xe0\x3f\x28\xeb\x82\x7e\x86\x34\x37\xd1\x0c\x51\x1f\x76\x0b\xfa\xba\xd9\x54\xcb\x8d\x4c\x3b\x97\xe0\xfd\x41\xa9\xdLine truncated
|
||||
|
||||
func confLocaleLocale_enUsIniBytes() ([]byte, error) {
|
||||
return bindataRead(
|
||||
@@ -4361,7 +4361,7 @@ func confLocaleLocale_enUsIni() (*asset, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "conf/locale/locale_en-US.ini", size: 55467, mode: os.FileMode(420), modTime: time.Unix(1472332431, 0)}
|
||||
info := bindataFileInfo{name: "conf/locale/locale_en-US.ini", size: 55565, mode: os.FileMode(420), modTime: time.Unix(1472373004, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
+10
-10
@@ -737,6 +737,16 @@ function setCodeMirror($editArea) {
|
||||
}
|
||||
|
||||
function initEditor() {
|
||||
$('.js-quick-pull-choice-option').change(function () {
|
||||
if ($(this).val() == 'commit-to-new-branch') {
|
||||
$('.quick-pull-branch-name').show();
|
||||
$('.quick-pull-branch-name input').prop('required',true);
|
||||
} else {
|
||||
$('.quick-pull-branch-name').hide();
|
||||
$('.quick-pull-branch-name input').prop('required',false);
|
||||
}
|
||||
});
|
||||
|
||||
var $editFilename = $("#file-name");
|
||||
$editFilename.keyup(function (e) {
|
||||
var $section = $('.breadcrumb span.section');
|
||||
@@ -841,16 +851,6 @@ function initEditor() {
|
||||
codeMirrorEditor.setOption("lineWrapping", false);
|
||||
}
|
||||
}).trigger('keyup');
|
||||
|
||||
|
||||
$('.js-quick-pull-choice-option').change(function () {
|
||||
if ($(this).val() == 'commit-to-new-branch') {
|
||||
$('.quick-pull-branch-name').show();
|
||||
} else {
|
||||
$('.quick-pull-branch-name').hide();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function initOrganization() {
|
||||
|
||||
+75
-35
@@ -20,9 +20,10 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
EDIT base.TplName = "repo/editor/edit"
|
||||
DIFF_PREVIEW base.TplName = "repo/editor/diff_preview"
|
||||
DIFF_PREVIEW_NEW base.TplName = "repo/editor/diff_preview_new"
|
||||
EDIT_FILE base.TplName = "repo/editor/edit"
|
||||
EDIT_DIFF_PREVIEW base.TplName = "repo/editor/diff_preview"
|
||||
NEW_DIFF_PREVIEW base.TplName = "repo/editor/diff_preview_new"
|
||||
DELETE_FILE base.TplName = "repo/editor/delete"
|
||||
)
|
||||
|
||||
func editFile(ctx *context.Context, isNewFile bool) {
|
||||
@@ -104,7 +105,7 @@ func editFile(ctx *context.Context, isNewFile bool) {
|
||||
ctx.Data["LineWrapExtensions"] = strings.Join(setting.Repository.Editor.LineWrapExtensions, ",")
|
||||
ctx.Data["PreviewableFileModes"] = strings.Join(setting.Repository.Editor.PreviewableFileModes, ",")
|
||||
|
||||
ctx.HTML(200, EDIT)
|
||||
ctx.HTML(200, EDIT_FILE)
|
||||
}
|
||||
|
||||
func EditFile(ctx *context.Context) {
|
||||
@@ -125,12 +126,10 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
|
||||
branchName := oldBranchName
|
||||
branchLink := ctx.Repo.RepoLink + "/src/" + branchName
|
||||
oldTreePath := ctx.Repo.TreePath
|
||||
content := form.Content
|
||||
commitChoice := form.CommitChoice
|
||||
lastCommit := form.LastCommit
|
||||
form.LastCommit = ctx.Repo.Commit.ID.String()
|
||||
|
||||
if commitChoice == "commit-to-new-branch" {
|
||||
if form.CommitChoice == "commit-to-new-branch" {
|
||||
branchName = form.NewBranchName
|
||||
}
|
||||
|
||||
@@ -144,10 +143,10 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
|
||||
ctx.Data["TreePath"] = form.TreePath
|
||||
ctx.Data["TreeNames"] = treeNames
|
||||
ctx.Data["BranchLink"] = branchLink
|
||||
ctx.Data["FileContent"] = content
|
||||
ctx.Data["FileContent"] = form.Content
|
||||
ctx.Data["commit_summary"] = form.CommitSummary
|
||||
ctx.Data["commit_message"] = form.CommitMessage
|
||||
ctx.Data["commit_choice"] = commitChoice
|
||||
ctx.Data["commit_choice"] = form.CommitChoice
|
||||
ctx.Data["new_branch_name"] = branchName
|
||||
ctx.Data["last_commit"] = form.LastCommit
|
||||
ctx.Data["MarkdownFileExts"] = strings.Join(setting.Markdown.FileExtensions, ",")
|
||||
@@ -155,20 +154,20 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
|
||||
ctx.Data["PreviewableFileModes"] = strings.Join(setting.Repository.Editor.PreviewableFileModes, ",")
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.HTML(200, EDIT)
|
||||
ctx.HTML(200, EDIT_FILE)
|
||||
return
|
||||
}
|
||||
|
||||
if len(form.TreePath) == 0 {
|
||||
ctx.Data["Err_TreePath"] = true
|
||||
ctx.RenderWithErr(ctx.Tr("repo.editor.filename_cannot_be_empty"), EDIT, &form)
|
||||
ctx.RenderWithErr(ctx.Tr("repo.editor.filename_cannot_be_empty"), EDIT_FILE, &form)
|
||||
return
|
||||
}
|
||||
|
||||
if oldBranchName != branchName {
|
||||
if _, err := ctx.Repo.Repository.GetBranch(branchName); err == nil {
|
||||
ctx.Data["Err_NewBranchName"] = true
|
||||
ctx.RenderWithErr(ctx.Tr("repo.editor.branch_already_exists", branchName), EDIT, &form)
|
||||
ctx.RenderWithErr(ctx.Tr("repo.editor.branch_already_exists", branchName), EDIT_FILE, &form)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -189,13 +188,13 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
|
||||
if index != len(treeNames)-1 {
|
||||
if !entry.IsDir() {
|
||||
ctx.Data["Err_TreePath"] = true
|
||||
ctx.RenderWithErr(ctx.Tr("repo.editor.directory_is_a_file", part), EDIT, &form)
|
||||
ctx.RenderWithErr(ctx.Tr("repo.editor.directory_is_a_file", part), EDIT_FILE, &form)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if entry.IsDir() {
|
||||
ctx.Data["Err_TreePath"] = true
|
||||
ctx.RenderWithErr(ctx.Tr("repo.editor.filename_is_a_directory", part), EDIT, &form)
|
||||
ctx.RenderWithErr(ctx.Tr("repo.editor.filename_is_a_directory", part), EDIT_FILE, &form)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -206,7 +205,7 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
|
||||
if err != nil {
|
||||
if git.IsErrNotExist(err) {
|
||||
ctx.Data["Err_TreePath"] = true
|
||||
ctx.RenderWithErr(ctx.Tr("repo.editor.file_editing_no_longer_exists", oldTreePath), EDIT, &form)
|
||||
ctx.RenderWithErr(ctx.Tr("repo.editor.file_editing_no_longer_exists", oldTreePath), EDIT_FILE, &form)
|
||||
} else {
|
||||
ctx.Handle(500, "GetTreeEntryByPath", err)
|
||||
}
|
||||
@@ -221,7 +220,7 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
|
||||
|
||||
for _, file := range files {
|
||||
if file == form.TreePath {
|
||||
ctx.RenderWithErr(ctx.Tr("repo.editor.file_changed_while_editing", ctx.Repo.RepoLink+"/compare/"+lastCommit+"..."+ctx.Repo.CommitID), EDIT, &form)
|
||||
ctx.RenderWithErr(ctx.Tr("repo.editor.file_changed_while_editing", ctx.Repo.RepoLink+"/compare/"+lastCommit+"..."+ctx.Repo.CommitID), EDIT_FILE, &form)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -239,15 +238,13 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
|
||||
}
|
||||
if entry != nil {
|
||||
ctx.Data["Err_TreePath"] = true
|
||||
ctx.RenderWithErr(ctx.Tr("repo.editor.file_already_exists", form.TreePath), EDIT, &form)
|
||||
ctx.RenderWithErr(ctx.Tr("repo.editor.file_already_exists", form.TreePath), EDIT_FILE, &form)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
var message string
|
||||
if len(form.CommitSummary) > 0 {
|
||||
message = strings.TrimSpace(form.CommitSummary)
|
||||
} else {
|
||||
message := strings.TrimSpace(form.CommitSummary)
|
||||
if len(message) == 0 {
|
||||
if isNewFile {
|
||||
message = ctx.Tr("repo.editor.add", form.TreePath)
|
||||
} else {
|
||||
@@ -267,11 +264,11 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
|
||||
OldTreeName: oldTreePath,
|
||||
NewTreeName: form.TreePath,
|
||||
Message: message,
|
||||
Content: content,
|
||||
Content: form.Content,
|
||||
IsNewFile: isNewFile,
|
||||
}); err != nil {
|
||||
ctx.Data["Err_TreePath"] = true
|
||||
ctx.RenderWithErr(ctx.Tr("repo.editor.failed_to_update_file", err), EDIT, &form)
|
||||
ctx.RenderWithErr(ctx.Tr("repo.editor.failed_to_update_file", err), EDIT_FILE, &form)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -287,14 +284,14 @@ func NewFilePost(ctx *context.Context, form auth.EditRepoFileForm) {
|
||||
}
|
||||
|
||||
func DiffPreviewPost(ctx *context.Context, form auth.EditPreviewDiffForm) {
|
||||
treeName := ctx.Repo.TreePath
|
||||
treePath := ctx.Repo.TreePath
|
||||
content := form.Content
|
||||
|
||||
entry, err := ctx.Repo.Commit.GetTreeEntryByPath(treeName)
|
||||
entry, err := ctx.Repo.Commit.GetTreeEntryByPath(treePath)
|
||||
if err != nil {
|
||||
if git.IsErrNotExist(err) {
|
||||
ctx.Data["FileContent"] = content
|
||||
ctx.HTML(200, DIFF_PREVIEW_NEW)
|
||||
ctx.HTML(200, NEW_DIFF_PREVIEW)
|
||||
} else {
|
||||
ctx.Error(500, "GetTreeEntryByPath: "+err.Error())
|
||||
}
|
||||
@@ -305,7 +302,7 @@ func DiffPreviewPost(ctx *context.Context, form auth.EditPreviewDiffForm) {
|
||||
return
|
||||
}
|
||||
|
||||
diff, err := ctx.Repo.Repository.GetDiffPreview(ctx.Repo.BranchName, treeName, content)
|
||||
diff, err := ctx.Repo.Repository.GetDiffPreview(ctx.Repo.BranchName, treePath, content)
|
||||
if err != nil {
|
||||
ctx.Error(500, "GetDiffPreview: "+err.Error())
|
||||
return
|
||||
@@ -317,28 +314,71 @@ func DiffPreviewPost(ctx *context.Context, form auth.EditPreviewDiffForm) {
|
||||
}
|
||||
ctx.Data["File"] = diff.Files[0]
|
||||
|
||||
ctx.HTML(200, DIFF_PREVIEW)
|
||||
ctx.HTML(200, EDIT_DIFF_PREVIEW)
|
||||
}
|
||||
|
||||
func DeleteFile(ctx *context.Context) {
|
||||
ctx.Data["PageIsDelete"] = true
|
||||
ctx.Data["BranchLink"] = ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchName
|
||||
ctx.Data["TreePath"] = ctx.Repo.TreePath
|
||||
ctx.Data["commit_summary"] = ""
|
||||
ctx.Data["commit_message"] = ""
|
||||
ctx.Data["commit_choice"] = "direct"
|
||||
ctx.Data["new_branch_name"] = ""
|
||||
ctx.HTML(200, DELETE_FILE)
|
||||
}
|
||||
|
||||
func DeleteFilePost(ctx *context.Context, form auth.DeleteRepoFileForm) {
|
||||
branchName := ctx.Repo.BranchName
|
||||
treeName := ctx.Repo.TreePath
|
||||
ctx.Data["PageIsDelete"] = true
|
||||
ctx.Data["BranchLink"] = ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchName
|
||||
ctx.Data["TreePath"] = ctx.Repo.TreePath
|
||||
|
||||
oldBranchName := ctx.Repo.BranchName
|
||||
branchName := oldBranchName
|
||||
treePath := ctx.Repo.TreePath
|
||||
|
||||
if form.CommitChoice == "commit-to-new-branch" {
|
||||
branchName = form.NewBranchName
|
||||
}
|
||||
ctx.Data["commit_summary"] = form.CommitSummary
|
||||
ctx.Data["commit_message"] = form.CommitMessage
|
||||
ctx.Data["commit_choice"] = form.CommitChoice
|
||||
ctx.Data["new_branch_name"] = branchName
|
||||
|
||||
if ctx.HasError() {
|
||||
ctx.Redirect(ctx.Repo.RepoLink + "/src/" + branchName + "/" + treeName)
|
||||
ctx.HTML(200, DELETE_FILE)
|
||||
return
|
||||
}
|
||||
|
||||
if oldBranchName != branchName {
|
||||
if _, err := ctx.Repo.Repository.GetBranch(branchName); err == nil {
|
||||
ctx.Data["Err_NewBranchName"] = true
|
||||
ctx.RenderWithErr(ctx.Tr("repo.editor.branch_already_exists", branchName), DELETE_FILE, &form)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
message := strings.TrimSpace(form.CommitSummary)
|
||||
if len(message) == 0 {
|
||||
message = ctx.Tr("repo.editor.delete", treePath)
|
||||
}
|
||||
|
||||
form.CommitMessage = strings.TrimSpace(form.CommitMessage)
|
||||
if len(form.CommitMessage) > 0 {
|
||||
message += "\n\n" + form.CommitMessage
|
||||
}
|
||||
|
||||
if err := ctx.Repo.Repository.DeleteRepoFile(ctx.User, models.DeleteRepoFileOptions{
|
||||
LastCommitID: ctx.Repo.CommitID,
|
||||
Branch: branchName,
|
||||
TreePath: treeName,
|
||||
Message: form.CommitSummary,
|
||||
OldBranch: oldBranchName,
|
||||
NewBranch: branchName,
|
||||
TreePath: treePath,
|
||||
Message: message,
|
||||
}); err != nil {
|
||||
ctx.Handle(500, "DeleteRepoFile", err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Flash.Success(ctx.Tr("repo.editor.file_delete_success", treeName))
|
||||
ctx.Flash.Success(ctx.Tr("repo.editor.file_delete_success", treePath))
|
||||
ctx.Redirect(ctx.Repo.RepoLink + "/src/" + branchName)
|
||||
}
|
||||
+12
-14
@@ -48,7 +48,6 @@ func Home(ctx *context.Context) {
|
||||
branchLink := ctx.Repo.RepoLink + "/src/" + branchName
|
||||
treeLink := branchLink
|
||||
rawLink := ctx.Repo.RepoLink + "/raw/" + branchName
|
||||
// newFileLink := ctx.Repo.RepoLink + "/_new/" + branchName
|
||||
// uploadFileLink := ctx.Repo.RepoLink + "/upload/" + branchName
|
||||
|
||||
treePath := ctx.Repo.TreePath
|
||||
@@ -155,13 +154,11 @@ func Home(ctx *context.Context) {
|
||||
|
||||
if ctx.Repo.IsWriter() && ctx.Repo.IsViewBranch {
|
||||
ctx.Data["CanDeleteFile"] = true
|
||||
ctx.Data["FileDeleteLinkTooltip"] = ctx.Tr("repo.delete_this_file")
|
||||
} else {
|
||||
if !ctx.Repo.IsViewBranch {
|
||||
ctx.Data["FileDeleteLinkTooltip"] = ctx.Tr("repo.must_be_on_branch")
|
||||
} else if !ctx.Repo.IsWriter() {
|
||||
ctx.Data["FileDeleteLinkTooltip"] = ctx.Tr("repo.must_be_writer")
|
||||
}
|
||||
ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.delete_this_file")
|
||||
} else if !ctx.Repo.IsViewBranch {
|
||||
ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.must_be_on_a_branch")
|
||||
} else if !ctx.Repo.IsWriter() {
|
||||
ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.must_have_write_access")
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -240,12 +237,13 @@ func Home(ctx *context.Context) {
|
||||
}
|
||||
ctx.Data["LastCommit"] = lastCommit
|
||||
ctx.Data["LastCommitUser"] = models.ValidateCommitWithEmail(lastCommit)
|
||||
// if ctx.Repo.IsWriter() && ctx.Repo.IsViewBranch {
|
||||
// ctx.Data["NewFileLink"] = newFileLink + "/" + treePath
|
||||
// if setting.Repository.Upload.Enabled {
|
||||
// ctx.Data["UploadFileLink"] = uploadFileLink + "/" + treePath
|
||||
// }
|
||||
// }
|
||||
|
||||
if ctx.Repo.IsWriter() && ctx.Repo.IsViewBranch {
|
||||
ctx.Data["CanAddFile"] = true
|
||||
// if setting.Repository.Upload.Enabled {
|
||||
// ctx.Data["UploadFileLink"] = uploadFileLink + "/" + treePath
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
ctx.Data["Username"] = userName
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
0.9.90.0828
|
||||
0.9.91.0828
|
||||
@@ -10,6 +10,6 @@
|
||||
{{end}}
|
||||
{{if .Flash.InfoMsg}}
|
||||
<div class="ui info message">
|
||||
<p>{{.Flash.InfoMsg| Safe}}</p>
|
||||
<p>{{.Flash.InfoMsg | Safe}}</p>
|
||||
</div>
|
||||
{{end}}
|
||||
@@ -1,5 +1,5 @@
|
||||
<div class="fitted item choose reference">
|
||||
<div id="branch-dropdown" class="ui floating filter dropdown" data-no-results="{{.i18n.Tr "repo.pulls.no_results"}}">
|
||||
<div class="ui floating filter dropdown" data-no-results="{{.i18n.Tr "repo.pulls.no_results"}}">
|
||||
<div class="ui basic small button">
|
||||
<span class="text">
|
||||
<i class="octicon octicon-git-branch"></i>
|
||||
@@ -31,12 +31,12 @@
|
||||
</div>
|
||||
<div id="branch-list" class="scrolling menu" {{if .IsViewTag}}style="display: none"{{end}}>
|
||||
{{range .Branches}}
|
||||
<div class="item {{if eq $.BranchName .}}selected{{end}}" data-url="{{$.RepoLink}}/{{if $.PageIsCommits}}commits{{else}}src{{end}}/{{EscapePound .}}{{if $.TreeName}}/{{EscapePound $.TreeName}}{{end}}">{{.}}</div>
|
||||
<div class="item {{if eq $.BranchName .}}selected{{end}}" data-url="{{$.RepoLink}}/{{if $.PageIsCommits}}commits{{else}}src{{end}}/{{EscapePound .}}{{if $.TreePath}}/{{EscapePound $.TreePath}}{{end}}">{{.}}</div>
|
||||
{{end}}
|
||||
</div>
|
||||
<div id="tag-list" class="scrolling menu" {{if not .IsViewTag}}style="display: none"{{end}}>
|
||||
{{range .Tags}}
|
||||
<div class="item {{if eq $.BranchName .}}selected{{end}}" data-url="{{$.RepoLink}}/{{if $.PageIsCommits}}commits{{else}}src{{end}}/{{EscapePound .}}{{if $.TreeName}}/{{EscapePound $.TreeName}}{{end}}">{{.}}</div>
|
||||
<div class="item {{if eq $.BranchName .}}selected{{end}}" data-url="{{$.RepoLink}}/{{if $.PageIsCommits}}commits{{else}}src{{end}}/{{EscapePound .}}{{if $.TreePath}}/{{EscapePound $.TreePath}}{{end}}">{{.}}</div>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -152,21 +152,21 @@
|
||||
|
||||
{{if .IsSplitStyle}}
|
||||
<script>
|
||||
(function() {
|
||||
$('.add-code').each(function() {
|
||||
var prev = $(this).prev();
|
||||
if(prev.is('.del-code') && prev.children().eq(3).text().trim() === '') {
|
||||
while(prev.prev().is('.del-code') && prev.prev().children().eq(3).text().trim() === '') {
|
||||
prev = prev.prev();
|
||||
(function() {
|
||||
$('.add-code').each(function() {
|
||||
var prev = $(this).prev();
|
||||
if(prev.is('.del-code') && prev.children().eq(3).text().trim() === '') {
|
||||
while(prev.prev().is('.del-code') && prev.prev().children().eq(3).text().trim() === '') {
|
||||
prev = prev.prev();
|
||||
}
|
||||
prev.children().eq(3).html($(this).children().eq(3).html());
|
||||
prev.children().eq(2).html($(this).children().eq(2).html());
|
||||
prev.children().eq(3).addClass('add-code');
|
||||
prev.children().eq(2).addClass('add-code');
|
||||
$(this).remove();
|
||||
}
|
||||
prev.children().eq(3).html($(this).children().eq(3).html());
|
||||
prev.children().eq(2).html($(this).children().eq(2).html());
|
||||
prev.children().eq(3).addClass('add-code');
|
||||
prev.children().eq(2).addClass('add-code');
|
||||
$(this).remove();
|
||||
}
|
||||
});
|
||||
}());
|
||||
});
|
||||
}());
|
||||
</script>
|
||||
{{end}}
|
||||
{{end}}
|
||||
@@ -0,0 +1,43 @@
|
||||
<div class="commit-form-wrapper">
|
||||
<img width="48" height="48" class="ui image commit-avatar" src="{{.SignedUser.AvatarLink}}">
|
||||
<div class="commit-form">
|
||||
<h3>{{.i18n.Tr "repo.editor.commit_changes"}}</h3>
|
||||
<div class="field">
|
||||
<input name="commit_summary" placeholder="{{if .PageIsDelete}}{{.i18n.Tr "repo.editor.delete" .TreePath}}{{else if .IsNewFile}}{{.i18n.Tr "repo.editor.add_tmpl" .TreePath}}{{else}}{{.i18n.Tr "repo.editor.update" .TreePath}}{{end}}" value="{{.commit_summary}}" autofocus>
|
||||
</div>
|
||||
<div class="field">
|
||||
<textarea name="commit_message" placeholder="{{.i18n.Tr "repo.editor.commit_message_desc"}}" rows="5">{{.commit_message}}</textarea>
|
||||
</div>
|
||||
<div class="quick-pull-choice js-quick-pull-choice">
|
||||
<div class="field">
|
||||
<div class="ui radio checkbox">
|
||||
<input type="radio" class="js-quick-pull-choice-option" name="commit_choice" value="direct" {{if eq .commit_choice "direct"}}checked{{end}}>
|
||||
<label>
|
||||
<i class="octicon octicon-git-commit" height="16" width="14"></i>
|
||||
{{.i18n.Tr "repo.editor.commit_directly_to_this_branch" .BranchName | Safe}}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui radio checkbox">
|
||||
<input type="radio" class="js-quick-pull-choice-option" name="commit_choice" value="commit-to-new-branch" {{if eq .commit_choice "commit-to-new-branch"}}checked{{end}}>
|
||||
<label>
|
||||
<i class="octicon octicon-git-pull-request" height="16" width="12"></i>
|
||||
{{.i18n.Tr "repo.editor.create_new_branch" | Safe}}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="quick-pull-branch-name {{if not (eq .commit_choice "commit-to-new-branch")}}hide{{end}}">
|
||||
<div class="new-branch-name-input field {{if .Err_NewBranchName}}error{{end}}">
|
||||
<i class="octicon octicon-git-branch" height="16" width="10"></i>
|
||||
<input type="text" name="new_branch_name" value="{{.new_branch_name}}" class="input-contrast mr-2 js-quick-pull-new-branch-name" placeholder="{{.i18n.Tr "repo.editor.new_branch_name_desc"}}" {{if eq .commit_choice "commit-to-new-branch"}}required{{end}}>
|
||||
<span class="text-muted js-quick-pull-normalization-info"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="ui green button">
|
||||
{{.i18n.Tr "repo.editor.commit_changes"}}
|
||||
</button>
|
||||
<a class="ui button red" href="{{EscapePound $.BranchLink}}/{{EscapePound .TreePath}}">{{.i18n.Tr "repo.editor.cancel"}}</a>
|
||||
</div>
|
||||
@@ -0,0 +1,12 @@
|
||||
{{template "base/head" .}}
|
||||
<div class="repository file editor delete">
|
||||
{{template "repo/header" .}}
|
||||
<div class="ui container">
|
||||
{{template "base/alert" .}}
|
||||
<form class="ui form" method="post">
|
||||
{{.CsrfTokenHtml}}
|
||||
{{template "repo/editor/commit_form" .}}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{{template "base/footer" .}}
|
||||
@@ -50,49 +50,7 @@
|
||||
{{.i18n.Tr "repo.release.loading"}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="commit-form-wrapper">
|
||||
<img width="48" height="48" class="ui image commit-avatar" src="{{.SignedUser.AvatarLink}}">
|
||||
<div class="commit-form">
|
||||
<h3>{{.i18n.Tr "repo.commit_changes"}}</h3>
|
||||
<div class="field">
|
||||
<input name="commit_summary" placeholder="{{if .IsNewFile}}{{.i18n.Tr "repo.add"}} '{{.TreePath}}/<filename>'{{else}}{{.i18n.Tr "repo.update"}} '{{.TreePath}}'{{end}}" value="{{.commit_summary}}">
|
||||
</div>
|
||||
<div class="field">
|
||||
<textarea name="commit_message" placeholder="{{.i18n.Tr "repo.default_commit_message"}}" rows="5">{{.commit_message}}</textarea>
|
||||
</div>
|
||||
<div class="quick-pull-choice js-quick-pull-choice">
|
||||
<div class="field">
|
||||
<div class="ui radio checkbox">
|
||||
<input type="radio" class="js-quick-pull-choice-option" name="commit_choice" value="direct" {{if eq .commit_choice "direct"}}checked{{end}}>
|
||||
<label>
|
||||
<i class="octicon octicon-git-commit" height="16" width="14"></i>
|
||||
{{.i18n.Tr "repo.editor.commit_directly_to_this_branch" .BranchName | Safe}}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui radio checkbox">
|
||||
<input type="radio" class="js-quick-pull-choice-option" name="commit_choice" value="commit-to-new-branch" {{if eq .commit_choice "commit-to-new-branch"}}checked{{end}}>
|
||||
<label>
|
||||
<i class="octicon octicon-git-pull-request" height="16" width="12"></i>
|
||||
{{.i18n.Tr "repo.editor.create_new_branch" | Safe}}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="quick-pull-branch-name {{if not (eq .commit_choice "commit-to-new-branch")}}hide{{end}}">
|
||||
<div class="new-branch-name-input{{if .Err_NewBranchName}} error{{end}}">
|
||||
<i class="octicon octicon-git-branch" height="16" width="10"></i>
|
||||
<input type="text" name="new_branch_name" value="{{.new_branch_name}}" class="form-control input-contrast mr-2 js-quick-pull-new-branch-name" placeholder="New branch name…">
|
||||
<span class="text-muted js-quick-pull-normalization-info"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="ui green button">
|
||||
{{.i18n.Tr "repo.commit_changes"}}
|
||||
</button>
|
||||
<a class="ui button red" href="{{EscapePound $.BranchLink}}/{{EscapePound .TreePath}}">{{.i18n.Tr "repo.cancel"}}</a>
|
||||
</div>
|
||||
{{template "repo/editor/commit_form" .}}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -34,9 +34,9 @@
|
||||
</div>
|
||||
<div class="right fitted item">
|
||||
<div id="file-buttons" class="ui tiny buttons">
|
||||
{{if .NewFileLink}}
|
||||
<a href="{{EscapePound .NewFileLink}}" class="ui button">
|
||||
{{.i18n.Tr "repo.new_file"}}
|
||||
{{if .CanAddFile}}
|
||||
<a href="{{.RepoLink}}/_new/{{EscapePound .BranchName}}/{{EscapePound .TreePath}}" class="ui button">
|
||||
{{.i18n.Tr "repo.editor.new_file"}}
|
||||
</a>
|
||||
{{end}}
|
||||
{{if .UploadFileLink}}
|
||||
|
||||
@@ -21,18 +21,14 @@
|
||||
<a class="ui button" href="{{EscapePound .FileLink}}">{{.i18n.Tr "repo.file_raw"}}</a>
|
||||
</div>
|
||||
{{if .CanEditFile}}
|
||||
<a href="{{.RepoLink}}/_edit/{{EscapePound .BranchName}}/{{EscapePound .TreePath}}"><i class="poping up octicon octicon-pencil btn-octicon" data-content="{{.EditFileTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i></a>
|
||||
<a href="{{.RepoLink}}/_edit/{{EscapePound .BranchName}}/{{EscapePound .TreePath}}"><i class="octicon octicon-pencil btn-octicon poping up" data-content="{{.EditFileTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i></a>
|
||||
{{else}}
|
||||
<i class="octicon btn-octicon octicon-pencil poping up disabled" data-content="{{.EditFileTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i>
|
||||
<i class="octicon octicon-pencil btn-octicon poping up disabled" data-content="{{.EditFileTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i>
|
||||
{{end}}
|
||||
{{if .CanDeleteFile}}
|
||||
<form id="delete-file-form" class="ui form inline-form" action="{{.RepoLink}}/_delete/{{EscapePound .BranchName}}/{{.TreePath}}" method="post">
|
||||
{{.CsrfTokenHtml}}
|
||||
<button onclick="submitDeleteForm()" class="octicon octicon-trashcan btn-octicon btn-octicon-danger poping up" type="button" data-content="{{.FileDeleteLinkTooltip}}" data-position="bottom center" data-variation="tiny inverted"></button>
|
||||
<input type="hidden" id="delete-message" name="commit_message" value="">
|
||||
</form>
|
||||
<a href="{{.RepoLink}}/_delete/{{EscapePound .BranchName}}/{{EscapePound .TreePath}}"><i class="octicon octicon-trashcan btn-octicon btn-octicon-danger poping up" data-content="{{.DeleteFileTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i></a>
|
||||
{{else}}
|
||||
<i class="octicon btn-octicon octicon-trashcan poping up disabled" data-content="{{.FileDeleteLinkTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i>
|
||||
<i class="octicon octicon-trashcan btn-octicon poping up disabled" data-content="{{.DeleteFileTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i>
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
Reference in new issue
Block a user