@@ -6,6 +6,7 @@ package migrations
6
6
7
7
import (
8
8
"context"
9
+ "errors"
9
10
"fmt"
10
11
"io"
11
12
"net/http"
@@ -572,7 +573,7 @@ func DumpRepository(ctx context.Context, baseDir, ownerName string, opts base.Mi
572
573
return nil
573
574
}
574
575
575
- func updateOptionsUnits (opts * base.MigrateOptions , units []string ) {
576
+ func updateOptionsUnits (opts * base.MigrateOptions , units []string ) error {
576
577
if len (units ) == 0 {
577
578
opts .Wiki = true
578
579
opts .Issues = true
@@ -585,6 +586,8 @@ func updateOptionsUnits(opts *base.MigrateOptions, units []string) {
585
586
} else {
586
587
for _ , unit := range units {
587
588
switch strings .ToLower (unit ) {
589
+ case "" :
590
+ continue
588
591
case "wiki" :
589
592
opts .Wiki = true
590
593
case "issues" :
@@ -601,9 +604,12 @@ func updateOptionsUnits(opts *base.MigrateOptions, units []string) {
601
604
opts .Comments = true
602
605
case "pull_requests" :
603
606
opts .PullRequests = true
607
+ default :
608
+ return errors .New ("invalid unit: " + unit )
604
609
}
605
610
}
606
611
}
612
+ return nil
607
613
}
608
614
609
615
// RestoreRepository restore a repository from the disk directory
@@ -626,7 +632,9 @@ func RestoreRepository(ctx context.Context, baseDir, ownerName, repoName string,
626
632
migrateOpts := base.MigrateOptions {
627
633
GitServiceType : structs .GitServiceType (tp ),
628
634
}
629
- updateOptionsUnits (& migrateOpts , units )
635
+ if err = updateOptionsUnits (& migrateOpts , units ); err != nil {
636
+ return err
637
+ }
630
638
631
639
if err = migrateRepository (downloader , uploader , migrateOpts , nil ); err != nil {
632
640
if err1 := uploader .Rollback (); err1 != nil {
0 commit comments