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