File tree Expand file tree Collapse file tree 2 files changed +20
-16
lines changed
core/src/main/java/hudson/model Expand file tree Collapse file tree 2 files changed +20
-16
lines changed Original file line number Diff line number Diff line change @@ -994,19 +994,8 @@ public RunT getLastCompletedBuild() {
994994 * if not enough builds satisfying the threshold have been found. Never null.
995995 */
996996 public List <RunT > getLastBuildsOverThreshold (int numberOfBuilds , Result threshold ) {
997-
998- List <RunT > result = new ArrayList <>(numberOfBuilds );
999-
1000997 RunT r = getLastBuild ();
1001- while (r != null && result .size () < numberOfBuilds ) {
1002- if (!r .isBuilding () &&
1003- (r .getResult () != null && r .getResult ().isBetterOrEqualTo (threshold ))) {
1004- result .add (r );
1005- }
1006- r = r .getPreviousBuild ();
1007- }
1008-
1009- return result ;
998+ return r .getBuildsOverThreshold (numberOfBuilds , threshold );
1010999 }
10111000
10121001 /**
Original file line number Diff line number Diff line change @@ -953,17 +953,32 @@ protected void dropLinks() {
953953 * @since 1.383
954954 */
955955 public @ Nonnull List <RunT > getPreviousBuildsOverThreshold (int numberOfBuilds , @ Nonnull Result threshold ) {
956- List <RunT > builds = new ArrayList <>(numberOfBuilds );
957-
958956 RunT r = getPreviousBuild ();
957+ return r .getBuildsOverThreshold (numberOfBuilds , threshold );
958+ }
959+
960+ /**
961+ * Returns the last {@code numberOfBuilds} builds with a build result ≥ {@code threshold}.
962+ *
963+ * @param numberOfBuilds the desired number of builds
964+ * @param threshold the build result threshold
965+ * @return a list with the builds (youngest build first).
966+ * May be smaller than 'numberOfBuilds' or even empty
967+ * if not enough builds satisfying the threshold have been found. Never null.
968+ * @since TODO
969+ */
970+ protected @ Nonnull List <RunT > getBuildsOverThreshold (int numberOfBuilds , @ Nonnull Result threshold ) {
971+ List <RunT > builds = new ArrayList <>(numberOfBuilds );
972+
973+ RunT r = _this ();
959974 while (r != null && builds .size () < numberOfBuilds ) {
960- if (!r .isBuilding () &&
975+ if (!r .isBuilding () &&
961976 (r .getResult () != null && r .getResult ().isBetterOrEqualTo (threshold ))) {
962977 builds .add (r );
963978 }
964979 r = r .getPreviousBuild ();
965980 }
966-
981+
967982 return builds ;
968983 }
969984
You can’t perform that action at this time.
0 commit comments