]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9899 Remove all references to branches of type PR
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Mon, 2 Oct 2017 15:37:22 +0000 (17:37 +0200)
committerDuarte Meneses <duarte.meneses@sonarsource.com>
Wed, 4 Oct 2017 10:13:25 +0000 (12:13 +0200)
20 files changed:
server/sonar-db-core/src/main/resources/org/sonar/db/version/schema-h2.ddl
server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchDao.java
server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchDto.java
server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchKeyType.java [deleted file]
server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchMapper.java
server/sonar-db-dao/src/main/resources/org/sonar/db/component/BranchMapper.xml
server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDaoTest.java
server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentTesting.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/AddIndexOnProjectBranchesKey.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/CreateTableProjectBranches.java
server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v66/PopulateMainProjectBranches.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/CreateTableProjectBranchesTest.java
server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v66/PopulateMainProjectBranchesTest.java
server/sonar-db-migration/src/test/resources/org/sonar/server/platform/db/migration/version/v66/PopulateMainProjectBranchesTest/initial.sql
server/sonar-server/src/main/java/org/sonar/server/component/ComponentUpdater.java
server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/component/BranchPersister.java
server/sonar-server/src/main/java/org/sonar/server/projectbranch/ws/DeleteAction.java
server/sonar-server/src/main/java/org/sonar/server/projectbranch/ws/ListAction.java
server/sonar-server/src/main/java/org/sonar/server/projectbranch/ws/RenameAction.java
server/sonar-server/src/test/java/org/sonar/server/component/ComponentUpdaterTest.java

index f4ea81d864e0d514f5048876c4ae97a508bb9ace..0aab8ac7160871052e5335049547f949a3b56249 100644 (file)
@@ -717,13 +717,11 @@ CREATE UNIQUE INDEX "PLUGINS_KEY" ON "PLUGINS" ("KEE");
 CREATE TABLE "PROJECT_BRANCHES" (
   "UUID" VARCHAR(50) NOT NULL PRIMARY KEY,
   "PROJECT_UUID" VARCHAR(50) NOT NULL,
-  "KEE_TYPE" VARCHAR(6) NOT NULL,
   "KEE" VARCHAR(255) NOT NULL,
   "BRANCH_TYPE" VARCHAR(5),
   "MERGE_BRANCH_UUID" VARCHAR(50),
-  "PULL_REQUEST_TITLE" VARCHAR(4000),
   "CREATED_AT" BIGINT NOT NULL,
   "UPDATED_AT" BIGINT NOT NULL
 );
 CREATE UNIQUE INDEX "PK_PROJECT_BRANCHES" ON "PROJECT_BRANCHES" ("UUID");
-CREATE UNIQUE INDEX "PROJECT_BRANCHES_KEE" ON "PROJECT_BRANCHES" ("PROJECT_UUID", "KEE_TYPE", "KEE");
+CREATE UNIQUE INDEX "PROJECT_BRANCHES_KEE" ON "PROJECT_BRANCHES" ("PROJECT_UUID", "KEE");
index ae6558869cf20aedb3fc803a664fd8efabda9490..1b30cf9ae09818bac07cff48e1eb83d72e52b78c 100644 (file)
@@ -22,7 +22,6 @@ package org.sonar.db.component;
 import java.util.Collection;
 import java.util.List;
 import java.util.Optional;
-import javax.annotation.Nullable;
 import org.sonar.api.utils.System2;
 import org.sonar.db.Dao;
 import org.sonar.db.DbSession;
@@ -54,8 +53,8 @@ public class BranchDao implements Dao {
     return mapper(dbSession).updateMainBranchName(projectUuid, newBranchKey, now);
   }
 
-  public Optional<BranchDto> selectByKey(DbSession dbSession, String projectUuid, BranchKeyType keyType, @Nullable String key) {
-    return Optional.ofNullable(mapper(dbSession).selectByKey(projectUuid, keyType, key));
+  public Optional<BranchDto> selectByKey(DbSession dbSession, String projectUuid, String key) {
+    return Optional.ofNullable(mapper(dbSession).selectByKey(projectUuid, key));
   }
 
   public Collection<BranchDto> selectByComponent(DbSession dbSession, ComponentDto component) {
index 655260116e4cf885320507d0e07b882fab6a69eb..65b46912c6d613ce7001163378487d15b51e8cb0 100644 (file)
@@ -48,24 +48,14 @@ public class BranchDto {
   private String projectUuid;
 
   /**
-   * Not null.
-   */
-  private BranchKeyType keeType;
-
-  /**
-   * If {@link #keeType} is {@link BranchKeyType#BRANCH}, then name of branch, for example
-   * "feature/foo".
-   *
-   * If {@link #keeType} is {@link BranchKeyType#PR}, then id of the pull request, for
-   * example "1204".
+   * Name of branch, for example "feature/foo".
    */
   private String kee;
 
   /**
-   * Value is mandatory when {@link #keeType} is {@link BranchKeyType#BRANCH}.
-   * Otherwise it is null.
+   * Branch type, as provided by {@link BranchType}.
+   * Not null.
    */
-  @Nullable
   private BranchType branchType;
 
   /**
@@ -78,12 +68,6 @@ public class BranchDto {
   @Nullable
   private String mergeBranchUuid;
 
-  /**
-   * Optional title of pull requests
-   */
-  @Nullable
-  private String pullRequestTitle;
-
   public String getUuid() {
     return uuid;
   }
@@ -106,15 +90,6 @@ public class BranchDto {
     return projectUuid.equals(uuid);
   }
 
-  public BranchKeyType getKeeType() {
-    return keeType;
-  }
-
-  public BranchDto setKeeType(BranchKeyType t) {
-    this.keeType = t;
-    return this;
-  }
-
   /**
    * This is the getter used by MyBatis mapper.
    */
@@ -139,7 +114,6 @@ public class BranchDto {
     return this;
   }
 
-  @Nullable
   public BranchType getBranchType() {
     return branchType;
   }
@@ -159,27 +133,14 @@ public class BranchDto {
     return this;
   }
 
-  @Nullable
-  public String getPullRequestTitle() {
-    return pullRequestTitle;
-  }
-
-  public BranchDto setPullRequestTitle(@Nullable String s) {
-    checkArgument(s == null || s.length() <= 4000, "Maximum length of pull request title is 4000: %s", s);
-    this.pullRequestTitle = s;
-    return this;
-  }
-
   @Override
   public String toString() {
     StringBuilder sb = new StringBuilder("BranchDto{");
     sb.append("uuid='").append(uuid).append('\'');
     sb.append(", projectUuid='").append(projectUuid).append('\'');
-    sb.append(", keeType=").append(keeType);
     sb.append(", kee='").append(kee).append('\'');
     sb.append(", branchType=").append(branchType);
     sb.append(", mergeBranchUuid='").append(mergeBranchUuid).append('\'');
-    sb.append(", pullRequestTitle='").append(pullRequestTitle).append('\'');
     sb.append('}');
     return sb.toString();
   }
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchKeyType.java b/server/sonar-db-dao/src/main/java/org/sonar/db/component/BranchKeyType.java
deleted file mode 100644 (file)
index cc6ca0a..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 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.db.component;
-
-/**
- * Supported values in column project_branches.kee_type
- */
-public enum BranchKeyType {
-  /**
-   * Branch, whatever long or short, main or not.
-   */
-  BRANCH,
-
-  /**
-   * Pull request
-   */
-  PR
-}
index d1c08ed6bc0b0514e1e3007bbd1f9651b257ab71..ec37acbc8dc83af4f751ec128a10f7f60f1cde78 100644 (file)
@@ -31,8 +31,7 @@ public interface BranchMapper {
 
   int updateMainBranchName(@Param("projectUuid") String projectUuid, @Param("newBranchName") String newBranchName, @Param("now") long now);
 
-  BranchDto selectByKey(@Param("projectUuid") String projectUuid,
-    @Param("keyType") BranchKeyType keyType, @Param("key") String key);
+  BranchDto selectByKey(@Param("projectUuid") String projectUuid, @Param("key") String key);
 
   BranchDto selectByUuid(@Param("uuid") String uuid);
 
index dd5206678334c6c56dbb89671933fe9476e22edc..f14a166566b7207b235a09f2f32ca087f2ff40a8 100644 (file)
@@ -5,32 +5,26 @@
   <sql id="columns">
     pb.uuid as uuid,
     pb.project_uuid as projectUuid,
-    pb.kee_type as keeType,
     pb.kee as kee,
     pb.branch_type as branchType,
-    pb.merge_branch_uuid as mergeBranchUuid,
-    pb.pull_request_title as pullRequestTitle
+    pb.merge_branch_uuid as mergeBranchUuid
   </sql>
 
   <insert id="insert" parameterType="map" useGeneratedKeys="false">
     insert into project_branches (
       uuid,
       project_uuid,
-      kee_type,
       kee,
       branch_type,
       merge_branch_uuid,
-      pull_request_title,
       created_at,
       updated_at
     ) values (
       #{dto.uuid, jdbcType=VARCHAR},
       #{dto.projectUuid, jdbcType=VARCHAR},
-      #{dto.keeType, jdbcType=VARCHAR},
       #{dto.kee, jdbcType=VARCHAR},
       #{dto.branchType, jdbcType=VARCHAR},
       #{dto.mergeBranchUuid, jdbcType=VARCHAR},
-      #{dto.pullRequestTitle, jdbcType=VARCHAR},
       #{now, jdbcType=BIGINT},
       #{now, jdbcType=BIGINT}
     )
@@ -49,7 +43,6 @@
     update project_branches
     set
     merge_branch_uuid = #{dto.mergeBranchUuid, jdbcType=VARCHAR},
-    pull_request_title = #{dto.pullRequestTitle, jdbcType=VARCHAR},
     updated_at = #{now, jdbcType=BIGINT}
     where
     uuid = #{dto.uuid, jdbcType=VARCHAR}
@@ -60,7 +53,6 @@
     from project_branches pb
     where
     pb.project_uuid = #{projectUuid, jdbcType=VARCHAR} and
-    pb.kee_type = #{keyType, jdbcType=VARCHAR} and
     pb.kee = #{key, jdbcType=VARCHAR}
   </select>
 
index f7f20dda309fce7d6ce5881e63ba3b702fcfade3..0932817bcbd32b7ac98c96bfbf8d2d2fd0e29b79 100644 (file)
@@ -37,8 +37,8 @@ import static org.assertj.core.api.Assertions.entry;
 public class BranchDaoTest {
 
   private static final long NOW = 1_000L;
-  private static final String SELECT_FROM = "select project_uuid as \"projectUuid\", uuid as \"uuid\", branch_type as \"branchType\", kee_type as \"keeType\", " +
-    "kee as \"kee\", merge_branch_uuid as \"mergeBranchUuid\", pull_request_title as \"pullRequestTitle\", created_at as \"createdAt\", updated_at as \"updatedAt\" " +
+  private static final String SELECT_FROM = "select project_uuid as \"projectUuid\", uuid as \"uuid\", branch_type as \"branchType\",  " +
+    "kee as \"kee\", merge_branch_uuid as \"mergeBranchUuid\", created_at as \"createdAt\", updated_at as \"updatedAt\" " +
     "from project_branches ";
   private System2 system2 = new TestSystem2().setNow(NOW);
 
@@ -54,7 +54,6 @@ public class BranchDaoTest {
     dto.setProjectUuid("U1");
     dto.setUuid("U2");
     dto.setBranchType(BranchType.SHORT);
-    dto.setKeeType(BranchKeyType.BRANCH);
     dto.setKey("feature/foo");
 
     underTest.insert(dbSession, dto);
@@ -64,10 +63,8 @@ public class BranchDaoTest {
       entry("projectUuid", "U1"),
       entry("uuid", "U2"),
       entry("branchType", "SHORT"),
-      entry("keeType", "BRANCH"),
       entry("kee", "feature/foo"),
       entry("mergeBranchUuid", null),
-      entry("pullRequestTitle", null),
       entry("createdAt", 1_000L),
       entry("updatedAt", 1_000L));
   }
@@ -78,7 +75,6 @@ public class BranchDaoTest {
     dto.setProjectUuid("U1");
     dto.setUuid("U1");
     dto.setBranchType(BranchType.LONG);
-    dto.setKeeType(BranchKeyType.BRANCH);
     dto.setKey("feature");
     underTest.insert(dbSession, dto);
 
@@ -86,17 +82,14 @@ public class BranchDaoTest {
     dto2.setProjectUuid("U2");
     dto2.setUuid("U2");
     dto2.setBranchType(BranchType.LONG);
-    dto2.setKeeType(BranchKeyType.BRANCH);
     dto2.setKey("branch");
     underTest.insert(dbSession, dto2);
 
     underTest.updateMainBranchName(dbSession, "U1", "master");
-    BranchDto loaded = underTest.selectByKey(dbSession, "U1", BranchKeyType.BRANCH, "master").get();
+    BranchDto loaded = underTest.selectByKey(dbSession, "U1", "master").get();
     assertThat(loaded.getMergeBranchUuid()).isNull();
-    assertThat(loaded.getPullRequestTitle()).isNull();
     assertThat(loaded.getProjectUuid()).isEqualTo("U1");
     assertThat(loaded.getBranchType()).isEqualTo(BranchType.LONG);
-    assertThat(loaded.getKeeType()).isEqualTo(BranchKeyType.BRANCH);
   }
 
   @Test
@@ -105,10 +98,8 @@ public class BranchDaoTest {
     dto.setProjectUuid(repeat("a", 50));
     dto.setUuid(repeat("b", 50));
     dto.setBranchType(BranchType.SHORT);
-    dto.setKeeType(BranchKeyType.BRANCH);
     dto.setKey(repeat("c", 255));
     dto.setMergeBranchUuid(repeat("d", 50));
-    dto.setPullRequestTitle(repeat("e", 4_000));
 
     underTest.insert(dbSession, dto);
 
@@ -117,7 +108,6 @@ public class BranchDaoTest {
     assertThat((String) map.get("uuid")).contains("b").isEqualTo(dto.getUuid());
     assertThat((String) map.get("kee")).contains("c").isEqualTo(dto.getKey());
     assertThat((String) map.get("mergeBranchUuid")).contains("d").isEqualTo(dto.getMergeBranchUuid());
-    assertThat((String) map.get("pullRequestTitle")).contains("e").isEqualTo(dto.getPullRequestTitle());
   }
 
   @Test
@@ -126,26 +116,21 @@ public class BranchDaoTest {
     dto.setProjectUuid("U1");
     dto.setUuid("U2");
     dto.setBranchType(BranchType.LONG);
-    dto.setKeeType(BranchKeyType.BRANCH);
     dto.setKey("foo");
     underTest.insert(dbSession, dto);
 
     // the fields that can be updated
     dto.setMergeBranchUuid("U3");
-    dto.setPullRequestTitle("theTitle");
 
     // the fields that can't be updated. New values are ignored.
     dto.setProjectUuid("ignored");
     dto.setBranchType(BranchType.SHORT);
-    dto.setKeeType(BranchKeyType.PR);
     underTest.upsert(dbSession, dto);
 
-    BranchDto loaded = underTest.selectByKey(dbSession, "U1", BranchKeyType.BRANCH, "foo").get();
+    BranchDto loaded = underTest.selectByKey(dbSession, "U1", "foo").get();
     assertThat(loaded.getMergeBranchUuid()).isEqualTo("U3");
-    assertThat(loaded.getPullRequestTitle()).isEqualTo("theTitle");
     assertThat(loaded.getProjectUuid()).isEqualTo("U1");
     assertThat(loaded.getBranchType()).isEqualTo(BranchType.LONG);
-    assertThat(loaded.getKeeType()).isEqualTo(BranchKeyType.BRANCH);
   }
 
   @Test
@@ -154,7 +139,6 @@ public class BranchDaoTest {
     mainBranch.setProjectUuid("U1");
     mainBranch.setUuid("U1");
     mainBranch.setBranchType(BranchType.LONG);
-    mainBranch.setKeeType(BranchKeyType.BRANCH);
     mainBranch.setKey("master");
     underTest.insert(dbSession, mainBranch);
 
@@ -162,26 +146,20 @@ public class BranchDaoTest {
     featureBranch.setProjectUuid("U1");
     featureBranch.setUuid("U2");
     featureBranch.setBranchType(BranchType.SHORT);
-    featureBranch.setKeeType(BranchKeyType.BRANCH);
     featureBranch.setKey("feature/foo");
     featureBranch.setMergeBranchUuid("U3");
     underTest.insert(dbSession, featureBranch);
 
     // select the feature branch
-    BranchDto loaded = underTest.selectByKey(dbSession, "U1", BranchKeyType.BRANCH, "feature/foo").get();
+    BranchDto loaded = underTest.selectByKey(dbSession, "U1", "feature/foo").get();
     assertThat(loaded.getUuid()).isEqualTo(featureBranch.getUuid());
     assertThat(loaded.getKey()).isEqualTo(featureBranch.getKey());
     assertThat(loaded.getProjectUuid()).isEqualTo(featureBranch.getProjectUuid());
     assertThat(loaded.getBranchType()).isEqualTo(featureBranch.getBranchType());
-    assertThat(loaded.getKeeType()).isEqualTo(featureBranch.getKeeType());
     assertThat(loaded.getMergeBranchUuid()).isEqualTo(featureBranch.getMergeBranchUuid());
-    assertThat(loaded.getPullRequestTitle()).isEqualTo(featureBranch.getPullRequestTitle());
-
-    // select a pull request with same key than the feature branch
-    assertThat(underTest.selectByKey(dbSession, "U1", BranchKeyType.PR, "feature/foo")).isEmpty();
 
     // select a branch on another project with same branch name
-    assertThat(underTest.selectByKey(dbSession, "U3", BranchKeyType.BRANCH, "feature/foo")).isEmpty();
+    assertThat(underTest.selectByKey(dbSession, "U3", "feature/foo")).isEmpty();
   }
 
   @Test
index 27e73d548a547dc03cdd6817e4716964b257fa9c..fa172f5bb5ab265dd847207397f468b362c4aef3 100644 (file)
@@ -29,7 +29,6 @@ import org.sonar.db.organization.OrganizationDto;
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
 import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric;
-import static org.sonar.db.component.BranchKeyType.BRANCH;
 import static org.sonar.db.component.ComponentDto.UUID_PATH_SEPARATOR;
 
 public class ComponentTesting {
@@ -209,7 +208,6 @@ public class ComponentTesting {
       .setUuid(Uuids.createFast())
       // MainBranchProjectUuid will be null if it's a main branch
       .setProjectUuid(projectUuid)
-      .setKeeType(BRANCH)
       .setBranchType(branchType);
   }
 
@@ -226,7 +224,6 @@ public class ComponentTesting {
       .setKey(key)
       .setUuid(branchComponent.uuid())
       .setProjectUuid(projectUuid)
-      .setKeeType(BRANCH)
       .setBranchType(branchType);
   }
 
index 81eee9c92303804bdd8d699d72a6aa7cfbaafdb1..09f3fb2950a6b6b079be7f4d84da5afea8e48f0f 100644 (file)
@@ -42,11 +42,6 @@ public class AddIndexOnProjectBranchesKey extends DdlChange {
           .setIsNullable(false)
           .setLimit(50)
           .build())
-        .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder()
-          .setColumnName("kee_type")
-          .setIsNullable(false)
-          .setLimit(6)
-          .build())
         .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder()
           .setColumnName("kee")
           .setIsNullable(false)
index db40d988aecf4caf8b7747f371178e612325429d..072e2cf428b414d32064663f24d92150fe67b416 100644 (file)
@@ -47,11 +47,6 @@ public class CreateTableProjectBranches extends DdlChange {
         .setIsNullable(false)
         .setLimit(50)
         .build())
-      .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder()
-        .setColumnName("kee_type")
-        .setIsNullable(false)
-        .setLimit(6)
-        .build())
       .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder()
         .setColumnName("kee")
         .setIsNullable(false)
@@ -67,11 +62,6 @@ public class CreateTableProjectBranches extends DdlChange {
         .setIsNullable(true)
         .setLimit(50)
         .build())
-      .addColumn(VarcharColumnDef.newVarcharColumnDefBuilder()
-        .setColumnName("pull_request_title")
-        .setIsNullable(true)
-        .setLimit(4000)
-        .build())
       .addColumn(BigIntegerColumnDef.newBigIntegerColumnDefBuilder()
         .setColumnName("created_at")
         .setIsNullable(false)
index 9d66de5abdca307411527e526a72e59b355cc4b0..77fca273828077030bbdc918bae7b9bc2d97ce3c 100644 (file)
@@ -43,20 +43,18 @@ public class PopulateMainProjectBranches extends DataChange {
     massUpdate.select("SELECT uuid FROM projects p "
       + "WHERE p.scope='PRJ' AND p.qualifier='TRK' AND p.main_branch_project_uuid IS NULL "
       + "AND NOT EXISTS (SELECT uuid FROM project_branches b WHERE b.uuid = p.uuid)");
-    massUpdate.update("INSERT INTO project_branches (uuid, project_uuid, kee_type, kee, branch_type, "
-      + "merge_branch_uuid, pull_request_title, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)");
+    massUpdate.update("INSERT INTO project_branches (uuid, project_uuid, kee, branch_type, "
+      + "merge_branch_uuid, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?)");
     massUpdate.rowPluralName("projects");
     massUpdate.execute((row, update) -> {
       String uuid = row.getString(1);
       update.setString(1, uuid);
       update.setString(2, uuid);
-      update.setString(3, "BRANCH");
-      update.setString(4, MAIN_BRANCH_NAME);
-      update.setString(5, "LONG");
-      update.setString(6, null);
-      update.setString(7, null);
-      update.setLong(8, now);
-      update.setLong(9, now);
+      update.setString(3, MAIN_BRANCH_NAME);
+      update.setString(4, "LONG");
+      update.setString(5, null);
+      update.setLong(6, now);
+      update.setLong(7, now);
       return true;
     });
   }
index f8d74a0b11523683c0a4760651d6f14688722ce9..a7916e617c9804ed9747812fca2dcb0751d2c9ce 100644 (file)
@@ -47,11 +47,9 @@ public class CreateTableProjectBranchesTest {
 
     db.assertColumnDefinition(TABLE, "uuid", Types.VARCHAR, 50, false);
     db.assertColumnDefinition(TABLE, "project_uuid", Types.VARCHAR, 50, false);
-    db.assertColumnDefinition(TABLE, "kee_type", Types.VARCHAR, 6, false);
     db.assertColumnDefinition(TABLE, "kee", Types.VARCHAR, 255, false);
     db.assertColumnDefinition(TABLE, "branch_type", Types.VARCHAR, 5, true);
     db.assertColumnDefinition(TABLE, "merge_branch_uuid", Types.VARCHAR, 50, true);
-    db.assertColumnDefinition(TABLE, "pull_request_title", Types.VARCHAR, 4000, true);
     db.assertColumnDefinition(TABLE, "created_at", Types.BIGINT, null, false);
     db.assertColumnDefinition(TABLE, "updated_at", Types.BIGINT, null, false);
     db.assertPrimaryKey(TABLE, "pk_" + TABLE, "uuid");
index 29433a7dc19d18095ab49660c8da7d6e1b7cda95..e9a10caa2d82975f65740efb83909b36e39c7a84 100644 (file)
@@ -54,7 +54,7 @@ public class PopulateMainProjectBranchesTest {
 
     underTest.execute();
 
-    assertProjectBranches(tuple("master", project, project, "BRANCH", "LONG", NOW, NOW));
+    assertProjectBranches(tuple("master", project, project, "LONG", NOW, NOW));
   }
 
   @Test
@@ -81,13 +81,13 @@ public class PopulateMainProjectBranchesTest {
 
     underTest.execute();
 
-    assertProjectBranches(tuple("master", project, project, "BRANCH", "LONG", PAST, PAST));
+    assertProjectBranches(tuple("master", project, project, "LONG", PAST, PAST));
   }
 
   private void assertProjectBranches(Tuple... expectedTuples) {
-    assertThat(db.select("SELECT KEE, UUID, PROJECT_UUID, KEE_TYPE, BRANCH_TYPE, CREATED_AT, UPDATED_AT FROM PROJECT_BRANCHES")
+    assertThat(db.select("SELECT KEE, UUID, PROJECT_UUID, BRANCH_TYPE, CREATED_AT, UPDATED_AT FROM PROJECT_BRANCHES")
       .stream()
-      .map(map -> new Tuple(map.get("KEE"), map.get("UUID"), map.get("PROJECT_UUID"), map.get("KEE_TYPE"), map.get("BRANCH_TYPE"), map.get("CREATED_AT"), map.get("UPDATED_AT")))
+      .map(map -> new Tuple(map.get("KEE"), map.get("UUID"), map.get("PROJECT_UUID"), map.get("BRANCH_TYPE"), map.get("CREATED_AT"), map.get("UPDATED_AT")))
       .collect(Collectors.toList()))
         .containsExactlyInAnyOrder(expectedTuples);
   }
@@ -116,7 +116,6 @@ public class PopulateMainProjectBranchesTest {
     db.executeInsert("PROJECT_BRANCHES",
       "uuid", uuid,
       "project_uuid", uuid,
-      "kee_type", "BRANCH",
       "kee", "master",
       "branch_type", "LONG",
       "created_at", PAST,
index fa29c6921b35e8f269fd2e444671b2793b82d4fb..7ae1777df165c4556972f31d4a79654359947845 100644 (file)
@@ -48,13 +48,11 @@ CREATE INDEX "PROJECTS_QUALIFIER" ON "PROJECTS" ("QUALIFIER");
 CREATE TABLE "PROJECT_BRANCHES" (
   "UUID" VARCHAR(50) NOT NULL PRIMARY KEY,
   "PROJECT_UUID" VARCHAR(50) NOT NULL,
-  "KEE_TYPE" VARCHAR(6) NOT NULL,
   "KEE" VARCHAR(255) NOT NULL,
   "BRANCH_TYPE" VARCHAR(5),
   "MERGE_BRANCH_UUID" VARCHAR(50),
-  "PULL_REQUEST_TITLE" VARCHAR(4000),
   "CREATED_AT" BIGINT NOT NULL,
   "UPDATED_AT" BIGINT NOT NULL
 );
 CREATE UNIQUE INDEX "PK_PROJECT_BRANCHES" ON "PROJECT_BRANCHES" ("UUID");
-CREATE UNIQUE INDEX "PROJECT_BRANCHES_KEE" ON "PROJECT_BRANCHES" ("PROJECT_UUID", "KEE_TYPE", "KEE");
+CREATE UNIQUE INDEX "PROJECT_BRANCHES_KEE" ON "PROJECT_BRANCHES" ("PROJECT_UUID", "KEE");
index 2ed1f3d02fea445b53138b8a104e9ae7e3e5eaa5..d53d7f153741852fa481d0a60e6be2b6e61acb2b 100644 (file)
@@ -32,7 +32,6 @@ import org.sonar.core.util.Uuids;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.component.BranchDto;
-import org.sonar.db.component.BranchKeyType;
 import org.sonar.db.component.BranchType;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.server.es.ProjectIndexer.Cause;
@@ -118,11 +117,9 @@ public class ComponentUpdater {
   private BranchDto createBranch(DbSession session, String componentUuid) {
     BranchDto branch = new BranchDto()
       .setBranchType(BranchType.LONG)
-      .setKeeType(BranchKeyType.BRANCH)
       .setUuid(componentUuid)
       .setKey(BranchDto.DEFAULT_MAIN_BRANCH_NAME)
       .setMergeBranchUuid(null)
-      .setPullRequestTitle(null)
       .setProjectUuid(componentUuid);
 
     dbClient.branchDao().upsert(session, branch);
index 48f1435d5b87fc533600dad5c846fe394f689ff9..2f6cd17882621ae2439a2275c180c0d132522f03 100644 (file)
@@ -26,7 +26,6 @@ import org.sonar.api.utils.System2;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.component.BranchDto;
-import org.sonar.db.component.BranchKeyType;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.server.computation.task.projectanalysis.analysis.AnalysisMetadataHolder;
 import org.sonar.server.computation.task.projectanalysis.analysis.Branch;
@@ -87,12 +86,10 @@ public class BranchPersister {
     dto.setUuid(componentDto.uuid());
     // MainBranchProjectUuid will be null if it's a main branch
     dto.setProjectUuid(firstNonNull(componentDto.getMainBranchProjectUuid(), componentDto.projectUuid()));
-    dto.setKeeType(BranchKeyType.BRANCH);
     dto.setKey(branch.getName());
     dto.setBranchType(branch.getType());
     // merge branch is only present if it's a short living branch
     dto.setMergeBranchUuid(branch.getMergeBranchUuid().orElse(null));
-    dto.setPullRequestTitle(null);
     return dto;
   }
 
index f907be4dfc020c945cf0436ce1346bd944a02087..c9a16b50e53689725b483e2a126f0e9437fd179b 100644 (file)
@@ -28,7 +28,6 @@ import org.sonar.api.web.UserRole;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.component.BranchDto;
-import org.sonar.db.component.BranchKeyType;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.server.component.ComponentCleanerService;
 import org.sonar.server.component.ComponentFinder;
@@ -76,7 +75,7 @@ public class DeleteAction implements BranchWsAction {
       checkPermission(project);
 
       BranchDto branch = checkFoundWithOptional(
-        dbClient.branchDao().selectByKey(dbSession, project.uuid(), BranchKeyType.BRANCH, branchKey),
+        dbClient.branchDao().selectByKey(dbSession, project.uuid(), branchKey),
         "Branch '%s' not found for project '%s'", branchKey, projectKey);
 
       if (branch.isMain()) {
index 9ed81f2a73f083e10bf200597aad298de473cff5..7e3486eb313f96ec4cc850e0824e505468ad4ec2 100644 (file)
@@ -34,7 +34,6 @@ import org.sonar.api.web.UserRole;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.component.BranchDto;
-import org.sonar.db.component.BranchKeyType;
 import org.sonar.db.component.BranchType;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.db.component.SnapshotDto;
@@ -119,7 +118,6 @@ public class ListAction implements BranchWsAction {
 
       WsBranches.ListWsResponse.Builder protobufResponse = WsBranches.ListWsResponse.newBuilder();
       branches.stream()
-        .filter(b -> b.getKeeType().equals(BranchKeyType.BRANCH))
         .forEach(b -> addBranch(protobufResponse, b, mergeBranchesByUuid, qualityGateMeasuresByComponentUuids.get(b.getUuid()), branchStatisticsByBranchUuid.get(b.getUuid()),
           analysisDateByBranchUuid.get(b.getUuid())));
       WsUtils.writeProtobuf(protobufResponse.build(), request, response);
index 498c629db75e1c64a664a9492bcb3f244939a874..8ffa8abb5640bb015bc057055c8e1f6ecd7cb92e 100644 (file)
@@ -28,7 +28,6 @@ import org.sonar.api.web.UserRole;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.component.BranchDto;
-import org.sonar.db.component.BranchKeyType;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.server.component.ComponentFinder;
 import org.sonar.server.user.UserSession;
@@ -71,7 +70,7 @@ public class RenameAction implements BranchWsAction {
       ComponentDto project = componentFinder.getRootComponentByUuidOrKey(dbSession, null, projectKey);
       checkPermission(project);
 
-      Optional<BranchDto> branch = dbClient.branchDao().selectByKey(dbSession, project.uuid(), BranchKeyType.BRANCH, branchKey);
+      Optional<BranchDto> branch = dbClient.branchDao().selectByKey(dbSession, project.uuid(), branchKey);
       if (branch.isPresent() && !branch.get().isMain()) {
         throw new IllegalArgumentException("Impossible to update branch name: a branch with name \"" + branchKey + "\" already exists in the project.");
       }
index 036475dc6fcdb6e8befeeda585eb36f122e4cd00..fc3784953ce0e8aac3347b9795ab2b4622ad280a 100644 (file)
@@ -28,7 +28,6 @@ import org.sonar.api.resources.Scopes;
 import org.sonar.api.utils.System2;
 import org.sonar.db.DbTester;
 import org.sonar.db.component.BranchDto;
-import org.sonar.db.component.BranchKeyType;
 import org.sonar.db.component.BranchType;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.db.organization.OrganizationDto;
@@ -101,10 +100,8 @@ public class ComponentUpdaterTest {
 
     Optional<BranchDto> branch = db.getDbClient().branchDao().selectByUuid(db.getSession(), returned.uuid());
     assertThat(branch).isPresent();
-    assertThat(branch.get().getKeeType()).isEqualTo(BranchKeyType.BRANCH);
     assertThat(branch.get().getKey()).isEqualTo(BranchDto.DEFAULT_MAIN_BRANCH_NAME);
     assertThat(branch.get().getMergeBranchUuid()).isNull();
-    assertThat(branch.get().getPullRequestTitle()).isNull();
     assertThat(branch.get().getBranchType()).isEqualTo(BranchType.LONG);
     assertThat(branch.get().getUuid()).isEqualTo(returned.uuid());
     assertThat(branch.get().getProjectUuid()).isEqualTo(returned.uuid());