Skip to content

Commit 6ce878f

Browse files
committed
added a convenience method
1 parent 2ea5d7c commit 6ce878f

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/main/java/com/cloudbees/jenkins/GitHubRepositoryName.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,18 @@ protected GHRepository adapt(GitHub item) {
9090
};
9191
}
9292

93+
/**
94+
* Variation of {@link #resolve()} method that just returns the first valid repository object.
95+
*
96+
* This is useful if the caller only relies on the read access to the repository and doesn't need to
97+
* walk possible candidates.
98+
*/
99+
public GHRepository resolveOne() {
100+
for (GHRepository r : resolve())
101+
return r;
102+
return null;
103+
}
104+
93105
private <V> Iterator<V> filterNull(Iterator<V> itr) {
94106
return new FilterIterator<V>(itr) {
95107
@Override

0 commit comments

Comments
 (0)