@@ -43,6 +43,21 @@ public class GHBranchProtectionBuilder {
43
43
includeAdmins (false );
44
44
}
45
45
46
+ /**
47
+ * Add required checks gh branch protection builder.
48
+ *
49
+ * @param checks
50
+ * the checks
51
+ * @return the gh branch protection builder
52
+ */
53
+ public GHBranchProtectionBuilder addRequiredChecksWithAppIds (Collection <GHBranchProtection .Check > checks ) {
54
+ if (!(getStatusChecks () instanceof StatusChecksWithAppId )) {
55
+ statusChecks = new StatusChecksWithAppId ();
56
+ }
57
+ ((StatusChecksWithAppId ) getStatusChecks ()).checks .addAll (checks );
58
+ return this ;
59
+ }
60
+
46
61
/**
47
62
* Add required checks gh branch protection builder.
48
63
*
@@ -51,7 +66,10 @@ public class GHBranchProtectionBuilder {
51
66
* @return the gh branch protection builder
52
67
*/
53
68
public GHBranchProtectionBuilder addRequiredChecks (Collection <String > checks ) {
54
- getStatusChecks ().contexts .addAll (checks );
69
+ if (!(getStatusChecks () instanceof StatusChecksDeprecated )) {
70
+ statusChecks = new StatusChecksDeprecated ();
71
+ }
72
+ ((StatusChecksDeprecated ) getStatusChecks ()).contexts .addAll (checks );
55
73
return this ;
56
74
}
57
75
@@ -67,6 +85,18 @@ public GHBranchProtectionBuilder addRequiredChecks(String... checks) {
67
85
return this ;
68
86
}
69
87
88
+ /**
89
+ * Add required checks gh branch protection builder.
90
+ *
91
+ * @param checks
92
+ * the checks
93
+ * @return the gh branch protection builder
94
+ */
95
+ public GHBranchProtectionBuilder addRequiredChecksWithAppIds (GHBranchProtection .Check ... checks ) {
96
+ addRequiredChecksWithAppIds (Arrays .asList (checks ));
97
+ return this ;
98
+ }
99
+
70
100
/**
71
101
* Allow deletion of the protected branch.
72
102
*
@@ -532,7 +562,7 @@ private Restrictions getRestrictions() {
532
562
533
563
private StatusChecks getStatusChecks () {
534
564
if (statusChecks == null ) {
535
- statusChecks = new StatusChecks ();
565
+ statusChecks = new StatusChecksWithAppId ();
536
566
}
537
567
return statusChecks ;
538
568
}
@@ -546,8 +576,15 @@ private static class Restrictions {
546
576
private Set <String > users = new HashSet <String >();
547
577
}
548
578
549
- private static class StatusChecks {
550
- final List <String > contexts = new ArrayList <String >();
579
+ private static abstract class StatusChecks {
551
580
boolean strict ;
552
581
}
582
+
583
+ private static class StatusChecksWithAppId extends StatusChecks {
584
+ final List <GHBranchProtection .Check > checks = new ArrayList <>();
585
+ }
586
+
587
+ private static class StatusChecksDeprecated extends StatusChecks {
588
+ final List <String > contexts = new ArrayList <>();
589
+ }
553
590
}
0 commit comments