From 9efd1ceb15957b0cc86fe25166945e807a026483 Mon Sep 17 00:00:00 2001 From: chenyifan01 Date: Tue, 24 May 2022 18:09:37 +0800 Subject: [PATCH] #2146 fix bug --- modules/repofiles/update.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/repofiles/update.go b/modules/repofiles/update.go index d7751d50e..07440301a 100644 --- a/modules/repofiles/update.go +++ b/modules/repofiles/update.go @@ -783,6 +783,7 @@ func RenameRepoFile(repo *models.Repository, doer *models.User, opts *RenameRepo // Check that the path given in opts.treePath is valid (not a git path) treePath := CleanUploadFileName(opts.TreePath) + treePath = strings.ReplaceAll(treePath, " ", "") if treePath == "" { return models.ErrFilenameInvalid{ Path: opts.TreePath, @@ -942,16 +943,16 @@ func moveAndAddFiles(oldTreePath, newTreePath string, t *TemporaryUploadReposito } //example for v(mode SHA-1 stage file) //100755 d294c88235ac05d3dece028d8a65590f28ec46ac 0 custom/conf/app.ini - v = strings.ReplaceAll(v, "0\t", "") - tmpArray := strings.Split(v, " ") - oldPath := tmpArray[2] + tempArray := strings.Split(v, "0\t") + leftArray := strings.Split(tempArray[0], " ") + oldPath := tempArray[1] newPath := newTreePath + strings.TrimPrefix(oldPath, oldTreePath) // mode 0 means remove file stdIn.WriteString("0 0000000000000000000000000000000000000000\t") stdIn.WriteString(oldPath) stdIn.WriteByte('\000') - stdIn.WriteString(tmpArray[0] + " ") - stdIn.WriteString(tmpArray[1] + "\t") + stdIn.WriteString(leftArray[0] + " ") + stdIn.WriteString(leftArray[1] + "\t") stdIn.WriteString(newPath) stdIn.WriteByte('\000') }