Quellcode durchsuchen

refactor: commit po,不记录门户id

370774330@qq.com vor 5 Jahren
Ursprung
Commit
27e1edc5e7

+ 8 - 8
web/src/main/java/cn/seecoder/web/core/commit/CommitResolver.java

@@ -9,10 +9,10 @@ import cn.seecoder.web.core.commit.model.CommitType;
  * @date 2021/3/22
  * @description:
  * 需要约束的commit规范
- * feat: working on #123456, users can leave the group now. (pass)
- * feat: complete #123456. (pass)
- * fix: fixing on #123456, users can log out successfully now. (pass)
- * fix: fix #123456, users can log out successfully now. (pass)
+ * feat: working on #123456#, users can leave the group now. (pass)
+ * feat: complete #123456#. (pass)
+ * fix: fixing on #123456#, users can log out successfully now. (pass)
+ * fix: fix #123456#, users can log out successfully now. (pass)
  */
 public class CommitResolver {
     /**
@@ -61,7 +61,7 @@ public class CommitResolver {
 
         String state = title.substring(colon+1, pound);
         for ( CommitState t: CommitState.values()) {
-            if ( state.trim().contains(t.toString())){
+            if ( state.trim().equals(t.toString())){
                 return t;
             }
         }
@@ -78,9 +78,9 @@ public class CommitResolver {
         }
         int id;
         title = title.substring(pound+1);
-        int space = title.indexOf(' ');
-        if (space != -1){
-            title = title.substring(0,space);
+        pound = title.indexOf('#');
+        if (pound != -1){
+            title = title.substring(0,pound);
         }
         try{
             id = Integer.parseInt(title);

+ 2 - 7
web/src/main/java/cn/seecoder/web/model/po/project/CommitPO.java

@@ -23,7 +23,7 @@ public class CommitPO {
     private String message;
     private String title;
     private String timestamp;
-    private String username;
+    private String gitlabUsername;
     private String email;
     private CommitRelatedEnum relatedType;
     /**
@@ -36,14 +36,9 @@ public class CommitPO {
      */
     private Integer projectId;
 
-    /**
-     * 这条commit提交人的门户id
-     */
-    private Integer userId;
-
     public CommitPO(GitWebHookVO.Commit commit, Integer projectId, CommitRelatedEnum type){
         BeanUtils.copyProperties(commit,this);
-        this.username = commit.getAuthor().getName();
+        this.gitlabUsername = commit.getAuthor().getName();
         this.email = commit.getAuthor().getEmail();
         this.projectId = projectId;
         relatedType = type;

+ 16 - 18
web/src/main/resources/sql/table_init.sql

@@ -39,6 +39,22 @@ create table if not exists devcloud.project
 )
     charset = utf8;
 
+create table if not exists devcloud.commit
+(
+    id              varchar(127) not null
+        primary key,
+    message         text         null,
+    title           text         null,
+    timestamp       varchar(31)  null,
+    gitlab_username varchar(31)  null,
+    related_id      int          null,
+    project_id      int          null,
+    related_type    varchar(11)  null,
+    email           varchar(63)  null,
+    constraint commit_project_id_fk
+        foreign key (project_id) references devcloud.project (id)
+);
+
 create table if not exists devcloud.pipeline
 (
     id            int auto_increment
@@ -167,24 +183,6 @@ create table if not exists devcloud.bug_list
         foreign key (processor_id) references devcloud.user (id)
 );
 
-create table if not exists devcloud.commit
-(
-    id              varchar(127) not null
-        primary key,
-    message         text         null,
-    title           text         null,
-    timestamp       varchar(31)  null,
-    gitlab_username varchar(31)  null,
-    related_id      int          null,
-    project_id      int          null,
-    related_type    varchar(11)  null,
-    user_id         int          null,
-    constraint commit_project_id_fk
-        foreign key (project_id) references devcloud.project (id),
-    constraint commit_user_id_fk
-        foreign key (user_id) references devcloud.user (id)
-);
-
 create table if not exists devcloud.pipeline_record
 (
     id          int auto_increment

+ 2 - 2
web/src/test/java/cn/seecoder/web/dao/project/CommitMapperTest.java

@@ -31,7 +31,7 @@ class CommitMapperTest {
     void insert() {
         CommitPO commitPO = CommitPO.builder()
                 .id("esdadafs")
-                .username("cool")
+                .gitlabUsername("cool")
                 .message("fefefefeat")
                 .title("feat: nononono")
                 .projectId(2)
@@ -46,7 +46,7 @@ class CommitMapperTest {
     void update() {
         CommitPO commitPO = CommitPO.builder()
                 .id("esdadafs")
-                .username("not cool")
+                .gitlabUsername("not cool")
                 .build();
         commitMapper.update(commitPO);
     }