use of org.sonar.server.computation.task.projectanalysis.scm.Changeset in project sonarqube by SonarSource.
the class ScmLineReader method read.
@Override
public void read(DbFileSources.Line.Builder lineBuilder) {
Changeset changeset = scmReport.getChangesetForLine(lineBuilder.getLine());
String author = changeset.getAuthor();
if (author != null) {
lineBuilder.setScmAuthor(author);
}
lineBuilder.setScmRevision(changeset.getRevision());
lineBuilder.setScmDate(changeset.getDate());
updateLatestChange(changeset);
}
use of org.sonar.server.computation.task.projectanalysis.scm.Changeset in project sonarqube by SonarSource.
the class IssueAssignerTest method set_last_committer_when_line_is_bigger_than_changeset_size.
@Test
public void set_last_committer_when_line_is_bigger_than_changeset_size() throws Exception {
addScmUser("john", "John C");
Changeset changeset = Changeset.newChangesetBuilder().setAuthor("john").setDate(123456789L).setRevision("rev-1").build();
scmInfoRepository.setScmInfo(FILE_REF, changeset, changeset);
DefaultIssue issue = new DefaultIssue().setLine(3);
underTest.onIssue(FILE, issue);
assertThat(issue.assignee()).isEqualTo("John C");
}
use of org.sonar.server.computation.task.projectanalysis.scm.Changeset in project sonarqube by SonarSource.
the class IssueCreationDateCalculator method getChangeset.
private static Optional<Changeset> getChangeset(ScmInfo scmInfo, DefaultIssue issue) {
Integer line = issue.getLine();
if (line != null) {
Changeset changesetForLine = scmInfo.getChangesetForLine(line);
if (changesetForLine != null) {
return Optional.of(changesetForLine);
}
}
Changeset latestChangeset = scmInfo.getLatestChangeset();
if (latestChangeset != null) {
return Optional.of(latestChangeset);
}
return Optional.empty();
}
use of org.sonar.server.computation.task.projectanalysis.scm.Changeset in project sonarqube by SonarSource.
the class NewMaintainabilityMeasuresVisitor method initNewDebtRatioCounter.
private void initNewDebtRatioCounter(Counter devCostCounter, Component file, Measure nclocDataMeasure, ScmInfo scmInfo) {
boolean hasDevCost = false;
long lineDevCost = ratingSettings.getDevCost(file.getFileAttributes().getLanguageKey());
for (Integer nclocLineIndex : nclocLineIndexes(nclocDataMeasure)) {
Changeset changeset = scmInfo.getChangesetForLine(nclocLineIndex);
Period period = periodHolder.getPeriod();
if (isLineInPeriod(changeset.getDate(), period)) {
devCostCounter.incrementDevCost(lineDevCost);
hasDevCost = true;
}
}
if (hasDevCost) {
long newDebt = getLongValue(measureRepository.getRawMeasure(file, this.newDebtMetric));
devCostCounter.incrementNewDebt(newDebt);
}
}
use of org.sonar.server.computation.task.projectanalysis.scm.Changeset in project sonarqube by SonarSource.
the class IssueAssignerTest method set_last_committer_when_line_is_null.
@Test
public void set_last_committer_when_line_is_null() throws Exception {
addScmUser("henry", "Henry V");
Changeset changeset1 = Changeset.newChangesetBuilder().setAuthor("john").setDate(123456789L).setRevision("rev-1").build();
// Latest changeset
Changeset changeset2 = Changeset.newChangesetBuilder().setAuthor("henry").setDate(1234567810L).setRevision("rev-2").build();
scmInfoRepository.setScmInfo(FILE_REF, changeset1, changeset2, changeset1);
DefaultIssue issue = new DefaultIssue().setLine(null);
underTest.onIssue(FILE, issue);
assertThat(issue.assignee()).isEqualTo("Henry V");
}
Aggregations