aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src/main/java/org/sonar/scm
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-scanner-engine/src/main/java/org/sonar/scm')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scm/git/GitScmProvider.java22
1 files changed, 13 insertions, 9 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scm/git/GitScmProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scm/git/GitScmProvider.java
index f728b2be2ac..c91cf055ced 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scm/git/GitScmProvider.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scm/git/GitScmProvider.java
@@ -59,6 +59,7 @@ import org.sonar.api.utils.MessageException;
import org.sonar.api.utils.System2;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
+import org.sonar.scanner.bootstrap.ScannerWsClient;
public class GitScmProvider extends ScmProvider {
@@ -68,12 +69,14 @@ public class GitScmProvider extends ScmProvider {
private final AnalysisWarnings analysisWarnings;
private final GitIgnoreCommand gitIgnoreCommand;
private final System2 system2;
+ private final String documentationLink;
- public GitScmProvider(JGitBlameCommand jgitBlameCommand, AnalysisWarnings analysisWarnings, GitIgnoreCommand gitIgnoreCommand, System2 system2) {
+ public GitScmProvider(JGitBlameCommand jgitBlameCommand, AnalysisWarnings analysisWarnings, GitIgnoreCommand gitIgnoreCommand, System2 system2, ScannerWsClient client) {
this.jgitBlameCommand = jgitBlameCommand;
this.analysisWarnings = analysisWarnings;
this.gitIgnoreCommand = gitIgnoreCommand;
this.system2 = system2;
+ this.documentationLink = client.baseUrl() + "/documentation/analysis/scm-integration/";
}
@Override
@@ -103,10 +106,7 @@ public class GitScmProvider extends ScmProvider {
try (Repository repo = buildRepo(rootBaseDir)) {
Ref targetRef = resolveTargetRef(targetBranchName, repo);
if (targetRef == null) {
- analysisWarnings.addUnique(String.format(COULD_NOT_FIND_REF
- + ". You may see unexpected issues and changes. "
- + "Please make sure to fetch this ref before pull request analysis and refer to"
- + " <a href=\"/documentation/analysis/scm-integration/\" target=\"_blank\">the documentation</a>.", targetBranchName));
+ addWarningTargetNotFound(targetBranchName);
return null;
}
@@ -148,10 +148,7 @@ public class GitScmProvider extends ScmProvider {
try (Repository repo = buildRepo(projectBaseDir)) {
Ref targetRef = resolveTargetRef(targetBranchName, repo);
if (targetRef == null) {
- analysisWarnings.addUnique(String.format(COULD_NOT_FIND_REF
- + ". You may see unexpected issues and changes. "
- + "Please make sure to fetch this ref before pull request analysis"
- + " and refer to <a href=\"/documentation/analysis/scm-integration/\" target=\"_blank\">the documentation</a>.", targetBranchName));
+ addWarningTargetNotFound(targetBranchName);
return null;
}
@@ -181,6 +178,13 @@ public class GitScmProvider extends ScmProvider {
return null;
}
+ private void addWarningTargetNotFound(String targetBranchName) {
+ analysisWarnings.addUnique(String.format(COULD_NOT_FIND_REF
+ + ". You may see unexpected issues and changes. "
+ + "Please make sure to fetch this ref before pull request analysis and refer to"
+ + " <a href=\"%s\" target=\"_blank\">the documentation</a>.", targetBranchName, documentationLink));
+ }
+
private void collectChangedLines(Repository repo, RevCommit mergeBaseCommit, Map<Path, Set<Integer>> changedLines, Path changedFile) {
ChangedLinesComputer computer = new ChangedLinesComputer();