提交 7025cf34 编写于 作者: C Christoph Kutzinski

There's no reason why ResuldTrend shouldn't be usable for Run, too

上级 2af3b0d3
......@@ -100,7 +100,20 @@ public enum ResultTrend {
* @return the result trend
*/
public static ResultTrend getResultTrend(AbstractBuild<?, ?> build) {
Result result = build.getResult();
return getResultTrend((Run<?,?>)build);
}
/**
* Returns the result trend of a run.
*
* @param run the current run
* @return the result trend
*
* @since 1.441
*/
public static ResultTrend getResultTrend(Run<?, ?> run) {
Result result = run.getResult();
if (result == Result.ABORTED) {
return ABORTED;
......@@ -109,14 +122,14 @@ public enum ResultTrend {
}
if (result == Result.SUCCESS) {
if (isFix(build)) {
if (isFix(run)) {
return FIXED;
} else {
return SUCCESS;
}
}
AbstractBuild<?, ?> previousBuild = getPreviousNonAbortedBuild(build);
Run<?, ?> previousBuild = getPreviousNonAbortedBuild(run);
if (result == Result.UNSTABLE) {
if (previousBuild == null) {
return UNSTABLE;
......@@ -138,15 +151,15 @@ public enum ResultTrend {
}
}
throw new IllegalArgumentException("Unknown result: '" + result + "' for build: " + build);
throw new IllegalArgumentException("Unknown result: '" + result + "' for build: " + run);
}
/**
* Returns the previous 'not aborted' build (i.e. ignores ABORTED and NOT_BUILT builds)
* or null.
*/
private static AbstractBuild<?, ?> getPreviousNonAbortedBuild(AbstractBuild<?, ?> build) {
AbstractBuild<?, ?> previousBuild = build.getPreviousBuild();
private static Run<?, ?> getPreviousNonAbortedBuild(Run<?, ?> build) {
Run<?, ?> previousBuild = build.getPreviousBuild();
while (previousBuild != null) {
if (previousBuild.getResult() == null
|| previousBuild.getResult() == Result.ABORTED
......@@ -166,12 +179,12 @@ public enum ResultTrend {
* 'failed' and/or 'unstable' builds.
* Ignores 'aborted' and 'not built' builds.
*/
private static boolean isFix(AbstractBuild<?, ?> build) {
private static boolean isFix(Run<?, ?> build) {
if (build.getResult() != Result.SUCCESS) {
return false;
}
AbstractBuild<?, ?> previousBuild = getPreviousNonAbortedBuild(build);
Run<?, ?> previousBuild = getPreviousNonAbortedBuild(build);
if (previousBuild != null) {
return previousBuild.getResult().isWorseThan(Result.SUCCESS);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册