@@ -651,7 +651,14 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
651
651
})
652
652
}
653
653
654
- if opts .HasIssues != nil {
654
+ if opts .HasIssues == nil {
655
+ // If HasIssues setting not touched, rewrite existing repo unit
656
+ if unit , err := repo .GetUnit (models .UnitTypeIssues ); err == nil {
657
+ units = append (units , * unit )
658
+ } else if unit , err := repo .GetUnit (models .UnitTypeExternalTracker ); err == nil {
659
+ units = append (units , * unit )
660
+ }
661
+ } else {
655
662
if * opts .HasIssues {
656
663
// We don't currently allow setting individual issue settings through the API,
657
664
// only can enable/disable issues, so when enabling issues,
@@ -677,7 +684,14 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
677
684
}
678
685
}
679
686
680
- if opts .HasWiki != nil {
687
+ if opts .HasWiki == nil {
688
+ // If HasWiki setting not touched, rewrite existing repo unit
689
+ if unit , err := repo .GetUnit (models .UnitTypeWiki ); err == nil {
690
+ units = append (units , * unit )
691
+ } else if unit , err := repo .GetUnit (models .UnitTypeExternalWiki ); err == nil {
692
+ units = append (units , * unit )
693
+ }
694
+ } else {
681
695
if * opts .HasWiki {
682
696
// We don't currently allow setting individual wiki settings through the API,
683
697
// only can enable/disable the wiki, so when enabling the wiki,
@@ -692,7 +706,12 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
692
706
}
693
707
}
694
708
695
- if opts .HasPullRequests != nil {
709
+ if opts .HasPullRequests == nil {
710
+ // If HasPullRequest setting not touched, rewrite existing repo unit
711
+ if unit , err := repo .GetUnit (models .UnitTypePullRequests ); err == nil {
712
+ units = append (units , * unit )
713
+ }
714
+ } else {
696
715
if * opts .HasPullRequests {
697
716
// We do allow setting individual PR settings through the API, so
698
717
// we get the config settings and then set them
0 commit comments