From 9775954aff95f4e844693fb9b100b2ce4b017d5d Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Mon, 13 Apr 2015 16:45:38 -0700 Subject: [PATCH] Massaging the PR. - need to retrieve the object in full to have all the fields properly populated - documentation fix, as this method points to the root of the forking chain, not just an upstream. --- .../java/org/kohsuke/github/GHRepository.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index d615c2a47..67c93848d 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -1109,16 +1109,20 @@ public class GHRepository extends GHObject { return list; } - /** - * Forked repositories have a 'source' attribute that specifies the repository they were forked - * from. - * @return The GHRepository instance from the fork source, or null if this - * GHRepository isn't a fork. - */ - public GHRepository getSource() { - return source; - } - + /** + * Forked repositories have a 'source' attribute that specifies the ultimate source of the forking chain. + * + * @return + * {@link GHRepository} that points to the root repository where this repository is forked + * (indirectly or directly) from. Otherwise null. + */ + public GHRepository getSource() throws IOException { + if (source == null) return null; + if (source.root == null) + source = root.getRepository(source.getFullName()); + return source; + } + /** * Subscribes to this repository to get notifications. */