Skip to content
This repository was archived by the owner on Jul 31, 2025. It is now read-only.

Commit 9775954

Browse files
committed
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.
1 parent b926b6c commit 9775954

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

src/main/java/org/kohsuke/github/GHRepository.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,16 +1109,20 @@ public List<GHDeployKey> getDeployKeys() throws IOException{
11091109
return list;
11101110
}
11111111

1112-
/**
1113-
* Forked repositories have a 'source' attribute that specifies the repository they were forked
1114-
* from.
1115-
* @return The GHRepository instance from the fork source, or null if this
1116-
* GHRepository isn't a fork.
1117-
*/
1118-
public GHRepository getSource() {
1119-
return source;
1120-
}
1121-
1112+
/**
1113+
* Forked repositories have a 'source' attribute that specifies the ultimate source of the forking chain.
1114+
*
1115+
* @return
1116+
* {@link GHRepository} that points to the root repository where this repository is forked
1117+
* (indirectly or directly) from. Otherwise null.
1118+
*/
1119+
public GHRepository getSource() throws IOException {
1120+
if (source == null) return null;
1121+
if (source.root == null)
1122+
source = root.getRepository(source.getFullName());
1123+
return source;
1124+
}
1125+
11221126
/**
11231127
* Subscribes to this repository to get notifications.
11241128
*/

0 commit comments

Comments
 (0)