Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove icon from reference link as it is broken in core again #1697

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import hudson.model.Run;

import io.jenkins.plugins.forensics.reference.ReferenceBuild;
import io.jenkins.plugins.util.QualityGateStatus;

/**
Expand Down Expand Up @@ -155,6 +156,20 @@ public boolean isResetQualityGateVisible() {
return analysisResult.getReferenceBuild();
}

/**
* Renders the reference build as an HTML link.
*
* @return the reference build
* @see #getReferenceBuild()
*/
@SuppressWarnings("unused") // Called by jelly view
public String getReferenceBuildLink() {
return facade.getReferenceLink(
analysisResult.getReferenceBuild()
.map(Run::getExternalizableId)
.orElse("-"));
}

public boolean isZeroIssuesHighscore() {
return getNoIssuesSinceBuild() > 0 && analysisResult.getOwner().getNumber() > getNoIssuesSinceBuild();
}
Expand All @@ -175,5 +190,9 @@ static class LabelProviderFactoryFacade {
public StaticAnalysisLabelProvider get(final String id) {
return new LabelProviderFactory().create(id);
}

public String getReferenceLink(final String id) {
return ReferenceBuild.getReferenceBuildLink(id);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
<j:set var="r" value="${s.referenceBuild.get()}"/>
<li>
Reference build:
<t:buildLink jobName="${r.parent.displayName}" job="${r.parent}" number="${r.number}"/>
<j:out value="${s.referenceBuildLink}"/>
</li>
</j:if>
<j:if test="${s.qualityGateStatus.name() != 'INACTIVE'}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ void shouldCreateTitleMessageIfThereAreNoWarnings() {
.hasAnalysesCount(1)
.hasQualityGateStatus(QualityGateStatus.INACTIVE)
.hasReferenceBuild(Optional.empty())
.hasReferenceBuildLink("-")
.isNotZeroIssuesHighscore()
.hasNoErrors()
.isNotResetQualityGateVisible();
Expand Down Expand Up @@ -157,14 +158,16 @@ void shouldUseReferenceBuildOfResult() {

Run<?, ?> run = mock(Run.class);
when(run.getFullDisplayName()).thenReturn("Job #15");
when(run.getExternalizableId()).thenReturn("#15");
when(run.getUrl()).thenReturn("job/my-job/15");
when(analysisResult.getReferenceBuild()).thenReturn(Optional.of(run));

when(analysisResult.getBuild()).thenReturn(new Build(2));

SummaryModel summary = createSummary(analysisResult);

assertThat(summary).hasReferenceBuild(Optional.of(run));
assertThat(summary).hasReferenceBuild(Optional.of(run))
.hasReferenceBuildLink("#reference-link");
}

@Test
Expand Down Expand Up @@ -209,6 +212,8 @@ private SummaryModel createSummary(final AnalysisResult analysisResult) {
when(facade.get(CHECK_STYLE_ID)).thenReturn(checkStyleLabelProvider);
StaticAnalysisLabelProvider pmdLabelProvider = new StaticAnalysisLabelProvider(PMD_ID, PMD_NAME);
when(facade.get(PMD_ID)).thenReturn(pmdLabelProvider);
when(facade.getReferenceLink("-")).thenReturn("-");
when(facade.getReferenceLink(startsWith("#"))).thenReturn("#reference-link");

SummaryModel summaryModel = new SummaryModel(new StaticAnalysisLabelProvider(TOOL_ID, TOOL_NAME), analysisResult, facade);
summaryModel.setResetQualityGateCommand(createResetReferenceAction(false));
Expand Down
Loading