aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-server-common
diff options
context:
space:
mode:
authorLukasz Jarocki <lukasz.jarocki@sonarsource.com>2022-10-31 12:25:54 +0100
committersonartech <sonartech@sonarsource.com>2022-11-01 20:03:09 +0000
commitb0be5da0c49b74538dbce98014298a104d4ac5b0 (patch)
tree6a9b4734fefe01a34ef2b45336276be4fafa1483 /server/sonar-server-common
parentb309ce1704e490af7daef2a0d0ab1bbba8c930b8 (diff)
downloadsonarqube-b0be5da0c49b74538dbce98014298a104d4ac5b0.tar.gz
sonarqube-b0be5da0c49b74538dbce98014298a104d4ac5b0.zip
SONAR-17524 changing default branch name for projects
Diffstat (limited to 'server/sonar-server-common')
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/project/DefaultBranchNameResolver.java38
1 files changed, 38 insertions, 0 deletions
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/project/DefaultBranchNameResolver.java b/server/sonar-server-common/src/main/java/org/sonar/server/project/DefaultBranchNameResolver.java
new file mode 100644
index 00000000000..bd93736002b
--- /dev/null
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/project/DefaultBranchNameResolver.java
@@ -0,0 +1,38 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2022 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.server.project;
+
+import org.sonar.api.config.Configuration;
+
+import static org.sonar.core.config.CorePropertyDefinitions.SONAR_PROJECTCREATION_MAINBRANCHNAME;
+import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
+
+public class DefaultBranchNameResolver {
+
+ Configuration configuration;
+
+ public DefaultBranchNameResolver(Configuration configuration) {
+ this.configuration = configuration;
+ }
+
+ public String getEffectiveMainBranchName() {
+ return configuration.get(SONAR_PROJECTCREATION_MAINBRANCHNAME).orElse(DEFAULT_PROJECT_MAIN_BRANCH_NAME);
+ }
+}