Browse Source

Web editor: fix cannot create new file in subdirectory

Unknwon 8 years ago
parent
commit
62b0dc4853

+ 1 - 1
README.md

@@ -3,7 +3,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
 
 ![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
 
-##### Current tip version: 0.9.92 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions)
+##### Current tip version: 0.9.93 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions)
 
 | Web | UI  | Preview  |
 |:-------------:|:-------:|:-------:|

+ 1 - 0
conf/locale/locale_en-US.ini

@@ -458,6 +458,7 @@ editor.file_editing_no_longer_exists = The file '%s' you are editing no longer e
 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.no_changes_to_show = There are no changes to show.
+editor.fail_to_update_file = Failed to update/create file '%s' with error: %v
 upload_files = Upload files
 upload_file = Upload file
 add_files_to_dir = Add files to %s

+ 1 - 1
gogs.go

@@ -17,7 +17,7 @@ import (
 	"github.com/gogits/gogs/modules/setting"
 )
 
-const APP_VER = "0.9.92.0828"
+const APP_VER = "0.9.93.0829"
 
 func init() {
 	runtime.GOMAXPROCS(runtime.NumCPU())

+ 4 - 2
models/repo_editor.go

@@ -96,6 +96,7 @@ func (repo *Repository) UpdateRepoFile(doer *User, opts UpdateRepoFileOptions) (
 	}
 
 	localPath := repo.LocalCopyPath()
+	oldFilePath := path.Join(localPath, opts.OldTreeName)
 	filePath := path.Join(localPath, opts.NewTreeName)
 	os.MkdirAll(path.Dir(filePath), os.ModePerm)
 
@@ -106,8 +107,9 @@ func (repo *Repository) UpdateRepoFile(doer *User, opts UpdateRepoFileOptions) (
 		}
 	}
 
-	// If update a file, move if file name change.
-	if len(opts.OldTreeName) > 0 && len(opts.NewTreeName) > 0 && opts.OldTreeName != opts.NewTreeName {
+	// Ignore move step if it's a new file under a directory.
+	// Otherwise, move the file when name changed.
+	if com.IsFile(oldFilePath) && opts.OldTreeName != opts.NewTreeName {
 		if err = git.MoveFile(localPath, opts.OldTreeName, opts.NewTreeName); err != nil {
 			return fmt.Errorf("git mv %s %s: %v", opts.OldTreeName, opts.NewTreeName, err)
 		}

File diff suppressed because it is too large
+ 0 - 0
modules/bindata/bindata.go


+ 2 - 2
modules/mailer/mailer.go

@@ -126,8 +126,8 @@ func (s *Sender) Send(from string, to []string, msg io.WriterTo) error {
 		return fmt.Errorf("NewClient: %v", err)
 	}
 
-	if !setting.MailService.DisableHelo {
-		hostname := setting.MailService.HeloHostname
+	if !opts.DisableHelo {
+		hostname := opts.HeloHostname
 		if len(hostname) == 0 {
 			hostname, err = os.Hostname()
 			if err != nil {

+ 1 - 1
public/css/gogs.css

@@ -1199,6 +1199,7 @@ footer .ui.language .menu {
 .repository #clone-panel {
   margin-top: -8px;
   width: 100%;
+  padding-left: 20px;
 }
 .repository #clone-panel input {
   border-radius: 0;
@@ -1227,7 +1228,6 @@ footer .ui.language .menu {
 .repository.file.list #file-buttons {
   font-weight: normal;
   margin-top: -3px;
-  padding-right: 20px;
 }
 .repository.file.list #file-buttons .ui.button {
   padding: 8px 10px;

+ 1 - 1
public/less/_repository.less

@@ -127,6 +127,7 @@
 	#clone-panel {
 		margin-top: -8px;
 		width: 100%;
+		padding-left: 20px;
 
 		input {
 			border-radius: 0;
@@ -161,7 +162,6 @@
 		#file-buttons {
 			font-weight: normal;
 			margin-top: -3px;
-			padding-right: 20px;
 			.ui.button {
 				padding: 8px 10px;
 			}

+ 1 - 1
routers/repo/editor.go

@@ -267,7 +267,7 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
 		IsNewFile:    isNewFile,
 	}); err != nil {
 		ctx.Data["Err_TreePath"] = true
-		ctx.RenderWithErr(ctx.Tr("repo.editor.failed_to_update_file", err), EDIT_FILE, &form)
+		ctx.RenderWithErr(ctx.Tr("repo.editor.fail_to_update_file", form.TreePath, err), EDIT_FILE, &form)
 		return
 	}
 

+ 1 - 1
templates/.VERSION

@@ -1 +1 @@
-0.9.92.0828
+0.9.93.0829

Some files were not shown because too many files changed in this diff