@@ -50,7 +50,7 @@ type ChangeRepoFile struct {
50
50
Options * RepoFileOptions
51
51
}
52
52
53
- // UpdateRepoFilesOptions holds the repository files update options
53
+ // ChangeRepoFilesOptions holds the repository files update options
54
54
type ChangeRepoFilesOptions struct {
55
55
LastCommitID string
56
56
OldBranch string
@@ -159,7 +159,7 @@ func ChangeRepoFiles(ctx context.Context, repo *repo_model.Repository, doer *use
159
159
return nil , err
160
160
}
161
161
162
- treePaths := []string {}
162
+ var treePaths []string
163
163
for _ , file := range opts .Files {
164
164
// If FromTreePath is not set, set it to the opts.TreePath
165
165
if file .TreePath != "" && file .FromTreePath == "" {
@@ -302,7 +302,7 @@ func ChangeRepoFiles(ctx context.Context, repo *repo_model.Repository, doer *use
302
302
return nil , err
303
303
}
304
304
default :
305
- return nil , fmt .Errorf ("Invalid file operation: %s %s, supported operations are create, update, delete" , file .Operation , file .Options .treePath )
305
+ return nil , fmt .Errorf ("invalid file operation: %s %s, supported operations are create, update, delete" , file .Operation , file .Options .treePath )
306
306
}
307
307
}
308
308
@@ -334,16 +334,16 @@ func ChangeRepoFiles(ctx context.Context, repo *repo_model.Repository, doer *use
334
334
return nil , err
335
335
}
336
336
337
- filesReponse , err := GetFilesResponseFromCommit (ctx , repo , commit , opts .NewBranch , treePaths )
337
+ filesResponse , err := GetFilesResponseFromCommit (ctx , repo , commit , opts .NewBranch , treePaths )
338
338
if err != nil {
339
339
return nil , err
340
340
}
341
341
342
342
if repo .IsEmpty {
343
- _ = repo_model .UpdateRepositoryCols (ctx , & repo_model.Repository {ID : repo .ID , IsEmpty : false }, "is_empty" )
343
+ _ = repo_model .UpdateRepositoryCols (ctx , & repo_model.Repository {ID : repo .ID , IsEmpty : false , DefaultBranch : opts . NewBranch }, "is_empty" , "default_branch " )
344
344
}
345
345
346
- return filesReponse , nil
346
+ return filesResponse , nil
347
347
}
348
348
349
349
// handles the check for various issues for ChangeRepoFiles
@@ -437,7 +437,7 @@ func handleCheckErrors(file *ChangeRepoFile, commit *git.Commit, opts *ChangeRep
437
437
return nil
438
438
}
439
439
440
- // handle creating or updating a file for ChangeRepoFiles
440
+ // CreateOrUpdateFile handles creating or updating a file for ChangeRepoFiles
441
441
func CreateOrUpdateFile (ctx context.Context , t * TemporaryUploadRepository , file * ChangeRepoFile , contentStore * lfs.ContentStore , repoID int64 , hasOldBranch bool ) error {
442
442
// Get the two paths (might be the same if not moving) from the index if they exist
443
443
filesInIndex , err := t .LsFiles (file .TreePath , file .FromTreePath )
@@ -540,7 +540,7 @@ func CreateOrUpdateFile(ctx context.Context, t *TemporaryUploadRepository, file
540
540
if ! exist {
541
541
if err := contentStore .Put (lfsMetaObject .Pointer , strings .NewReader (file .Content )); err != nil {
542
542
if _ , err2 := git_model .RemoveLFSMetaObjectByOid (ctx , repoID , lfsMetaObject .Oid ); err2 != nil {
543
- return fmt .Errorf ("Error whilst removing failed inserted LFS object %s: %v (Prev Error: %w)" , lfsMetaObject .Oid , err2 , err )
543
+ return fmt .Errorf ("unable to remove failed inserted LFS object %s: %v (Prev Error: %w)" , lfsMetaObject .Oid , err2 , err )
544
544
}
545
545
return err
546
546
}
0 commit comments