@@ -651,7 +651,14 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
651651 })
652652 }
653653
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 {
655662 if * opts .HasIssues {
656663 // We don't currently allow setting individual issue settings through the API,
657664 // only can enable/disable issues, so when enabling issues,
@@ -677,7 +684,14 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
677684 }
678685 }
679686
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 {
681695 if * opts .HasWiki {
682696 // We don't currently allow setting individual wiki settings through the API,
683697 // only can enable/disable the wiki, so when enabling the wiki,
@@ -692,7 +706,12 @@ func updateRepoUnits(ctx *context.APIContext, opts api.EditRepoOption) error {
692706 }
693707 }
694708
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 {
696715 if * opts .HasPullRequests {
697716 // We do allow setting individual PR settings through the API, so
698717 // we get the config settings and then set them
0 commit comments