Web editor: fix cannot create new file in subdirectory
This commit is contained in:
parent
429c92c0ce
commit
62b0dc4853
|
@ -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)
|
![](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 |
|
| Web | UI | Preview |
|
||||||
|:-------------:|:-------:|:-------:|
|
|:-------------:|:-------:|:-------:|
|
||||||
|
|
|
@ -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_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.no_changes_to_show = There are no changes to show.
|
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_files = Upload files
|
||||||
upload_file = Upload file
|
upload_file = Upload file
|
||||||
add_files_to_dir = Add files to %s
|
add_files_to_dir = Add files to %s
|
||||||
|
|
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.92.0828"
|
const APP_VER = "0.9.93.0829"
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||||
|
|
|
@ -96,6 +96,7 @@ func (repo *Repository) UpdateRepoFile(doer *User, opts UpdateRepoFileOptions) (
|
||||||
}
|
}
|
||||||
|
|
||||||
localPath := repo.LocalCopyPath()
|
localPath := repo.LocalCopyPath()
|
||||||
|
oldFilePath := path.Join(localPath, opts.OldTreeName)
|
||||||
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)
|
||||||
|
|
||||||
|
@ -106,8 +107,9 @@ func (repo *Repository) UpdateRepoFile(doer *User, opts UpdateRepoFileOptions) (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If update a file, move if file name change.
|
// Ignore move step if it's a new file under a directory.
|
||||||
if len(opts.OldTreeName) > 0 && len(opts.NewTreeName) > 0 && opts.OldTreeName != opts.NewTreeName {
|
// 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 {
|
if err = git.MoveFile(localPath, opts.OldTreeName, opts.NewTreeName); err != nil {
|
||||||
return fmt.Errorf("git mv %s %s: %v", opts.OldTreeName, opts.NewTreeName, err)
|
return fmt.Errorf("git mv %s %s: %v", opts.OldTreeName, opts.NewTreeName, err)
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -126,8 +126,8 @@ func (s *Sender) Send(from string, to []string, msg io.WriterTo) error {
|
||||||
return fmt.Errorf("NewClient: %v", err)
|
return fmt.Errorf("NewClient: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !setting.MailService.DisableHelo {
|
if !opts.DisableHelo {
|
||||||
hostname := setting.MailService.HeloHostname
|
hostname := opts.HeloHostname
|
||||||
if len(hostname) == 0 {
|
if len(hostname) == 0 {
|
||||||
hostname, err = os.Hostname()
|
hostname, err = os.Hostname()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -1199,6 +1199,7 @@ footer .ui.language .menu {
|
||||||
.repository #clone-panel {
|
.repository #clone-panel {
|
||||||
margin-top: -8px;
|
margin-top: -8px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
padding-left: 20px;
|
||||||
}
|
}
|
||||||
.repository #clone-panel input {
|
.repository #clone-panel input {
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
|
@ -1227,7 +1228,6 @@ footer .ui.language .menu {
|
||||||
.repository.file.list #file-buttons {
|
.repository.file.list #file-buttons {
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
margin-top: -3px;
|
margin-top: -3px;
|
||||||
padding-right: 20px;
|
|
||||||
}
|
}
|
||||||
.repository.file.list #file-buttons .ui.button {
|
.repository.file.list #file-buttons .ui.button {
|
||||||
padding: 8px 10px;
|
padding: 8px 10px;
|
||||||
|
|
|
@ -127,6 +127,7 @@
|
||||||
#clone-panel {
|
#clone-panel {
|
||||||
margin-top: -8px;
|
margin-top: -8px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
padding-left: 20px;
|
||||||
|
|
||||||
input {
|
input {
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
|
@ -161,7 +162,6 @@
|
||||||
#file-buttons {
|
#file-buttons {
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
margin-top: -3px;
|
margin-top: -3px;
|
||||||
padding-right: 20px;
|
|
||||||
.ui.button {
|
.ui.button {
|
||||||
padding: 8px 10px;
|
padding: 8px 10px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,7 +267,7 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
|
||||||
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_FILE, &form)
|
ctx.RenderWithErr(ctx.Tr("repo.editor.fail_to_update_file", form.TreePath, err), EDIT_FILE, &form)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0.9.92.0828
|
0.9.93.0829
|
Loading…
Reference in New Issue