@Override
  public void publish(ScannerReportWriter writer) {
    Optional<String> targetBranch = getTargetBranch();
    if (targetBranch.isPresent()) {
      Profiler profiler = Profiler.create(LOG).startInfo(LOG_MSG);
      int count = writeChangedLines(scmConfiguration.provider(), writer, targetBranch.get());
      LOG.debug("SCM reported changed lines for {} {} in the branch", count, ScannerUtils.pluralize("file", count));
      profiler.stopInfo();
    }
  }
@Test
  public void write_changed_files() {
    DefaultInputFile fileWithChangedLines = createInputFile("path1", "l1\nl2\nl3\n");
    DefaultInputFile fileNotReturned = createInputFile("path2", "l1\nl2\nl3\n");
    DefaultInputFile fileWithoutChangedLines = createInputFile("path3", "l1\nl2\nl3\n");

    Set<Path> paths = new HashSet<>(Arrays.asList(BASE_DIR.resolve("path1"), BASE_DIR.resolve("path2"), BASE_DIR.resolve("path3")));
    Set<Integer> lines = new HashSet<>(Arrays.asList(1, 10));
    when(provider.branchChangedLines(TARGET_BRANCH, BASE_DIR, paths))
      .thenReturn(ImmutableMap.of(BASE_DIR.resolve("path1"), lines, BASE_DIR.resolve("path3"), Collections.emptySet()));
    when(inputComponentStore.allChangedFilesToPublish()).thenReturn(Arrays.asList(fileWithChangedLines, fileNotReturned, fileWithoutChangedLines));

    publisher.publish(writer);

    assertPublished(fileWithChangedLines, new HashSet<>(Arrays.asList(1, 10)));
    assertPublished(fileWithoutChangedLines, Collections.emptySet());
    assertPublished(fileNotReturned, Collections.emptySet());

    assumeThat(logTester.logs()).contains("File '/root/path2' was detected as changed but without having changed lines");
  }