|
|
@@ -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') |
|
|
|
} |
|
|
|