mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-04 05:18:25 +00:00 
			
		
		
		
	Web editor: improve delete file process
This commit is contained in:
		@@ -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  |
 | 
					| Web | UI  | Preview  |
 | 
				
			||||||
|:-------------:|:-------:|:-------:|
 | 
					|:-------------:|:-------:|:-------:|
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -506,7 +506,8 @@ func runWeb(ctx *cli.Context) error {
 | 
				
			|||||||
			m.Post("/_preview/*", bindIgnErr(auth.EditPreviewDiffForm{}), repo.DiffPreviewPost)
 | 
								m.Post("/_preview/*", bindIgnErr(auth.EditPreviewDiffForm{}), repo.DiffPreviewPost)
 | 
				
			||||||
			m.Combo("/_upload/*").Get(repo.UploadFile).
 | 
								m.Combo("/_upload/*").Get(repo.UploadFile).
 | 
				
			||||||
				Post(bindIgnErr(auth.UploadRepoFileForm{}), repo.UploadFilePost)
 | 
									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-file", repo.UploadFileToServer)
 | 
				
			||||||
			// m.Post("/upload-remove", bindIgnErr(auth.RemoveUploadFileForm{}), repo.RemoveUploadFileFromServer)
 | 
								// m.Post("/upload-remove", bindIgnErr(auth.RemoveUploadFileForm{}), repo.RemoveUploadFileFromServer)
 | 
				
			||||||
		}, reqRepoWriter, context.RepoRef(), func(ctx *context.Context) {
 | 
							}, reqRepoWriter, context.RepoRef(), func(ctx *context.Context) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -426,30 +426,31 @@ file_view_raw = View Raw
 | 
				
			|||||||
file_permalink = Permalink
 | 
					file_permalink = Permalink
 | 
				
			||||||
file_too_large = This file is too large to be shown
 | 
					file_too_large = This file is too large to be shown
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cancel = Cancel
 | 
					 | 
				
			||||||
cancel_lower = cancel
 | 
					cancel_lower = cancel
 | 
				
			||||||
or = or
 | 
					or = or
 | 
				
			||||||
new_file = New file
 | 
					 | 
				
			||||||
upload_files = Upload files
 | 
					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
 | 
					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
 | 
					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.
 | 
					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
 | 
					new_branch = new branch
 | 
				
			||||||
 | 
					editor.new_file = New file
 | 
				
			||||||
editor.cannot_edit_non_text_files = Cannot edit non-text files
 | 
					editor.cannot_edit_non_text_files = Cannot edit non-text files
 | 
				
			||||||
editor.edit_this_file = Edit this file
 | 
					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.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.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.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.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.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.filename_cannot_be_empty = Filename cannot be empty.
 | 
				
			||||||
editor.branch_already_exists = Branch '%s' already exists in this repository.
 | 
					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.
 | 
					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_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_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.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.failed_to_upload_files = An error occurred while updating file: %v
 | 
				
			||||||
editor.no_changes_to_show = There are no changes to show.
 | 
					editor.no_changes_to_show = There are no changes to show.
 | 
				
			||||||
create_branch = Create branch
 | 
					 | 
				
			||||||
from = from
 | 
					 | 
				
			||||||
upload_file = Upload file
 | 
					upload_file = Upload file
 | 
				
			||||||
add_files_to_dir = Add files to %s
 | 
					add_files_to_dir = Add files to %s
 | 
				
			||||||
add_subdir = Add subdirectory...
 | 
					add_subdir = Add subdirectory...
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								gogs.go
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								gogs.go
									
									
									
									
									
								
							@@ -17,7 +17,7 @@ import (
 | 
				
			|||||||
	"github.com/gogits/gogs/modules/setting"
 | 
						"github.com/gogits/gogs/modules/setting"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const APP_VER = "0.9.90.0828"
 | 
					const APP_VER = "0.9.91.0828"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func init() {
 | 
					func init() {
 | 
				
			||||||
	runtime.GOMAXPROCS(runtime.NumCPU())
 | 
						runtime.GOMAXPROCS(runtime.NumCPU())
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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()
 | 
						localPath := repo.LocalCopyPath()
 | 
				
			||||||
	filePath := path.Join(localPath, opts.NewTreeName)
 | 
						filePath := path.Join(localPath, opts.NewTreeName)
 | 
				
			||||||
	os.MkdirAll(path.Dir(filePath), os.ModePerm)
 | 
						os.MkdirAll(path.Dir(filePath), os.ModePerm)
 | 
				
			||||||
@@ -228,7 +220,8 @@ func (repo *Repository) GetDiffPreview(branch, treePath, content string) (diff *
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
type DeleteRepoFileOptions struct {
 | 
					type DeleteRepoFileOptions struct {
 | 
				
			||||||
	LastCommitID string
 | 
						LastCommitID string
 | 
				
			||||||
	Branch       string
 | 
						OldBranch    string
 | 
				
			||||||
 | 
						NewBranch    string
 | 
				
			||||||
	TreePath     string
 | 
						TreePath     string
 | 
				
			||||||
	Message      string
 | 
						Message      string
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -237,21 +230,23 @@ func (repo *Repository) DeleteRepoFile(doer *User, opts DeleteRepoFileOptions) (
 | 
				
			|||||||
	repoWorkingPool.CheckIn(com.ToStr(repo.ID))
 | 
						repoWorkingPool.CheckIn(com.ToStr(repo.ID))
 | 
				
			||||||
	defer repoWorkingPool.CheckOut(com.ToStr(repo.ID))
 | 
						defer repoWorkingPool.CheckOut(com.ToStr(repo.ID))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	localPath := repo.LocalCopyPath()
 | 
						if err = repo.DiscardLocalRepoBranchChanges(opts.OldBranch); err != nil {
 | 
				
			||||||
	if err = discardLocalRepoBranchChanges(localPath, opts.Branch); err != nil {
 | 
							return fmt.Errorf("DiscardLocalRepoBranchChanges [branch: %s]: %v", opts.OldBranch, err)
 | 
				
			||||||
		return fmt.Errorf("discardLocalRepoBranchChanges [branch: %s]: %v", opts.Branch, err)
 | 
						} else if err = repo.UpdateLocalCopyBranch(opts.OldBranch); err != nil {
 | 
				
			||||||
	} else if err = repo.UpdateLocalCopyBranch(opts.Branch); err != nil {
 | 
							return fmt.Errorf("UpdateLocalCopyBranch [branch: %s]: %v", opts.OldBranch, err)
 | 
				
			||||||
		return fmt.Errorf("UpdateLocalCopyBranch [branch: %s]: %v", opts.Branch, 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 {
 | 
						if err = os.Remove(path.Join(localPath, opts.TreePath)); err != nil {
 | 
				
			||||||
		return fmt.Errorf("Remove: %v", err)
 | 
							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 {
 | 
						if err = git.AddChanges(localPath, true); err != nil {
 | 
				
			||||||
		return fmt.Errorf("git add --all: %v", err)
 | 
							return fmt.Errorf("git add --all: %v", err)
 | 
				
			||||||
	} else if err = git.CommitChanges(localPath, git.CommitChangesOptions{
 | 
						} else if err = git.CommitChanges(localPath, git.CommitChangesOptions{
 | 
				
			||||||
@@ -259,8 +254,8 @@ func (repo *Repository) DeleteRepoFile(doer *User, opts DeleteRepoFileOptions) (
 | 
				
			|||||||
		Message:   opts.Message,
 | 
							Message:   opts.Message,
 | 
				
			||||||
	}); err != nil {
 | 
						}); err != nil {
 | 
				
			||||||
		return fmt.Errorf("CommitChanges: %v", err)
 | 
							return fmt.Errorf("CommitChanges: %v", err)
 | 
				
			||||||
	} else if err = git.Push(localPath, "origin", opts.Branch); err != nil {
 | 
						} else if err = git.Push(localPath, "origin", opts.NewBranch); err != nil {
 | 
				
			||||||
		return fmt.Errorf("git push origin %s: %v", opts.Branch, err)
 | 
							return fmt.Errorf("git push origin %s: %v", opts.NewBranch, err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	gitRepo, err := git.OpenRepository(repo.RepoPath())
 | 
						gitRepo, err := git.OpenRepository(repo.RepoPath())
 | 
				
			||||||
@@ -268,9 +263,9 @@ func (repo *Repository) DeleteRepoFile(doer *User, opts DeleteRepoFileOptions) (
 | 
				
			|||||||
		log.Error(4, "OpenRepository: %v", err)
 | 
							log.Error(4, "OpenRepository: %v", err)
 | 
				
			||||||
		return nil
 | 
							return nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	commit, err := gitRepo.GetBranchCommit(opts.Branch)
 | 
						commit, err := gitRepo.GetBranchCommit(opts.NewBranch)
 | 
				
			||||||
	if err != nil {
 | 
						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
 | 
							return nil
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -283,7 +278,7 @@ func (repo *Repository) DeleteRepoFile(doer *User, opts DeleteRepoFileOptions) (
 | 
				
			|||||||
		PusherName:  doer.Name,
 | 
							PusherName:  doer.Name,
 | 
				
			||||||
		RepoOwnerID: repo.MustOwner().ID,
 | 
							RepoOwnerID: repo.MustOwner().ID,
 | 
				
			||||||
		RepoName:    repo.Name,
 | 
							RepoName:    repo.Name,
 | 
				
			||||||
		RefFullName: git.BRANCH_PREFIX + opts.Branch,
 | 
							RefFullName: git.BRANCH_PREFIX + opts.NewBranch,
 | 
				
			||||||
		OldCommitID: opts.LastCommitID,
 | 
							OldCommitID: opts.LastCommitID,
 | 
				
			||||||
		NewCommitID: commit.ID.String(),
 | 
							NewCommitID: commit.ID.String(),
 | 
				
			||||||
		Commits:     pushCommits,
 | 
							Commits:     pushCommits,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -337,6 +337,9 @@ func (f *RemoveUploadFileForm) Validate(ctx *macaron.Context, errs binding.Error
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
type DeleteRepoFileForm struct {
 | 
					type DeleteRepoFileForm struct {
 | 
				
			||||||
	CommitSummary string `binding:"MaxSize(100)`
 | 
						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 {
 | 
					func (f *DeleteRepoFileForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
 | 
				
			||||||
 
 | 
				
			|||||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@@ -737,6 +737,16 @@ function setCodeMirror($editArea) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function initEditor() {
 | 
					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");
 | 
					    var $editFilename = $("#file-name");
 | 
				
			||||||
    $editFilename.keyup(function (e) {
 | 
					    $editFilename.keyup(function (e) {
 | 
				
			||||||
        var $section = $('.breadcrumb span.section');
 | 
					        var $section = $('.breadcrumb span.section');
 | 
				
			||||||
@@ -841,16 +851,6 @@ function initEditor() {
 | 
				
			|||||||
            codeMirrorEditor.setOption("lineWrapping", false);
 | 
					            codeMirrorEditor.setOption("lineWrapping", false);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }).trigger('keyup');
 | 
					    }).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() {
 | 
					function initOrganization() {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,9 +20,10 @@ import (
 | 
				
			|||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
	EDIT             base.TplName = "repo/editor/edit"
 | 
						EDIT_FILE         base.TplName = "repo/editor/edit"
 | 
				
			||||||
	DIFF_PREVIEW     base.TplName = "repo/editor/diff_preview"
 | 
						EDIT_DIFF_PREVIEW base.TplName = "repo/editor/diff_preview"
 | 
				
			||||||
	DIFF_PREVIEW_NEW base.TplName = "repo/editor/diff_preview_new"
 | 
						NEW_DIFF_PREVIEW  base.TplName = "repo/editor/diff_preview_new"
 | 
				
			||||||
 | 
						DELETE_FILE       base.TplName = "repo/editor/delete"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func editFile(ctx *context.Context, isNewFile bool) {
 | 
					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["LineWrapExtensions"] = strings.Join(setting.Repository.Editor.LineWrapExtensions, ",")
 | 
				
			||||||
	ctx.Data["PreviewableFileModes"] = strings.Join(setting.Repository.Editor.PreviewableFileModes, ",")
 | 
						ctx.Data["PreviewableFileModes"] = strings.Join(setting.Repository.Editor.PreviewableFileModes, ",")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctx.HTML(200, EDIT)
 | 
						ctx.HTML(200, EDIT_FILE)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func EditFile(ctx *context.Context) {
 | 
					func EditFile(ctx *context.Context) {
 | 
				
			||||||
@@ -125,12 +126,10 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
 | 
				
			|||||||
	branchName := oldBranchName
 | 
						branchName := oldBranchName
 | 
				
			||||||
	branchLink := ctx.Repo.RepoLink + "/src/" + branchName
 | 
						branchLink := ctx.Repo.RepoLink + "/src/" + branchName
 | 
				
			||||||
	oldTreePath := ctx.Repo.TreePath
 | 
						oldTreePath := ctx.Repo.TreePath
 | 
				
			||||||
	content := form.Content
 | 
					 | 
				
			||||||
	commitChoice := form.CommitChoice
 | 
					 | 
				
			||||||
	lastCommit := form.LastCommit
 | 
						lastCommit := form.LastCommit
 | 
				
			||||||
	form.LastCommit = ctx.Repo.Commit.ID.String()
 | 
						form.LastCommit = ctx.Repo.Commit.ID.String()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if commitChoice == "commit-to-new-branch" {
 | 
						if form.CommitChoice == "commit-to-new-branch" {
 | 
				
			||||||
		branchName = form.NewBranchName
 | 
							branchName = form.NewBranchName
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -144,10 +143,10 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
 | 
				
			|||||||
	ctx.Data["TreePath"] = form.TreePath
 | 
						ctx.Data["TreePath"] = form.TreePath
 | 
				
			||||||
	ctx.Data["TreeNames"] = treeNames
 | 
						ctx.Data["TreeNames"] = treeNames
 | 
				
			||||||
	ctx.Data["BranchLink"] = branchLink
 | 
						ctx.Data["BranchLink"] = branchLink
 | 
				
			||||||
	ctx.Data["FileContent"] = content
 | 
						ctx.Data["FileContent"] = form.Content
 | 
				
			||||||
	ctx.Data["commit_summary"] = form.CommitSummary
 | 
						ctx.Data["commit_summary"] = form.CommitSummary
 | 
				
			||||||
	ctx.Data["commit_message"] = form.CommitMessage
 | 
						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["new_branch_name"] = branchName
 | 
				
			||||||
	ctx.Data["last_commit"] = form.LastCommit
 | 
						ctx.Data["last_commit"] = form.LastCommit
 | 
				
			||||||
	ctx.Data["MarkdownFileExts"] = strings.Join(setting.Markdown.FileExtensions, ",")
 | 
						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, ",")
 | 
						ctx.Data["PreviewableFileModes"] = strings.Join(setting.Repository.Editor.PreviewableFileModes, ",")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ctx.HasError() {
 | 
						if ctx.HasError() {
 | 
				
			||||||
		ctx.HTML(200, EDIT)
 | 
							ctx.HTML(200, EDIT_FILE)
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if len(form.TreePath) == 0 {
 | 
						if len(form.TreePath) == 0 {
 | 
				
			||||||
		ctx.Data["Err_TreePath"] = true
 | 
							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
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if oldBranchName != branchName {
 | 
						if oldBranchName != branchName {
 | 
				
			||||||
		if _, err := ctx.Repo.Repository.GetBranch(branchName); err == nil {
 | 
							if _, err := ctx.Repo.Repository.GetBranch(branchName); err == nil {
 | 
				
			||||||
			ctx.Data["Err_NewBranchName"] = true
 | 
								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
 | 
								return
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -189,13 +188,13 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
 | 
				
			|||||||
		if index != len(treeNames)-1 {
 | 
							if index != len(treeNames)-1 {
 | 
				
			||||||
			if !entry.IsDir() {
 | 
								if !entry.IsDir() {
 | 
				
			||||||
				ctx.Data["Err_TreePath"] = true
 | 
									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
 | 
									return
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			if entry.IsDir() {
 | 
								if entry.IsDir() {
 | 
				
			||||||
				ctx.Data["Err_TreePath"] = true
 | 
									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
 | 
									return
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -206,7 +205,7 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
 | 
				
			|||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			if git.IsErrNotExist(err) {
 | 
								if git.IsErrNotExist(err) {
 | 
				
			||||||
				ctx.Data["Err_TreePath"] = true
 | 
									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 {
 | 
								} else {
 | 
				
			||||||
				ctx.Handle(500, "GetTreeEntryByPath", err)
 | 
									ctx.Handle(500, "GetTreeEntryByPath", err)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
@@ -221,7 +220,7 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			for _, file := range files {
 | 
								for _, file := range files {
 | 
				
			||||||
				if file == form.TreePath {
 | 
									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
 | 
										return
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
@@ -239,15 +238,13 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		if entry != nil {
 | 
							if entry != nil {
 | 
				
			||||||
			ctx.Data["Err_TreePath"] = true
 | 
								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
 | 
								return
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var message string
 | 
						message := strings.TrimSpace(form.CommitSummary)
 | 
				
			||||||
	if len(form.CommitSummary) > 0 {
 | 
						if len(message) == 0 {
 | 
				
			||||||
		message = strings.TrimSpace(form.CommitSummary)
 | 
					 | 
				
			||||||
	} else {
 | 
					 | 
				
			||||||
		if isNewFile {
 | 
							if isNewFile {
 | 
				
			||||||
			message = ctx.Tr("repo.editor.add", form.TreePath)
 | 
								message = ctx.Tr("repo.editor.add", form.TreePath)
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
@@ -267,11 +264,11 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
 | 
				
			|||||||
		OldTreeName:  oldTreePath,
 | 
							OldTreeName:  oldTreePath,
 | 
				
			||||||
		NewTreeName:  form.TreePath,
 | 
							NewTreeName:  form.TreePath,
 | 
				
			||||||
		Message:      message,
 | 
							Message:      message,
 | 
				
			||||||
		Content:      content,
 | 
							Content:      form.Content,
 | 
				
			||||||
		IsNewFile:    isNewFile,
 | 
							IsNewFile:    isNewFile,
 | 
				
			||||||
	}); err != nil {
 | 
						}); err != nil {
 | 
				
			||||||
		ctx.Data["Err_TreePath"] = true
 | 
							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
 | 
							return
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -287,14 +284,14 @@ func NewFilePost(ctx *context.Context, form auth.EditRepoFileForm) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func DiffPreviewPost(ctx *context.Context, form auth.EditPreviewDiffForm) {
 | 
					func DiffPreviewPost(ctx *context.Context, form auth.EditPreviewDiffForm) {
 | 
				
			||||||
	treeName := ctx.Repo.TreePath
 | 
						treePath := ctx.Repo.TreePath
 | 
				
			||||||
	content := form.Content
 | 
						content := form.Content
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	entry, err := ctx.Repo.Commit.GetTreeEntryByPath(treeName)
 | 
						entry, err := ctx.Repo.Commit.GetTreeEntryByPath(treePath)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		if git.IsErrNotExist(err) {
 | 
							if git.IsErrNotExist(err) {
 | 
				
			||||||
			ctx.Data["FileContent"] = content
 | 
								ctx.Data["FileContent"] = content
 | 
				
			||||||
			ctx.HTML(200, DIFF_PREVIEW_NEW)
 | 
								ctx.HTML(200, NEW_DIFF_PREVIEW)
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			ctx.Error(500, "GetTreeEntryByPath: "+err.Error())
 | 
								ctx.Error(500, "GetTreeEntryByPath: "+err.Error())
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -305,7 +302,7 @@ func DiffPreviewPost(ctx *context.Context, form auth.EditPreviewDiffForm) {
 | 
				
			|||||||
		return
 | 
							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 {
 | 
						if err != nil {
 | 
				
			||||||
		ctx.Error(500, "GetDiffPreview: "+err.Error())
 | 
							ctx.Error(500, "GetDiffPreview: "+err.Error())
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
@@ -317,28 +314,71 @@ func DiffPreviewPost(ctx *context.Context, form auth.EditPreviewDiffForm) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	ctx.Data["File"] = diff.Files[0]
 | 
						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) {
 | 
					func DeleteFilePost(ctx *context.Context, form auth.DeleteRepoFileForm) {
 | 
				
			||||||
	branchName := ctx.Repo.BranchName
 | 
						ctx.Data["PageIsDelete"] = true
 | 
				
			||||||
	treeName := ctx.Repo.TreePath
 | 
						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() {
 | 
						if ctx.HasError() {
 | 
				
			||||||
		ctx.Redirect(ctx.Repo.RepoLink + "/src/" + branchName + "/" + treeName)
 | 
							ctx.HTML(200, DELETE_FILE)
 | 
				
			||||||
		return
 | 
							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{
 | 
						if err := ctx.Repo.Repository.DeleteRepoFile(ctx.User, models.DeleteRepoFileOptions{
 | 
				
			||||||
		LastCommitID: ctx.Repo.CommitID,
 | 
							LastCommitID: ctx.Repo.CommitID,
 | 
				
			||||||
		Branch:       branchName,
 | 
							OldBranch:    oldBranchName,
 | 
				
			||||||
		TreePath:     treeName,
 | 
							NewBranch:    branchName,
 | 
				
			||||||
		Message:      form.CommitSummary,
 | 
							TreePath:     treePath,
 | 
				
			||||||
 | 
							Message:      message,
 | 
				
			||||||
	}); err != nil {
 | 
						}); err != nil {
 | 
				
			||||||
		ctx.Handle(500, "DeleteRepoFile", err)
 | 
							ctx.Handle(500, "DeleteRepoFile", err)
 | 
				
			||||||
		return
 | 
							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)
 | 
						ctx.Redirect(ctx.Repo.RepoLink + "/src/" + branchName)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -48,7 +48,6 @@ func Home(ctx *context.Context) {
 | 
				
			|||||||
	branchLink := ctx.Repo.RepoLink + "/src/" + branchName
 | 
						branchLink := ctx.Repo.RepoLink + "/src/" + branchName
 | 
				
			||||||
	treeLink := branchLink
 | 
						treeLink := branchLink
 | 
				
			||||||
	rawLink := ctx.Repo.RepoLink + "/raw/" + branchName
 | 
						rawLink := ctx.Repo.RepoLink + "/raw/" + branchName
 | 
				
			||||||
	// newFileLink := ctx.Repo.RepoLink + "/_new/" + branchName
 | 
					 | 
				
			||||||
	// uploadFileLink := ctx.Repo.RepoLink + "/upload/" + branchName
 | 
						// uploadFileLink := ctx.Repo.RepoLink + "/upload/" + branchName
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	treePath := ctx.Repo.TreePath
 | 
						treePath := ctx.Repo.TreePath
 | 
				
			||||||
@@ -155,13 +154,11 @@ func Home(ctx *context.Context) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		if ctx.Repo.IsWriter() && ctx.Repo.IsViewBranch {
 | 
							if ctx.Repo.IsWriter() && ctx.Repo.IsViewBranch {
 | 
				
			||||||
			ctx.Data["CanDeleteFile"] = true
 | 
								ctx.Data["CanDeleteFile"] = true
 | 
				
			||||||
			ctx.Data["FileDeleteLinkTooltip"] = ctx.Tr("repo.delete_this_file")
 | 
								ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.delete_this_file")
 | 
				
			||||||
		} else {
 | 
							} else if !ctx.Repo.IsViewBranch {
 | 
				
			||||||
			if !ctx.Repo.IsViewBranch {
 | 
								ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.must_be_on_a_branch")
 | 
				
			||||||
				ctx.Data["FileDeleteLinkTooltip"] = ctx.Tr("repo.must_be_on_branch")
 | 
							} else if !ctx.Repo.IsWriter() {
 | 
				
			||||||
			} else if !ctx.Repo.IsWriter() {
 | 
								ctx.Data["DeleteFileTooltip"] = ctx.Tr("repo.editor.must_have_write_access")
 | 
				
			||||||
				ctx.Data["FileDeleteLinkTooltip"] = ctx.Tr("repo.must_be_writer")
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
@@ -240,12 +237,13 @@ func Home(ctx *context.Context) {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		ctx.Data["LastCommit"] = lastCommit
 | 
							ctx.Data["LastCommit"] = lastCommit
 | 
				
			||||||
		ctx.Data["LastCommitUser"] = models.ValidateCommitWithEmail(lastCommit)
 | 
							ctx.Data["LastCommitUser"] = models.ValidateCommitWithEmail(lastCommit)
 | 
				
			||||||
		// if ctx.Repo.IsWriter() && ctx.Repo.IsViewBranch {
 | 
					
 | 
				
			||||||
		// 	ctx.Data["NewFileLink"] = newFileLink + "/" + treePath
 | 
							if ctx.Repo.IsWriter() && ctx.Repo.IsViewBranch {
 | 
				
			||||||
		// 	if setting.Repository.Upload.Enabled {
 | 
								ctx.Data["CanAddFile"] = true
 | 
				
			||||||
		// 		ctx.Data["UploadFileLink"] = uploadFileLink + "/" + treePath
 | 
								// if setting.Repository.Upload.Enabled {
 | 
				
			||||||
		// 	}
 | 
								// 	ctx.Data["UploadFileLink"] = uploadFileLink + "/" + treePath
 | 
				
			||||||
		// }
 | 
								// }
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctx.Data["Username"] = userName
 | 
						ctx.Data["Username"] = userName
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1 +1 @@
 | 
				
			|||||||
0.9.90.0828
 | 
					0.9.91.0828
 | 
				
			||||||
@@ -10,6 +10,6 @@
 | 
				
			|||||||
{{end}}
 | 
					{{end}}
 | 
				
			||||||
{{if .Flash.InfoMsg}}
 | 
					{{if .Flash.InfoMsg}}
 | 
				
			||||||
	<div class="ui info message">
 | 
						<div class="ui info message">
 | 
				
			||||||
		<p>{{.Flash.InfoMsg| Safe}}</p>
 | 
							<p>{{.Flash.InfoMsg | Safe}}</p>
 | 
				
			||||||
	</div>
 | 
						</div>
 | 
				
			||||||
{{end}}
 | 
					{{end}}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
<div class="fitted item choose reference">
 | 
					<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">
 | 
								<div class="ui basic small button">
 | 
				
			||||||
			<span class="text">
 | 
								<span class="text">
 | 
				
			||||||
				<i class="octicon octicon-git-branch"></i>
 | 
									<i class="octicon octicon-git-branch"></i>
 | 
				
			||||||
@@ -31,12 +31,12 @@
 | 
				
			|||||||
			</div>
 | 
								</div>
 | 
				
			||||||
			<div id="branch-list" class="scrolling menu" {{if .IsViewTag}}style="display: none"{{end}}>
 | 
								<div id="branch-list" class="scrolling menu" {{if .IsViewTag}}style="display: none"{{end}}>
 | 
				
			||||||
				{{range .Branches}}
 | 
									{{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}}
 | 
									{{end}}
 | 
				
			||||||
			</div>
 | 
								</div>
 | 
				
			||||||
			<div id="tag-list" class="scrolling menu" {{if not .IsViewTag}}style="display: none"{{end}}>
 | 
								<div id="tag-list" class="scrolling menu" {{if not .IsViewTag}}style="display: none"{{end}}>
 | 
				
			||||||
				{{range .Tags}}
 | 
									{{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}}
 | 
									{{end}}
 | 
				
			||||||
			</div>
 | 
								</div>
 | 
				
			||||||
		</div>
 | 
							</div>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -152,21 +152,21 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	{{if .IsSplitStyle}}
 | 
						{{if .IsSplitStyle}}
 | 
				
			||||||
		<script>
 | 
							<script>
 | 
				
			||||||
		(function() {
 | 
								(function() {
 | 
				
			||||||
			$('.add-code').each(function() {
 | 
									$('.add-code').each(function() {
 | 
				
			||||||
				var prev = $(this).prev();
 | 
										var prev = $(this).prev();
 | 
				
			||||||
				if(prev.is('.del-code') && prev.children().eq(3).text().trim() === '') {
 | 
										if(prev.is('.del-code') && prev.children().eq(3).text().trim() === '') {
 | 
				
			||||||
					while(prev.prev().is('.del-code') && prev.prev().children().eq(3).text().trim() === '') {
 | 
											while(prev.prev().is('.del-code') && prev.prev().children().eq(3).text().trim() === '') {
 | 
				
			||||||
						prev = prev.prev();
 | 
												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>
 | 
							</script>
 | 
				
			||||||
	{{end}}
 | 
						{{end}}
 | 
				
			||||||
{{end}}
 | 
					{{end}}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										43
									
								
								templates/repo/editor/commit_form.tmpl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								templates/repo/editor/commit_form.tmpl
									
									
									
									
									
										Normal file
									
								
							@@ -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>
 | 
				
			||||||
							
								
								
									
										12
									
								
								templates/repo/editor/delete.tmpl
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								templates/repo/editor/delete.tmpl
									
									
									
									
									
										Normal file
									
								
							@@ -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"}}
 | 
										{{.i18n.Tr "repo.release.loading"}}
 | 
				
			||||||
				</div>
 | 
									</div>
 | 
				
			||||||
			</div>
 | 
								</div>
 | 
				
			||||||
			<div class="commit-form-wrapper">
 | 
								{{template "repo/editor/commit_form" .}}
 | 
				
			||||||
				<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>
 | 
					 | 
				
			||||||
		</form>
 | 
							</form>
 | 
				
			||||||
	</div>
 | 
						</div>
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -34,9 +34,9 @@
 | 
				
			|||||||
			</div>
 | 
								</div>
 | 
				
			||||||
			<div class="right fitted item">
 | 
								<div class="right fitted item">
 | 
				
			||||||
				<div id="file-buttons" class="ui tiny buttons">
 | 
									<div id="file-buttons" class="ui tiny buttons">
 | 
				
			||||||
					{{if .NewFileLink}}
 | 
										{{if .CanAddFile}}
 | 
				
			||||||
						<a href="{{EscapePound .NewFileLink}}" class="ui button">
 | 
											<a href="{{.RepoLink}}/_new/{{EscapePound .BranchName}}/{{EscapePound .TreePath}}" class="ui button">
 | 
				
			||||||
							{{.i18n.Tr "repo.new_file"}}
 | 
												{{.i18n.Tr "repo.editor.new_file"}}
 | 
				
			||||||
						</a>
 | 
											</a>
 | 
				
			||||||
					{{end}}
 | 
										{{end}}
 | 
				
			||||||
					{{if .UploadFileLink}}
 | 
										{{if .UploadFileLink}}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,18 +21,14 @@
 | 
				
			|||||||
					<a class="ui button" href="{{EscapePound .FileLink}}">{{.i18n.Tr "repo.file_raw"}}</a>
 | 
										<a class="ui button" href="{{EscapePound .FileLink}}">{{.i18n.Tr "repo.file_raw"}}</a>
 | 
				
			||||||
				</div>
 | 
									</div>
 | 
				
			||||||
				{{if .CanEditFile}}
 | 
									{{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}}
 | 
									{{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}}
 | 
									{{end}}
 | 
				
			||||||
				{{if .CanDeleteFile}}
 | 
									{{if .CanDeleteFile}}
 | 
				
			||||||
					<form id="delete-file-form" class="ui form inline-form" action="{{.RepoLink}}/_delete/{{EscapePound .BranchName}}/{{.TreePath}}" method="post">
 | 
										<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>
 | 
				
			||||||
						{{.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>
 | 
					 | 
				
			||||||
				{{else}}
 | 
									{{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}}
 | 
									{{end}}
 | 
				
			||||||
			</div>
 | 
								</div>
 | 
				
			||||||
		{{end}}
 | 
							{{end}}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user