Search in sources :

Example 1 with Changeset

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);
}
Also used : Changeset(org.sonar.server.computation.task.projectanalysis.scm.Changeset)

Example 2 with 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");
}
Also used : DefaultIssue(org.sonar.core.issue.DefaultIssue) Changeset(org.sonar.server.computation.task.projectanalysis.scm.Changeset) Test(org.junit.Test)

Example 3 with Changeset

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();
}
Also used : Changeset(org.sonar.server.computation.task.projectanalysis.scm.Changeset)

Example 4 with Changeset

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);
    }
}
Also used : Period(org.sonar.server.computation.task.projectanalysis.period.Period) Changeset(org.sonar.server.computation.task.projectanalysis.scm.Changeset)

Example 5 with 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_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");
}
Also used : DefaultIssue(org.sonar.core.issue.DefaultIssue) Changeset(org.sonar.server.computation.task.projectanalysis.scm.Changeset) Test(org.junit.Test)

Aggregations

Changeset (org.sonar.server.computation.task.projectanalysis.scm.Changeset)8 Test (org.junit.Test)3 DefaultIssue (org.sonar.core.issue.DefaultIssue)2 ScmInfo (org.sonar.server.computation.task.projectanalysis.scm.ScmInfo)2 Period (org.sonar.server.computation.task.projectanalysis.period.Period)1 ScmInfoImpl (org.sonar.server.computation.task.projectanalysis.scm.ScmInfoImpl)1