-
Notifications
You must be signed in to change notification settings - Fork 775
Expand file tree
/
Copy pathGHRepository.java
More file actions
3440 lines (3147 loc) · 103 KB
/
GHRepository.java
File metadata and controls
3440 lines (3147 loc) · 103 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* The MIT License
*
* Copyright (c) 2010, Kohsuke Kawaguchi
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.kohsuke.github;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.infradna.tool.bridge_method_injector.WithBridgeMethods;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.lang3.StringUtils;
import org.kohsuke.github.function.InputStreamFunction;
import org.kohsuke.github.internal.EnumUtils;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.WeakHashMap;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import static java.util.Arrays.asList;
import static java.util.Objects.requireNonNull;
// TODO: Auto-generated Javadoc
/**
* A repository on GitHub.
*
* @author Kohsuke Kawaguchi
*/
@SuppressWarnings({ "UnusedDeclaration" })
@SuppressFBWarnings(value = { "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", "UWF_UNWRITTEN_FIELD", "NP_UNWRITTEN_FIELD" },
justification = "JSON API")
public class GHRepository extends GHObject {
/**
* Affiliation of a repository collaborator.
*/
public enum CollaboratorAffiliation {
/** The all. */
ALL,
/** The direct. */
DIRECT,
/** The outside. */
OUTSIDE
}
/**
* The type Contributor.
*/
public static class Contributor extends GHUser {
private int contributions;
/**
* Create default Contributor instance
*/
public Contributor() {
}
/**
* Equals.
*
* @param obj
* the obj
* @return true, if successful
*/
@Override
public boolean equals(Object obj) {
// We ignore contributions in the calculation
return super.equals(obj);
}
/**
* Gets contributions.
*
* @return the contributions
*/
public int getContributions() {
return contributions;
}
/**
* Hash code.
*
* @return the int
*/
@Override
public int hashCode() {
// We ignore contributions in the calculation
return super.hashCode();
}
}
/**
* Sort orders for listing forks.
*/
public enum ForkSort {
/** The newest. */
NEWEST,
/** The oldest. */
OLDEST,
/** The stargazers. */
STARGAZERS
}
/**
* A {@link GHRepositoryBuilder} that allows multiple properties to be updated per request.
*
* Consumer must call {@link #done()} to commit changes.
*/
@BetaApi
public static class Setter extends GHRepositoryBuilder<GHRepository> {
/**
* Instantiates a new setter.
*
* @param repository
* the repository
*/
protected Setter(@Nonnull GHRepository repository) {
super(GHRepository.class, repository.root(), null);
// even when we don't change the name, we need to send it in
// this requirement may be out-of-date, but we do not want to break it
requester.with("name", repository.name);
requester.method("PATCH").withUrlPath(repository.getApiTailUrl(""));
}
}
/**
* A {@link GHRepositoryBuilder} that allows multiple properties to be updated per request.
*
* Consumer must call {@link #done()} to commit changes.
*/
@BetaApi
public static class Updater extends GHRepositoryBuilder<Updater> {
/**
* Instantiates a new updater.
*
* @param repository
* the repository
*/
protected Updater(@Nonnull GHRepository repository) {
super(Updater.class, repository.root(), null);
// even when we don't change the name, we need to send it in
// this requirement may be out-of-date, but we do not want to break it
requester.with("name", repository.name);
requester.method("PATCH").withUrlPath(repository.getApiTailUrl(""));
}
}
/**
* Visibility of a repository.
*/
public enum Visibility {
/** The internal. */
INTERNAL,
/** The private. */
PRIVATE,
/** The public. */
PUBLIC,
/**
* Placeholder for unexpected data values.
*
* This avoids throwing exceptions during data binding or reading when the list of allowed values returned from
* GitHub is expanded.
*
* Do not pass this value to any methods. If this value is returned during a request, check the log output and
* report an issue for the missing value.
*/
UNKNOWN;
/**
* From.
*
* @param value
* the value
* @return the visibility
*/
public static Visibility from(String value) {
return EnumUtils.getNullableEnumOrDefault(Visibility.class, value, Visibility.UNKNOWN);
}
/**
* To string.
*
* @return the string
*/
@Override
public String toString() {
return name().toLowerCase(Locale.ROOT);
}
}
// Only used within listCodeownersErrors().
private static class GHCodeownersErrors {
List<GHCodeownersError> errors;
}
// Only used within listTopics().
private static class Topics {
List<String> names;
}
static class GHRepoPermission {
boolean pull, push, admin;
}
/**
* Read.
*
* @param root
* the root
* @param owner
* the owner
* @param name
* the name
* @return the GH repository
* @throws IOException
* Signals that an I/O exception has occurred.
*/
static GHRepository read(GitHub root, String owner, String name) throws IOException {
return root.createRequest().withUrlPath("/repos/" + owner + '/' + name).fetch(GHRepository.class);
}
private boolean allowForking;
private boolean allowMergeCommit;
private boolean allowRebaseMerge;
private boolean allowSquashMerge;
private Map<String, GHCommit> commits = Collections.synchronizedMap(new WeakHashMap<>());
private boolean compareUsePaginatedCommits;
private String defaultBranch, language;
private boolean deleteBranchOnMerge;
private int forksCount, stargazersCount, watchersCount, size, openIssuesCount, subscribersCount;
private String gitUrl, sshUrl, cloneUrl, svnUrl, mirrorUrl;
private boolean hasIssues, hasWiki, fork, hasDownloads, hasPages, archived, disabled, hasProjects;
private String htmlUrl; // this is the UI
@JsonProperty("private")
private boolean isPrivate;
private Boolean isTemplate;
/*
* The license information makes use of the preview API.
*
* See: https://developer.github.com/v3/licenses/
*/
private GHLicense license;
private Map<Integer, GHMilestone> milestones = Collections.synchronizedMap(new WeakHashMap<>());
private String nodeId, description, homepage, name, fullName;
private GHUser owner; // not fully populated. beware.
@SkipFromToString
private GHRepoPermission permissions;
private String pushedAt;
private GHRepository source, parent;
private GHRepository templateRepository;
private String visibility;
/**
* Create default GHRepository instance
*/
public GHRepository() {
}
/**
* Add collaborators.
*
* @param users
* the users
* @throws IOException
* the io exception
*/
public void addCollaborators(Collection<GHUser> users) throws IOException {
modifyCollaborators(users, "PUT", null);
}
/**
* Add collaborators.
*
* @param users
* the users
* @param permission
* the permission level
* @throws IOException
* the io exception
*/
public void addCollaborators(Collection<GHUser> users, GHOrganization.RepositoryRole permission)
throws IOException {
modifyCollaborators(users, "PUT", permission);
}
/**
* Add collaborators.
*
* @param permission
* the permission level
* @param users
* the users
*
* @throws IOException
* the io exception
*/
public void addCollaborators(GHOrganization.RepositoryRole permission, GHUser... users) throws IOException {
addCollaborators(asList(users), permission);
}
/**
* Add collaborators.
*
* @param users
* the users
* @throws IOException
* the io exception
*/
public void addCollaborators(GHUser... users) throws IOException {
addCollaborators(asList(users));
}
/**
* Add deploy key gh deploy key.
*
* @param title
* the title
* @param key
* the key
* @return the gh deploy key
* @throws IOException
* the io exception
*/
public GHDeployKey addDeployKey(String title, String key) throws IOException {
return addDeployKey(title, key, false);
}
/**
* Add deploy key gh deploy key.
*
* @param title
* the title
* @param key
* the key
* @param readOnly
* read-only ability of the key
* @return the gh deploy key
* @throws IOException
* the io exception
*/
public GHDeployKey addDeployKey(String title, String key, boolean readOnly) throws IOException {
return root().createRequest()
.method("POST")
.with("title", title)
.with("key", key)
.with("read_only", readOnly)
.withUrlPath(getApiTailUrl("keys"))
.fetch(GHDeployKey.class)
.lateBind(this);
}
/**
* Allow private fork.
*
* @param value
* the value
* @throws IOException
* the io exception
*/
public void allowForking(boolean value) throws IOException {
set().allowForking(value);
}
/**
* Allow merge commit.
*
* @param value
* the value
* @throws IOException
* the io exception
*/
public void allowMergeCommit(boolean value) throws IOException {
set().allowMergeCommit(value);
}
/**
* Allow rebase merge.
*
* @param value
* the value
* @throws IOException
* the io exception
*/
public void allowRebaseMerge(boolean value) throws IOException {
set().allowRebaseMerge(value);
}
/**
* Allow squash merge.
*
* @param value
* the value
* @throws IOException
* the io exception
*/
public void allowSquashMerge(boolean value) throws IOException {
set().allowSquashMerge(value);
}
/**
* Will archive and this repository as read-only. When a repository is archived, any operation that can change its
* state is forbidden. This applies symmetrically if trying to unarchive it.
*
* <p>
* When you try to do any operation that modifies a read-only repository, it returns the response:
*
* <pre>
* org.kohsuke.github.HttpException: {
* "message":"Repository was archived so is read-only.",
* "documentation_url":"https://developer.github.com/v3/repos/#edit"
* }
* </pre>
*
* @throws IOException
* In case of any networking error or error from the server.
*/
public void archive() throws IOException {
set().archive();
// Generally would not update this record,
// but doing so here since this will result in any other update actions failing
archived = true;
}
/**
* Create an autolink gh autolink builder.
*
* @return the gh autolink builder
*/
public GHAutolinkBuilder createAutolink() {
return new GHAutolinkBuilder(this);
}
/**
* Create blob gh blob builder.
*
* @return the gh blob builder
*/
public GHBlobBuilder createBlob() {
return new GHBlobBuilder(this);
}
/**
* Creates a check run for a commit.
*
* @param name
* an identifier for the run
* @param headSHA
* the commit hash
* @return a builder which you should customize, then call {@link GHCheckRunBuilder#create}
*/
public @NonNull GHCheckRunBuilder createCheckRun(@NonNull String name, @NonNull String headSHA) {
return new GHCheckRunBuilder(this, name, headSHA);
}
/**
* Create commit gh commit builder.
*
* @return the gh commit builder
*/
public GHCommitBuilder createCommit() {
return new GHCommitBuilder(this);
}
/**
* Create commit status gh commit status.
*
* @param sha1
* the sha 1
* @param state
* the state
* @param targetUrl
* the target url
* @param description
* the description
* @return the gh commit status
* @throws IOException
* the io exception
* @see #createCommitStatus(String, GHCommitState, String, String, String) #createCommitStatus(String,
* GHCommitState,String,String,String)
*/
public GHCommitStatus createCommitStatus(String sha1, GHCommitState state, String targetUrl, String description)
throws IOException {
return createCommitStatus(sha1, state, targetUrl, description, null);
}
/**
* Creates a commit status.
*
* @param sha1
* the sha 1
* @param state
* the state
* @param targetUrl
* Optional parameter that points to the URL that has more details.
* @param description
* Optional short description.
* @param context
* Optional commit status context.
* @return the gh commit status
* @throws IOException
* the io exception
*/
public GHCommitStatus createCommitStatus(String sha1,
GHCommitState state,
String targetUrl,
String description,
String context) throws IOException {
return root().createRequest()
.method("POST")
.with("state", state)
.with("target_url", targetUrl)
.with("description", description)
.with("context", context)
.withUrlPath(String.format("/repos/%s/%s/statuses/%s", getOwnerName(), this.name, sha1))
.fetch(GHCommitStatus.class);
}
/**
* Creates a new content, or update an existing content.
*
* @return the gh content builder
*/
public GHContentBuilder createContent() {
return new GHContentBuilder(this);
}
/**
* Create deployment gh deployment builder.
*
* @param ref
* the ref
* @return the gh deployment builder
*/
public GHDeploymentBuilder createDeployment(String ref) {
return new GHDeploymentBuilder(this, ref);
}
/**
* Create fork gh repository fork builder.
* (https://docs.github.com/en/rest/repos/forks?apiVersion=2022-11-28#create-a-fork)
*
* @return the gh repository fork builder
*/
public GHRepositoryForkBuilder createFork() {
return new GHRepositoryForkBuilder(this);
}
/**
* See https://api.github.com/hooks for possible names and their configuration scheme. TODO: produce type-safe
* binding
*
* @param name
* Type of the hook to be created. See https://api.github.com/hooks for possible names.
* @param config
* The configuration hash.
* @param events
* Can be null. Types of events to hook into.
* @param active
* the active
* @return the gh hook
* @throws IOException
* the io exception
*/
public GHHook createHook(String name, Map<String, String> config, Collection<GHEvent> events, boolean active)
throws IOException {
return GHHooks.repoContext(this, owner).createHook(name, config, events, active);
}
/**
* Create issue gh issue builder.
*
* @param title
* the title
* @return the gh issue builder
*/
public GHIssueBuilder createIssue(String title) {
return new GHIssueBuilder(this, title);
}
/**
* Create label gh label.
*
* @param name
* the name
* @param color
* the color
* @return the gh label
* @throws IOException
* the io exception
*/
public GHLabel createLabel(String name, String color) throws IOException {
return GHLabel.create(this).name(name).color(color).description("").done();
}
/**
* Description is still in preview.
*
* @param name
* the name
* @param color
* the color
* @param description
* the description
* @return gh label
* @throws IOException
* the io exception
*/
public GHLabel createLabel(String name, String color, String description) throws IOException {
return GHLabel.create(this).name(name).color(color).description(description).done();
}
/**
* Create milestone gh milestone.
*
* @param title
* the title
* @param description
* the description
* @return the gh milestone
* @throws IOException
* the io exception
*/
public GHMilestone createMilestone(String title, String description) throws IOException {
return root().createRequest()
.method("POST")
.with("title", title)
.with("description", description)
.withUrlPath(getApiTailUrl("milestones"))
.fetch(GHMilestone.class)
.lateBind(this);
}
/**
* Create a project for this repository.
*
* @param name
* the name
* @param body
* the body
* @return the gh project
* @throws IOException
* the io exception
*/
public GHProject createProject(String name, String body) throws IOException {
return root().createRequest()
.method("POST")
.with("name", name)
.with("body", body)
.withUrlPath(getApiTailUrl("projects"))
.fetch(GHProject.class)
.lateBind(this);
}
/**
* Creates a new pull request.
*
* @param title
* Required. The title of the pull request.
* @param head
* Required. The name of the branch where your changes are implemented. For cross-repository pull
* requests in the same network, namespace head with a user like this: username:branch.
* @param base
* Required. The name of the branch you want your changes pulled into. This should be an existing branch
* on the current repository.
* @param body
* The contents of the pull request. This is the markdown description of a pull request.
* @return the gh pull request
* @throws IOException
* the io exception
*/
public GHPullRequest createPullRequest(String title, String head, String base, String body) throws IOException {
return createPullRequest(title, head, base, body, true);
}
/**
* Creates a new pull request. Maintainer's permissions aware.
*
* @param title
* Required. The title of the pull request.
* @param head
* Required. The name of the branch where your changes are implemented. For cross-repository pull
* requests in the same network, namespace head with a user like this: username:branch.
* @param base
* Required. The name of the branch you want your changes pulled into. This should be an existing branch
* on the current repository.
* @param body
* The contents of the pull request. This is the markdown description of a pull request.
* @param maintainerCanModify
* Indicates whether maintainers can modify the pull request.
* @return the gh pull request
* @throws IOException
* the io exception
*/
public GHPullRequest createPullRequest(String title,
String head,
String base,
String body,
boolean maintainerCanModify) throws IOException {
return createPullRequest(title, head, base, body, maintainerCanModify, false);
}
/**
* Creates a new pull request. Maintainer's permissions and draft aware.
*
* @param title
* Required. The title of the pull request.
* @param head
* Required. The name of the branch where your changes are implemented. For cross-repository pull
* requests in the same network, namespace head with a user like this: username:branch.
* @param base
* Required. The name of the branch you want your changes pulled into. This should be an existing branch
* on the current repository.
* @param body
* The contents of the pull request. This is the markdown description of a pull request.
* @param maintainerCanModify
* Indicates whether maintainers can modify the pull request.
* @param draft
* Indicates whether to create a draft pull request or not.
* @return the gh pull request
* @throws IOException
* the io exception
*/
public GHPullRequest createPullRequest(String title,
String head,
String base,
String body,
boolean maintainerCanModify,
boolean draft) throws IOException {
return root().createRequest()
.method("POST")
.with("title", title)
.with("head", head)
.with("base", base)
.with("body", body)
.with("maintainer_can_modify", maintainerCanModify)
.with("draft", draft)
.withUrlPath(getApiTailUrl("pulls"))
.fetch(GHPullRequest.class)
.wrapUp(this);
}
/**
* Creates a named ref, such as tag, branch, etc.
*
* @param name
* The name of the fully qualified reference (ie: refs/heads/main). If it doesn't start with 'refs' and
* have at least two slashes, it will be rejected.
* @param sha
* The SHA1 value to set this reference to
* @return the gh ref
* @throws IOException
* the io exception
*/
public GHRef createRef(String name, String sha) throws IOException {
return root().createRequest()
.method("POST")
.with("ref", name)
.with("sha", sha)
.withUrlPath(getApiTailUrl("git/refs"))
.fetch(GHRef.class);
}
/**
* Create release gh release builder.
*
* @param tag
* the tag
* @return the gh release builder
*/
public GHReleaseBuilder createRelease(String tag) {
return new GHReleaseBuilder(this, tag);
}
/**
* Set/Update a repository secret
* "https://docs.github.com/rest/reference/actions#create-or-update-a-repository-secret"
*
* @param secretName
* the name of the secret
* @param encryptedValue
* The encrypted value for this secret
* @param publicKeyId
* The id of the Public Key used to encrypt this secret
* @throws IOException
* the io exception
*/
public void createSecret(String secretName, String encryptedValue, String publicKeyId) throws IOException {
root().createRequest()
.method("PUT")
.with("encrypted_value", encryptedValue)
.with("key_id", publicKeyId)
.withUrlPath(getApiTailUrl("actions/secrets") + "/" + secretName)
.send();
}
/**
* Create a tag. See https://developer.github.com/v3/git/tags/#create-a-tag-object
*
* @param tag
* The tag's name.
* @param message
* The tag message.
* @param object
* The SHA of the git object this is tagging.
* @param type
* The type of the object we're tagging: "commit", "tree" or "blob".
* @return The newly created tag.
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public GHTagObject createTag(String tag, String message, String object, String type) throws IOException {
return root().createRequest()
.method("POST")
.with("tag", tag)
.with("message", message)
.with("object", object)
.with("type", type)
.withUrlPath(getApiTailUrl("git/tags"))
.fetch(GHTagObject.class)
.wrap(this);
}
/**
* Create tree gh tree builder.
*
* @return the gh tree builder
*/
public GHTreeBuilder createTree() {
return new GHTreeBuilder(this);
}
/**
* Create a repository variable.
*
* @param name
* the variable name (e.g. test-variable)
* @param value
* the value
* @throws IOException
* the io exception
*/
public void createVariable(String name, String value) throws IOException {
GHRepositoryVariable.create(this).name(name).value(value).done();
}
/**
* Create web hook gh hook.
*
* @param url
* the url
* @return the gh hook
* @throws IOException
* the io exception
*/
public GHHook createWebHook(URL url) throws IOException {
return createWebHook(url, null);
}
/**
* Create web hook gh hook.
*
* @param url
* the url
* @param events
* the events
* @return the gh hook
* @throws IOException
* the io exception
*/
public GHHook createWebHook(URL url, Collection<GHEvent> events) throws IOException {
return createHook("web", Collections.singletonMap("url", url.toExternalForm()), events, true);
}
/**
* Deletes this repository.
*
* @throws IOException
* the io exception
*/
public void delete() throws IOException {
try {
root().createRequest().method("DELETE").withUrlPath(getApiTailUrl("")).send();
} catch (FileNotFoundException x) {
throw (FileNotFoundException) new FileNotFoundException("Failed to delete " + getOwnerName() + "/" + name
+ "; might not exist, or you might need the delete_repo scope in your token: http://stackoverflow.com/a/19327004/12916")
.initCause(x);
}
}
/**
* Delete autolink.
* (https://docs.github.com/en/rest/repos/autolinks?apiVersion=2022-11-28#delete-an-autolink-reference-from-a-repository)
*
* @param autolinkId
* the autolink id
* @throws IOException
* the io exception
*/
public void deleteAutolink(int autolinkId) throws IOException {
root().createRequest()
.method("DELETE")
.withHeader("Accept", "application/vnd.github+json")
.withUrlPath(String.format("/repos/%s/%s/autolinks/%d", getOwnerName(), getName(), autolinkId))
.send();
}
/**
* After pull requests are merged, you can have head branches deleted automatically.
*
* @param value
* the value
* @throws IOException
* the io exception
*/
public void deleteBranchOnMerge(boolean value) throws IOException {
set().deleteBranchOnMerge(value);
}
/**
* Deletes hook.
*
* @param id
* the id
* @throws IOException
* the io exception
*/
public void deleteHook(int id) throws IOException {
GHHooks.repoContext(this, owner).deleteHook(id);
}