diff options
author | Lukasz Jarocki <lukasz.jarocki@sonarsource.com> | 2022-10-31 12:25:54 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-11-01 20:03:09 +0000 |
commit | b0be5da0c49b74538dbce98014298a104d4ac5b0 (patch) | |
tree | 6a9b4734fefe01a34ef2b45336276be4fafa1483 /sonar-scanner-engine | |
parent | b309ce1704e490af7daef2a0d0ab1bbba8c930b8 (diff) | |
download | sonarqube-b0be5da0c49b74538dbce98014298a104d4ac5b0.tar.gz sonarqube-b0be5da0c49b74538dbce98014298a104d4ac5b0.zip |
SONAR-17524 changing default branch name for projects
Diffstat (limited to 'sonar-scanner-engine')
6 files changed, 16 insertions, 16 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/ProjectBranches.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/ProjectBranches.java index d9ed8063cc8..09236b076a4 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/ProjectBranches.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/branch/ProjectBranches.java @@ -32,7 +32,7 @@ import javax.annotation.concurrent.Immutable; @Immutable public class ProjectBranches { // matches server-side default when creating a project. See BranchDto#DEFAULT_MAIN_BRANCH_NAME - private static final String DEFAULT_MAIN_BRANCH_NAME = "master"; + private static final String DEFAULT_MAIN_BRANCH_NAME = "main"; private final Map<String, BranchInfo> branches; private final String defaultBranchName; diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/branch/BranchMediumTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/branch/BranchMediumTest.java index 83a5bfb888f..52f940f527a 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/branch/BranchMediumTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/mediumtest/branch/BranchMediumTest.java @@ -111,7 +111,7 @@ public class BranchMediumTest { public void shouldSkipSensorForUnchangedFilesOnPr() throws Exception { AnalysisResult result = getResult(tester .setBranchName("myBranch") - .setBranchTarget("master") + .setBranchTarget("main") .setBranchType(BranchType.PULL_REQUEST)); final DefaultInputFile file = (DefaultInputFile) result.inputFile(FILE_PATH); @@ -125,7 +125,7 @@ public class BranchMediumTest { public void shouldNotSkipSensorForUnchangedFilesOnBranch() throws Exception { AnalysisResult result = getResult(tester .setBranchName("myBranch") - .setBranchTarget("master") + .setBranchTarget("main") .setBranchType(BranchType.BRANCH)); final DefaultInputFile file = (DefaultInputFile) result.inputFile(FILE_PATH); diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/DefaultNewCodePeriodLoaderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/DefaultNewCodePeriodLoaderTest.java index 63766950563..39d98c404e9 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/DefaultNewCodePeriodLoaderTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/DefaultNewCodePeriodLoaderTest.java @@ -47,7 +47,7 @@ public class DefaultNewCodePeriodLoaderTest { } private void prepareCallWithResults() throws IOException { - WsTestUtil.mockStream(wsClient, createResponse(NewCodePeriods.NewCodePeriodType.REFERENCE_BRANCH, "master")); + WsTestUtil.mockStream(wsClient, createResponse(NewCodePeriods.NewCodePeriodType.REFERENCE_BRANCH, "main")); } private InputStream createResponse(NewCodePeriods.NewCodePeriodType type, String value) throws IOException { diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/ReferenceBranchSupplierTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/ReferenceBranchSupplierTest.java index 3b51bd63d61..1b270781d3d 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/ReferenceBranchSupplierTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/ReferenceBranchSupplierTest.java @@ -64,16 +64,16 @@ public class ReferenceBranchSupplierTest { public void get_returns_reference_branch_when_set() { when(branchConfiguration.branchType()).thenReturn(BranchType.BRANCH); when(branchConfiguration.branchName()).thenReturn(BRANCH_KEY); - when(newCodePeriodLoader.load(PROJECT_KEY, BRANCH_KEY)).thenReturn(createResponse(NewCodePeriods.NewCodePeriodType.REFERENCE_BRANCH, "master")); + when(newCodePeriodLoader.load(PROJECT_KEY, BRANCH_KEY)).thenReturn(createResponse(NewCodePeriods.NewCodePeriodType.REFERENCE_BRANCH, "main")); - assertThat(referenceBranchSupplier.get()).isEqualTo("master"); + assertThat(referenceBranchSupplier.get()).isEqualTo("main"); } @Test public void get_uses_scanner_property_with_higher_priority() { when(branchConfiguration.branchType()).thenReturn(BranchType.BRANCH); when(branchConfiguration.branchName()).thenReturn(BRANCH_KEY); - when(newCodePeriodLoader.load(PROJECT_KEY, BRANCH_KEY)).thenReturn(createResponse(NewCodePeriods.NewCodePeriodType.REFERENCE_BRANCH, "master")); + when(newCodePeriodLoader.load(PROJECT_KEY, BRANCH_KEY)).thenReturn(createResponse(NewCodePeriods.NewCodePeriodType.REFERENCE_BRANCH, "main")); when(configuration.get("sonar.newCode.referenceBranch")).thenReturn(Optional.of("master2")); @@ -107,9 +107,9 @@ public class ReferenceBranchSupplierTest { when(branchConfiguration.branchType()).thenReturn(BranchType.BRANCH); when(branchConfiguration.branchName()).thenReturn(null); when(projectBranches.defaultBranchName()).thenReturn("default"); - when(newCodePeriodLoader.load(PROJECT_KEY, "default")).thenReturn(createResponse(NewCodePeriods.NewCodePeriodType.REFERENCE_BRANCH, "master")); + when(newCodePeriodLoader.load(PROJECT_KEY, "default")).thenReturn(createResponse(NewCodePeriods.NewCodePeriodType.REFERENCE_BRANCH, "main")); - assertThat(referenceBranchSupplier.get()).isEqualTo("master"); + assertThat(referenceBranchSupplier.get()).isEqualTo("main"); } @Test diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/branch/ProjectBranchesTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/branch/ProjectBranchesTest.java index 0c90cc46922..fcf85abca29 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/branch/ProjectBranchesTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/branch/ProjectBranchesTest.java @@ -70,6 +70,6 @@ public class ProjectBranchesTest { public void isEmpty() { assertThat(underTest.isEmpty()).isFalse(); assertThat(new ProjectBranches(Collections.emptyList()).isEmpty()).isTrue(); - assertThat(new ProjectBranches(Collections.emptyList()).defaultBranchName()).isEqualTo("master"); + assertThat(new ProjectBranches(Collections.emptyList()).defaultBranchName()).isEqualTo("main"); } } diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scm/git/GitScmProviderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scm/git/GitScmProviderTest.java index e75152cdb74..2a5252d7603 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scm/git/GitScmProviderTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scm/git/GitScmProviderTest.java @@ -164,7 +164,7 @@ public class GitScmProviderTest { git.rm().addFilepattern(fileName).call(); commit(renamedName); - Set<Path> files = newScmProvider().branchChangedFiles("master", worktree); + Set<Path> files = newScmProvider().branchChangedFiles("main", worktree); // no shared history, so no diff assertThat(files).isNull(); @@ -243,7 +243,7 @@ public class GitScmProviderTest { Repository repo = FileRepositoryBuilder.create(worktree.resolve(".git").toFile()); git = new Git(repo); - assertThat(newScmProvider().branchChangedFiles("master", worktree)).isNull(); + assertThat(newScmProvider().branchChangedFiles("main", worktree)).isNull(); } @Test @@ -375,7 +375,7 @@ public class GitScmProviderTest { git.checkout().setOrphan(true).setName("b1").call(); createAndCommitFile("file-b1.xoo"); - Map<Path, Set<Integer>> changedLines = newScmProvider().branchChangedLines("master", worktree, Collections.singleton(Paths.get(""))); + Map<Path, Set<Integer>> changedLines = newScmProvider().branchChangedLines("main", worktree, Collections.singleton(Paths.get(""))); assertThat(changedLines).isNull(); } @@ -476,7 +476,7 @@ public class GitScmProviderTest { Repository repo = FileRepositoryBuilder.create(worktree.resolve(".git").toFile()); git = new Git(repo); - assertThat(newScmProvider().branchChangedLines("master", worktree, Collections.singleton(Paths.get("file")))).isNull(); + assertThat(newScmProvider().branchChangedLines("main", worktree, Collections.singleton(Paths.get("file")))).isNull(); } /** @@ -602,14 +602,14 @@ public class GitScmProviderTest { @Test public void branchChangedFiles_should_throw_when_repo_nonexistent() { - assertThatThrownBy(() -> newScmProvider().branchChangedFiles("master", temp.newFolder().toPath())) + assertThatThrownBy(() -> newScmProvider().branchChangedFiles("main", temp.newFolder().toPath())) .isInstanceOf(MessageException.class) .hasMessageContaining("Not inside a Git work tree: "); } @Test public void branchChangedFiles_should_throw_when_dir_nonexistent() { - assertThatThrownBy(() -> newScmProvider().branchChangedFiles("master", temp.getRoot().toPath().resolve("nonexistent"))) + assertThatThrownBy(() -> newScmProvider().branchChangedFiles("main", temp.getRoot().toPath().resolve("nonexistent"))) .isInstanceOf(MessageException.class) .hasMessageContaining("Not inside a Git work tree: "); } |