Skip to content

Commit 30fd1c6

Browse files
committed
fix issues
1 parent 5821f3c commit 30fd1c6

File tree

5 files changed

+106
-9
lines changed

5 files changed

+106
-9
lines changed

modules/structs/repo_file.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ type ChangeFilesOptions struct {
8787
Files []*ChangeFileOperation `json:"files"`
8888
}
8989

90+
// Branch returns branch name
91+
func (o *ChangeFilesOptions) Branch() string {
92+
return o.FileOptions.BranchName
93+
}
94+
9095
// FileOptionInterface provides a unified interface for the different file options
9196
type FileOptionInterface interface {
9297
Branch() string

routers/api/v1/swagger/options.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ type swaggerParameterBodies struct {
116116
// in:body
117117
EditAttachmentOptions api.EditAttachmentOptions
118118

119+
// in:body
120+
ChangeFilesOptions api.ChangeFilesOptions
121+
119122
// in:body
120123
CreateFileOptions api.CreateFileOptions
121124

routers/api/v1/swagger/repo.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ type swaggerFileResponse struct {
299299
// FileListResponse
300300
// swagger:response FileListResponse
301301
type swaggerFileListResponse struct {
302+
// in: body
302303
Body []api.FileResponse `json:"body"`
303304
}
304305

services/repository/files/update.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,10 @@ func ChangeRepoFiles(ctx context.Context, repo *repo_model.Repository, doer *use
213213
if err != nil {
214214
return nil, err
215215
}
216-
if err := t.SetDefaultIndex(); err != nil {
217-
return nil, err
218-
}
219216
default:
220217
return nil, fmt.Errorf("Invalid file operation: %s %s", file.Operation, file.TreePath)
221218
}
219+
222220
// If FromTreePath is not set, set it to the opts.TreePath
223221
if file.TreePath != "" && file.FromTreePath == "" {
224222
file.FromTreePath = file.TreePath
@@ -246,6 +244,15 @@ func ChangeRepoFiles(ctx context.Context, repo *repo_model.Repository, doer *use
246244
bom: false,
247245
executable: false,
248246
}
247+
}
248+
249+
if hasOldBranch {
250+
if err := t.SetDefaultIndex(); err != nil {
251+
return nil, err
252+
}
253+
}
254+
255+
for _, file := range opts.Files {
249256
if file.Operation == "delete" {
250257
// Get the files in the index
251258
filesInIndex, err := t.LsFiles(file.TreePath)

templates/swagger/v1_json.tmpl

Lines changed: 87 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)