mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-25 08:59:31 -05:00
Web editor: fix cannot create new file in subdirectory
This commit is contained in:
parent
429c92c0ce
commit
62b0dc4853
10 changed files with 15 additions and 12 deletions
|
@ -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 |
|
||||
|:-------------:|:-------:|:-------:|
|
||||
|
|
|
@ -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
|
||||
|
|
2
gogs.go
2
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())
|
||||
|
|
|
@ -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 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)
|
||||
}
|
||||
|
||||
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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 @@
|
|||
0.9.92.0828
|
||||
0.9.93.0829
|
Loading…
Reference in a new issue