@@ -790,6 +790,26 @@ public GHRef[] getRefs() throws IOException {
790
790
return GHRef .wrap (root .retrieve ().to (String .format ("/repos/%s/%s/git/refs" , getOwnerName (), name ), GHRef [].class ), root );
791
791
}
792
792
793
+
794
+ /**
795
+ * Retrieves all refs for the github repository.
796
+ *
797
+ * @return paged iterable of all refs
798
+ * @throws IOException on failure communicating with GitHub, potentially due to an invalid ref type being requested
799
+ */
800
+ public PagedIterable <GHRef > listRefs () throws IOException {
801
+ final String url = String .format ("/repos/%s/%s/git/refs" , getOwnerName (), name );
802
+ return new PagedIterable <GHRef >() {
803
+ public PagedIterator <GHRef > _iterator (int pageSize ) {
804
+ return new PagedIterator <GHRef >(root .retrieve ().asIterator (url , GHRef [].class , pageSize )) {
805
+ protected void wrapUp (GHRef [] page ) {
806
+ // no-op
807
+ }
808
+ };
809
+ }
810
+ };
811
+ }
812
+
793
813
/**
794
814
* Retrieves all refs of the given type for the current GitHub repository.
795
815
* @param refType the type of reg to search for e.g. <tt>tags</tt> or <tt>commits</tt>
@@ -799,6 +819,27 @@ public GHRef[] getRefs() throws IOException {
799
819
public GHRef [] getRefs (String refType ) throws IOException {
800
820
return GHRef .wrap (root .retrieve ().to (String .format ("/repos/%s/%s/git/refs/%s" , getOwnerName (), name , refType ), GHRef [].class ),root );
801
821
}
822
+
823
+ /**
824
+ * Retrieves all refs of the given type for the current GitHub repository.
825
+ *
826
+ * @param refType the type of reg to search for e.g. <tt>tags</tt> or <tt>commits</tt>
827
+ * @return paged iterable of all refs of the specified type
828
+ * @throws IOException on failure communicating with GitHub, potentially due to an invalid ref type being requested
829
+ */
830
+ public PagedIterable <GHRef > listRefs (String refType ) throws IOException {
831
+ final String url = String .format ("/repos/%s/%s/git/refs/%s" , getOwnerName (), name , refType );
832
+ return new PagedIterable <GHRef >() {
833
+ public PagedIterator <GHRef > _iterator (int pageSize ) {
834
+ return new PagedIterator <GHRef >(root .retrieve ().asIterator (url , GHRef [].class , pageSize )) {
835
+ protected void wrapUp (GHRef [] page ) {
836
+ // no-op
837
+ }
838
+ };
839
+ }
840
+ };
841
+ }
842
+
802
843
/**
803
844
* Retrive a ref of the given type for the current GitHub repository.
804
845
*
@@ -816,6 +857,18 @@ public GHRef getRef(String refName) throws IOException {
816
857
refName = refName .replaceAll ("#" , "%23" );
817
858
return root .retrieve ().to (String .format ("/repos/%s/%s/git/refs/%s" , getOwnerName (), name , refName ), GHRef .class ).wrap (root );
818
859
}
860
+
861
+ /**
862
+ * Returns the <strong>annotated</strong> tag object. Only valid if the {@link GHRef#getObject()} has a
863
+ * {@link GHRef.GHObject#getType()} of {@code tag}.
864
+ *
865
+ * @param sha the sha of the tag object
866
+ * @return the annotated tag object
867
+ */
868
+ public GHTagObject getTagObject (String sha ) throws IOException {
869
+ return root .retrieve ().to (getApiTailUrl ("git/tags/" + sha ), GHTagObject .class ).wrap (this );
870
+ }
871
+
819
872
/**
820
873
* Retrive a tree of the given type for the current GitHub repository.
821
874
*
0 commit comments