You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by GitBox <gi...@apache.org> on 2022/07/15 09:31:47 UTC

[GitHub] [incubator-devlake] xgdyp opened a new pull request, #2504: Commitfile component

xgdyp opened a new pull request, #2504:
URL: https://github.com/apache/incubator-devlake/pull/2504

   
   
   # Summary
   This PR is related to issue953. 
   First, I create a table `component` and user can input file component relationship by operating this table including component name ,repoid,component regexp
   like
   <img width="887" alt="image" src="https://user-images.githubusercontent.com/37795442/179194988-1a045f81-4e2a-491a-8be7-ff6b1d079bc6.png">
   Then I changed the primarykey in commit_files table  from (commit_sha,filepath) to id(commit_sha+":"+filepath)
   like:
   <img width="1088" alt="image" src="https://user-images.githubusercontent.com/37795442/179195226-5fac2bd2-0d27-433a-9cd5-54beb4116cdc.png">
   Then, I create a new table to records which component every commit_file_id belongs to.
   <img width="1374" alt="image" src="https://user-images.githubusercontent.com/37795442/179195444-ca294ee1-2c9e-4dd1-9df7-e5beb31c4370.png">
   
   When user run a pipeline  using gitextractor plugin, lake gets the relationship in components table and match by regexp. Then update the commit_file_component during storing commit_files
   
   ### Does this close any open issues?
   Please mention the issues here.
   closed #953
   
   
   
   ### Other Information
   Really thanks to Klesh for the guidance TwT!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] abeizn commented on a diff in pull request #2504: feat: add relationship with commit files and its components

Posted by GitBox <gi...@apache.org>.
abeizn commented on code in PR #2504:
URL: https://github.com/apache/incubator-devlake/pull/2504#discussion_r927425620


##########
models/migrationscripts/20220721_commitfile_component.go:
##########
@@ -0,0 +1,77 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package migrationscripts
+
+import (
+	"context"
+	"github.com/apache/incubator-devlake/models/common"
+	"github.com/apache/incubator-devlake/models/domainlayer"
+	"gorm.io/gorm"
+)
+
+type Component struct {
+	RepoId    string `gorm:"type:varchar(255)"`
+	Name      string `gorm:"primaryKey;type:varchar(255)"`
+	PathRegex string `gorm:"type:varchar(255)"`
+}
+
+func (Component) TableName() string {
+	return "components"
+}
+
+type CommitFile struct {
+	domainlayer.DomainEntity
+	CommitSha string `gorm:"type:varchar(40)"`
+	FilePath  string `gorm:"type:varchar(255)"`
+	Additions int
+	Deletions int
+}
+
+func (CommitFile) TableName() string {
+	return "commit_files"
+}
+
+type CommitFileComponent struct {
+	common.NoPKModel
+	CommitFileId  string `gorm:"primaryKey;type:varchar(255)"`
+	ComponentName string `gorm:"type:varchar(255)"`
+}
+
+func (CommitFileComponent) TableName() string {
+	return "commit_file_components"
+}
+
+type commitfileComponent struct{}
+
+func (*commitfileComponent) Up(ctx context.Context, db *gorm.DB) error {
+
+	err := db.Migrator().AutoMigrate(Component{}, CommitFile{}, CommitFileComponent{})

Review Comment:
   It was really needed before, but this v0.12 is not compatible with the previous version, so you can be lazy, lol~~



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] xgdyp commented on a diff in pull request #2504: feat: add relationship with commit files and its components

Posted by GitBox <gi...@apache.org>.
xgdyp commented on code in PR #2504:
URL: https://github.com/apache/incubator-devlake/pull/2504#discussion_r927422315


##########
models/migrationscripts/20220721_commitfile_component.go:
##########
@@ -0,0 +1,77 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package migrationscripts
+
+import (
+	"context"
+	"github.com/apache/incubator-devlake/models/common"
+	"github.com/apache/incubator-devlake/models/domainlayer"
+	"gorm.io/gorm"
+)
+
+type Component struct {
+	RepoId    string `gorm:"type:varchar(255)"`
+	Name      string `gorm:"primaryKey;type:varchar(255)"`
+	PathRegex string `gorm:"type:varchar(255)"`
+}
+
+func (Component) TableName() string {
+	return "components"
+}
+
+type CommitFile struct {
+	domainlayer.DomainEntity
+	CommitSha string `gorm:"type:varchar(40)"`
+	FilePath  string `gorm:"type:varchar(255)"`
+	Additions int
+	Deletions int
+}
+
+func (CommitFile) TableName() string {
+	return "commit_files"
+}
+
+type CommitFileComponent struct {
+	common.NoPKModel
+	CommitFileId  string `gorm:"primaryKey;type:varchar(255)"`
+	ComponentName string `gorm:"type:varchar(255)"`
+}
+
+func (CommitFileComponent) TableName() string {
+	return "commit_file_components"
+}
+
+type commitfileComponent struct{}
+
+func (*commitfileComponent) Up(ctx context.Context, db *gorm.DB) error {
+
+	err := db.Migrator().AutoMigrate(Component{}, CommitFile{}, CommitFileComponent{})

Review Comment:
   > please drop the `commit_files` table first, then add it, because it is not a new table.
   
   Do I need to migrate records before in `commitfile` table to the new table?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] xgdyp commented on a diff in pull request #2504: feat: add relationship with commit files and its components

Posted by GitBox <gi...@apache.org>.
xgdyp commented on code in PR #2504:
URL: https://github.com/apache/incubator-devlake/pull/2504#discussion_r926312055


##########
models/domainlayer/code/commit.go:
##########
@@ -45,13 +46,33 @@ func (Commit) TableName() string {
 }
 
 type CommitFile struct {
-	common.NoPKModel
-	CommitSha string `gorm:"primaryKey;type:varchar(40)"`
-	FilePath  string `gorm:"primaryKey;type:varchar(255)"`
+	domainlayer.DomainEntity
+	CommitSha string `gorm:"type:varchar(40)"`
+	FilePath  string `gorm:"type:varchar(255)"`
 	Additions int
 	Deletions int
 }
 
 func (CommitFile) TableName() string {
 	return "commit_files"
 }
+
+type Component struct {

Review Comment:
   I think it can be replaced in gitextractor plugin's model file, what do you think?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] xgdyp commented on a diff in pull request #2504: feat: add relationship with commit files and its components

Posted by GitBox <gi...@apache.org>.
xgdyp commented on code in PR #2504:
URL: https://github.com/apache/incubator-devlake/pull/2504#discussion_r927410944


##########
models/migrationscripts/20220721_commitfile_component.go:
##########
@@ -0,0 +1,77 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package migrationscripts
+
+import (
+	"context"
+	"github.com/apache/incubator-devlake/models/common"
+	"github.com/apache/incubator-devlake/models/domainlayer"
+	"gorm.io/gorm"
+)
+
+type Component struct {
+	RepoId    string `gorm:"type:varchar(255)"`
+	Name      string `gorm:"primaryKey;type:varchar(255)"`
+	PathRegex string `gorm:"type:varchar(255)"`
+}
+
+func (Component) TableName() string {
+	return "components"
+}
+
+type CommitFile struct {
+	domainlayer.DomainEntity
+	CommitSha string `gorm:"type:varchar(40)"`
+	FilePath  string `gorm:"type:varchar(255)"`
+	Additions int
+	Deletions int
+}
+
+func (CommitFile) TableName() string {
+	return "commit_files"
+}
+
+type CommitFileComponent struct {
+	common.NoPKModel
+	CommitFileId  string `gorm:"primaryKey;type:varchar(255)"`
+	ComponentName string `gorm:"type:varchar(255)"`
+}
+
+func (CommitFileComponent) TableName() string {
+	return "commit_file_components"
+}
+
+type commitfileComponent struct{}
+
+func (*commitfileComponent) Up(ctx context.Context, db *gorm.DB) error {
+
+	err := db.Migrator().AutoMigrate(Component{}, CommitFile{}, CommitFileComponent{})

Review Comment:
   I see



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] xgdyp commented on a diff in pull request #2504: feat: add relationship with commit files and its components

Posted by GitBox <gi...@apache.org>.
xgdyp commented on code in PR #2504:
URL: https://github.com/apache/incubator-devlake/pull/2504#discussion_r927459355


##########
models/migrationscripts/20220721_commitfile_component.go:
##########
@@ -0,0 +1,77 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package migrationscripts
+
+import (
+	"context"
+	"github.com/apache/incubator-devlake/models/common"
+	"github.com/apache/incubator-devlake/models/domainlayer"
+	"gorm.io/gorm"
+)
+
+type Component struct {
+	RepoId    string `gorm:"type:varchar(255)"`
+	Name      string `gorm:"primaryKey;type:varchar(255)"`
+	PathRegex string `gorm:"type:varchar(255)"`
+}
+
+func (Component) TableName() string {
+	return "components"
+}
+
+type CommitFile struct {
+	domainlayer.DomainEntity
+	CommitSha string `gorm:"type:varchar(40)"`
+	FilePath  string `gorm:"type:varchar(255)"`
+	Additions int
+	Deletions int
+}
+
+func (CommitFile) TableName() string {
+	return "commit_files"
+}
+
+type CommitFileComponent struct {
+	common.NoPKModel
+	CommitFileId  string `gorm:"primaryKey;type:varchar(255)"`
+	ComponentName string `gorm:"type:varchar(255)"`
+}
+
+func (CommitFileComponent) TableName() string {
+	return "commit_file_components"
+}
+
+type commitfileComponent struct{}
+
+func (*commitfileComponent) Up(ctx context.Context, db *gorm.DB) error {
+
+	err := db.Migrator().AutoMigrate(Component{}, CommitFile{}, CommitFileComponent{})

Review Comment:
   I fix it ,please review again, thanks!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] klesh commented on pull request #2504: feat: add relationship with commit files and its components

Posted by GitBox <gi...@apache.org>.
klesh commented on PR #2504:
URL: https://github.com/apache/incubator-devlake/pull/2504#issuecomment-1188765254

   > > @xgdyp Please fix the commit message by following https://www.conventionalcommits.org/en/v1.0.0/#summary
   > 
   > OK, I think it will squash it.
   
   Yes, we will. But the original commit messages will be kept inside that squashed commit.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] abeizn commented on a diff in pull request #2504: feat: add relationship with commit files and its components

Posted by GitBox <gi...@apache.org>.
abeizn commented on code in PR #2504:
URL: https://github.com/apache/incubator-devlake/pull/2504#discussion_r927407569


##########
models/migrationscripts/20220721_commitfile_component.go:
##########
@@ -0,0 +1,77 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package migrationscripts
+
+import (
+	"context"
+	"github.com/apache/incubator-devlake/models/common"
+	"github.com/apache/incubator-devlake/models/domainlayer"
+	"gorm.io/gorm"
+)
+
+type Component struct {
+	RepoId    string `gorm:"type:varchar(255)"`
+	Name      string `gorm:"primaryKey;type:varchar(255)"`
+	PathRegex string `gorm:"type:varchar(255)"`
+}
+
+func (Component) TableName() string {
+	return "components"
+}
+
+type CommitFile struct {
+	domainlayer.DomainEntity
+	CommitSha string `gorm:"type:varchar(40)"`
+	FilePath  string `gorm:"type:varchar(255)"`
+	Additions int
+	Deletions int
+}
+
+func (CommitFile) TableName() string {
+	return "commit_files"
+}
+
+type CommitFileComponent struct {
+	common.NoPKModel
+	CommitFileId  string `gorm:"primaryKey;type:varchar(255)"`
+	ComponentName string `gorm:"type:varchar(255)"`
+}
+
+func (CommitFileComponent) TableName() string {
+	return "commit_file_components"
+}
+
+type commitfileComponent struct{}
+
+func (*commitfileComponent) Up(ctx context.Context, db *gorm.DB) error {
+
+	err := db.Migrator().AutoMigrate(Component{}, CommitFile{}, CommitFileComponent{})

Review Comment:
   please drop the `commit_files` table first, then add it,  because it is not a new table.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] klesh commented on pull request #2504: feat: add relationship with commit files and its components

Posted by GitBox <gi...@apache.org>.
klesh commented on PR #2504:
URL: https://github.com/apache/incubator-devlake/pull/2504#issuecomment-1188746219

   @xgdyp Please fix the commit message by following https://www.conventionalcommits.org/en/v1.0.0/#summary


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] klesh commented on pull request #2504: feat: add relationship with commit files and its components

Posted by GitBox <gi...@apache.org>.
klesh commented on PR #2504:
URL: https://github.com/apache/incubator-devlake/pull/2504#issuecomment-1191098013

   @xgdyp Nice work. However, there is a conflict that needs to be dealt with.
   ![image](https://user-images.githubusercontent.com/61080/180145881-f1e60996-c835-41ca-be66-b7f841fe093e.png)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] abeizn merged pull request #2504: feat: add relationship with commit files and its components

Posted by GitBox <gi...@apache.org>.
abeizn merged PR #2504:
URL: https://github.com/apache/incubator-devlake/pull/2504


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] abeizn commented on a diff in pull request #2504: feat: add relationship with commit files and its components

Posted by GitBox <gi...@apache.org>.
abeizn commented on code in PR #2504:
URL: https://github.com/apache/incubator-devlake/pull/2504#discussion_r927467078


##########
models/migrationscripts/20220721_commitfile_component.go:
##########
@@ -0,0 +1,77 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package migrationscripts
+
+import (
+	"context"
+	"github.com/apache/incubator-devlake/models/common"
+	"github.com/apache/incubator-devlake/models/domainlayer"
+	"gorm.io/gorm"
+)
+
+type Component struct {
+	RepoId    string `gorm:"type:varchar(255)"`
+	Name      string `gorm:"primaryKey;type:varchar(255)"`
+	PathRegex string `gorm:"type:varchar(255)"`
+}
+
+func (Component) TableName() string {
+	return "components"
+}
+
+type CommitFile struct {
+	domainlayer.DomainEntity
+	CommitSha string `gorm:"type:varchar(40)"`
+	FilePath  string `gorm:"type:varchar(255)"`
+	Additions int
+	Deletions int
+}
+
+func (CommitFile) TableName() string {
+	return "commit_files"
+}
+
+type CommitFileComponent struct {
+	common.NoPKModel
+	CommitFileId  string `gorm:"primaryKey;type:varchar(255)"`
+	ComponentName string `gorm:"type:varchar(255)"`
+}
+
+func (CommitFileComponent) TableName() string {
+	return "commit_file_components"
+}
+
+type commitfileComponent struct{}
+
+func (*commitfileComponent) Up(ctx context.Context, db *gorm.DB) error {
+
+	err := db.Migrator().AutoMigrate(Component{}, CommitFile{}, CommitFileComponent{})

Review Comment:
   @xgdyp  I tested it, great finish.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] abeizn commented on a diff in pull request #2504: feat: add relationship with commit files and its components

Posted by GitBox <gi...@apache.org>.
abeizn commented on code in PR #2504:
URL: https://github.com/apache/incubator-devlake/pull/2504#discussion_r927402678


##########
models/migrationscripts/20220721_commitfile_component.go:
##########
@@ -0,0 +1,77 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package migrationscripts
+
+import (
+	"context"
+	"github.com/apache/incubator-devlake/models/common"
+	"github.com/apache/incubator-devlake/models/domainlayer"
+	"gorm.io/gorm"
+)
+
+type Component struct {
+	RepoId    string `gorm:"type:varchar(255)"`
+	Name      string `gorm:"primaryKey;type:varchar(255)"`
+	PathRegex string `gorm:"type:varchar(255)"`
+}
+
+func (Component) TableName() string {
+	return "components"
+}
+
+type CommitFile struct {
+	domainlayer.DomainEntity
+	CommitSha string `gorm:"type:varchar(40)"`
+	FilePath  string `gorm:"type:varchar(255)"`
+	Additions int
+	Deletions int
+}
+
+func (CommitFile) TableName() string {
+	return "commit_files"
+}
+
+type CommitFileComponent struct {
+	common.NoPKModel
+	CommitFileId  string `gorm:"primaryKey;type:varchar(255)"`
+	ComponentName string `gorm:"type:varchar(255)"`
+}
+
+func (CommitFileComponent) TableName() string {
+	return "commit_file_components"
+}
+
+type commitfileComponent struct{}
+
+func (*commitfileComponent) Up(ctx context.Context, db *gorm.DB) error {
+
+	err := db.Migrator().AutoMigrate(Component{}, CommitFile{}, CommitFileComponent{})
+	if err != nil {
+		return err
+	}
+	return nil
+
+}
+
+func (*commitfileComponent) Version() uint64 {
+	return 202207211505

Review Comment:
   Please keep 14 digits



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] xgdyp commented on pull request #2504: feat: add relationship with commit files and its components

Posted by GitBox <gi...@apache.org>.
xgdyp commented on PR #2504:
URL: https://github.com/apache/incubator-devlake/pull/2504#issuecomment-1188790920

   > > > @xgdyp Please fix the commit message by following https://www.conventionalcommits.org/en/v1.0.0/#summary
   > > 
   > > 
   > > OK, I think it will squash it.
   > 
   > Yes, we will. But the original commit messages will be kept inside that squashed commit.
   
   I'll fix it later


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] xgdyp commented on pull request #2504: feat: add relationship with commit files and its components

Posted by GitBox <gi...@apache.org>.
xgdyp commented on PR #2504:
URL: https://github.com/apache/incubator-devlake/pull/2504#issuecomment-1189842759

   I fix it, please review it, thanks! @klesh 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] klesh commented on a diff in pull request #2504: feat: add relationship with commit files and its components

Posted by GitBox <gi...@apache.org>.
klesh commented on code in PR #2504:
URL: https://github.com/apache/incubator-devlake/pull/2504#discussion_r926316718


##########
models/domainlayer/code/commit.go:
##########
@@ -45,13 +46,33 @@ func (Commit) TableName() string {
 }
 
 type CommitFile struct {
-	common.NoPKModel
-	CommitSha string `gorm:"primaryKey;type:varchar(40)"`
-	FilePath  string `gorm:"primaryKey;type:varchar(255)"`
+	domainlayer.DomainEntity
+	CommitSha string `gorm:"type:varchar(40)"`
+	FilePath  string `gorm:"type:varchar(255)"`
 	Additions int
 	Deletions int
 }
 
 func (CommitFile) TableName() string {
 	return "commit_files"
 }
+
+type Component struct {

Review Comment:
   No, just created a new file `models/domainlayer/code/component.go`, and move this struct into it and we are good.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] klesh commented on a diff in pull request #2504: feat: add relationship with commit files and its components

Posted by GitBox <gi...@apache.org>.
klesh commented on code in PR #2504:
URL: https://github.com/apache/incubator-devlake/pull/2504#discussion_r924206026


##########
models/domainlayer/code/commit.go:
##########
@@ -46,12 +46,33 @@ func (Commit) TableName() string {
 
 type CommitFile struct {
 	common.NoPKModel
-	CommitSha string `gorm:"primaryKey;type:varchar(40)"`
-	FilePath  string `gorm:"primaryKey;type:varchar(255)"`
+	ID        string `gorm:"primaryKey;type:varchar(255)"`
+	CommitSha string `gorm:"type:varchar(40)"`
+	FilePath  string `gorm:"type:varchar(255)"`
 	Additions int
 	Deletions int
 }
 
 func (CommitFile) TableName() string {
 	return "commit_files"
 }
+
+type Component struct {
+	RepoId    string `gorm:"primaryKey;type:varchar(255)"`
+	Name      string `gorm:"type:varchar(255)"`

Review Comment:
   I think we both agreed that the PrimaryKey should be the `Name`.
   The `RepoId` alone is not a valid PK for the table



##########
models/domainlayer/code/commit.go:
##########
@@ -46,12 +46,33 @@ func (Commit) TableName() string {
 
 type CommitFile struct {
 	common.NoPKModel
-	CommitSha string `gorm:"primaryKey;type:varchar(40)"`
-	FilePath  string `gorm:"primaryKey;type:varchar(255)"`
+	ID        string `gorm:"primaryKey;type:varchar(255)"`
+	CommitSha string `gorm:"type:varchar(40)"`
+	FilePath  string `gorm:"type:varchar(255)"`
 	Additions int
 	Deletions int
 }
 
 func (CommitFile) TableName() string {
 	return "commit_files"
 }
+
+type Component struct {
+	RepoId    string `gorm:"primaryKey;type:varchar(255)"`
+	Name      string `gorm:"type:varchar(255)"`
+	PathRegex string `gorm:"type:varchar(255)"`
+}
+
+func (Component) TableName() string {
+	return "components"
+}
+
+type CommitFileComponent struct {
+	common.NoPKModel
+	CommitFileID string `gorm:"primaryKey;type:varchar(255)"`

Review Comment:
   This should b `CommitFileId` if we nested `domainlayer.DomainEntity` instead of `common.NoPKModel` within `CommitFiles`



##########
plugins/gitextractor/store/database.go:
##########
@@ -91,6 +91,14 @@ func (d *Database) CommitFiles(file *code.CommitFile) error {
 	return batch.Add(file)
 }
 
+func (d *Database) FileComponent(commitfile *code.CommitFileComponent) error {

Review Comment:
   same as above



##########
plugins/gitextractor/store/csv.go:
##########
@@ -132,6 +132,9 @@ func (c *CsvStore) Refs(ref *code.Ref) error {
 func (c *CsvStore) CommitFiles(file *code.CommitFile) error {
 	return c.commitFileWriter.Write(file)
 }
+func (c *CsvStore) FileComponent(component *code.CommitFileComponent) error {

Review Comment:
   the variable name and its type are uncorrelated... this is very confusing. is it a `component` or what? 😂.
   and insert an empty line between functions pls.



##########
models/migrationscripts/register.go:
##########
@@ -27,6 +27,7 @@ func All() []migration.Script {
 		new(updateSchemas20220601),
 		new(updateSchemas20220616),
 		new(blueprintNormalMode),
+		new(updateSchemas20220711),

Review Comment:
   I would suggest that we give it a meaningful name like `commitfile_component` 



##########
models/domainlayer/code/commit.go:
##########
@@ -46,12 +46,33 @@ func (Commit) TableName() string {
 
 type CommitFile struct {
 	common.NoPKModel
-	CommitSha string `gorm:"primaryKey;type:varchar(40)"`
-	FilePath  string `gorm:"primaryKey;type:varchar(255)"`
+	ID        string `gorm:"primaryKey;type:varchar(255)"`

Review Comment:
   Please use the `domainlayer.DomainEntity` instead, check other domain layer entities for reference.



##########
models/domainlayer/code/commit.go:
##########
@@ -46,12 +46,33 @@ func (Commit) TableName() string {
 
 type CommitFile struct {
 	common.NoPKModel
-	CommitSha string `gorm:"primaryKey;type:varchar(40)"`
-	FilePath  string `gorm:"primaryKey;type:varchar(255)"`
+	ID        string `gorm:"primaryKey;type:varchar(255)"`
+	CommitSha string `gorm:"type:varchar(40)"`
+	FilePath  string `gorm:"type:varchar(255)"`
 	Additions int
 	Deletions int
 }
 
 func (CommitFile) TableName() string {
 	return "commit_files"
 }
+
+type Component struct {
+	RepoId    string `gorm:"primaryKey;type:varchar(255)"`
+	Name      string `gorm:"type:varchar(255)"`
+	PathRegex string `gorm:"type:varchar(255)"`
+}
+
+func (Component) TableName() string {
+	return "components"
+}
+
+type CommitFileComponent struct {
+	common.NoPKModel
+	CommitFileID string `gorm:"primaryKey;type:varchar(255)"`
+	Component    string `gorm:"type:varchar(255)"`

Review Comment:
   It should be `ComponentName` if we agreed that `Name` is the PK of `Components` table.



##########
models/migrationscripts/updateSchemas20220711.go:
##########
@@ -0,0 +1,77 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package migrationscripts
+
+import (
+	"context"
+	"github.com/apache/incubator-devlake/models/common"
+	"gorm.io/gorm"
+)
+
+type Component struct {

Review Comment:
   the migration script should be updated if we agreed to the above comments



##########
plugins/gitextractor/models/interface.go:
##########
@@ -27,5 +27,6 @@ type Store interface {
 	Refs(ref *code.Ref) error
 	CommitFiles(file *code.CommitFile) error
 	CommitParents(pp []*code.CommitParent) error
+	FileComponent(component *code.CommitFileComponent) error

Review Comment:
   Lets name it `CommitFileComponents`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] klesh commented on a diff in pull request #2504: feat: add relationship with commit files and its components

Posted by GitBox <gi...@apache.org>.
klesh commented on code in PR #2504:
URL: https://github.com/apache/incubator-devlake/pull/2504#discussion_r926306466


##########
models/domainlayer/code/commit.go:
##########
@@ -45,13 +46,33 @@ func (Commit) TableName() string {
 }
 
 type CommitFile struct {
-	common.NoPKModel
-	CommitSha string `gorm:"primaryKey;type:varchar(40)"`
-	FilePath  string `gorm:"primaryKey;type:varchar(255)"`
+	domainlayer.DomainEntity
+	CommitSha string `gorm:"type:varchar(40)"`
+	FilePath  string `gorm:"type:varchar(255)"`
 	Additions int
 	Deletions int
 }
 
 func (CommitFile) TableName() string {
 	return "commit_files"
 }
+
+type Component struct {

Review Comment:
   It would be better to move `Component` definition to an independent file since it is not part of the `commit` structure, nor do they highly coupled.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] xgdyp commented on a diff in pull request #2504: feat: add relationship with commit files and its components

Posted by GitBox <gi...@apache.org>.
xgdyp commented on code in PR #2504:
URL: https://github.com/apache/incubator-devlake/pull/2504#discussion_r926317268


##########
models/domainlayer/code/commit.go:
##########
@@ -45,13 +46,33 @@ func (Commit) TableName() string {
 }
 
 type CommitFile struct {
-	common.NoPKModel
-	CommitSha string `gorm:"primaryKey;type:varchar(40)"`
-	FilePath  string `gorm:"primaryKey;type:varchar(255)"`
+	domainlayer.DomainEntity
+	CommitSha string `gorm:"type:varchar(40)"`
+	FilePath  string `gorm:"type:varchar(255)"`
 	Additions int
 	Deletions int
 }
 
 func (CommitFile) TableName() string {
 	return "commit_files"
 }
+
+type Component struct {

Review Comment:
   OK!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] abeizn commented on a diff in pull request #2504: feat: add relationship with commit files and its components

Posted by GitBox <gi...@apache.org>.
abeizn commented on code in PR #2504:
URL: https://github.com/apache/incubator-devlake/pull/2504#discussion_r927409705


##########
models/migrationscripts/20220721_commitfile_component.go:
##########
@@ -0,0 +1,77 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package migrationscripts
+
+import (
+	"context"
+	"github.com/apache/incubator-devlake/models/common"
+	"github.com/apache/incubator-devlake/models/domainlayer"
+	"gorm.io/gorm"
+)
+
+type Component struct {
+	RepoId    string `gorm:"type:varchar(255)"`
+	Name      string `gorm:"primaryKey;type:varchar(255)"`
+	PathRegex string `gorm:"type:varchar(255)"`
+}
+
+func (Component) TableName() string {
+	return "components"
+}
+
+type CommitFile struct {
+	domainlayer.DomainEntity
+	CommitSha string `gorm:"type:varchar(40)"`
+	FilePath  string `gorm:"type:varchar(255)"`
+	Additions int
+	Deletions int
+}
+
+func (CommitFile) TableName() string {
+	return "commit_files"
+}
+
+type CommitFileComponent struct {
+	common.NoPKModel
+	CommitFileId  string `gorm:"primaryKey;type:varchar(255)"`
+	ComponentName string `gorm:"type:varchar(255)"`
+}
+
+func (CommitFileComponent) TableName() string {
+	return "commit_file_components"
+}
+
+type commitfileComponent struct{}
+
+func (*commitfileComponent) Up(ctx context.Context, db *gorm.DB) error {
+
+	err := db.Migrator().AutoMigrate(Component{}, CommitFile{}, CommitFileComponent{})

Review Comment:
   otherwise, when it upgrades, the commit_files is not right.
   ![image](https://user-images.githubusercontent.com/101256042/180395671-4085398c-5957-49ed-94e0-223b444aa1f5.png)
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] xgdyp commented on a diff in pull request #2504: feat: add relationship with commit files and its components

Posted by GitBox <gi...@apache.org>.
xgdyp commented on code in PR #2504:
URL: https://github.com/apache/incubator-devlake/pull/2504#discussion_r927404636


##########
models/migrationscripts/20220721_commitfile_component.go:
##########
@@ -0,0 +1,77 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package migrationscripts
+
+import (
+	"context"
+	"github.com/apache/incubator-devlake/models/common"
+	"github.com/apache/incubator-devlake/models/domainlayer"
+	"gorm.io/gorm"
+)
+
+type Component struct {
+	RepoId    string `gorm:"type:varchar(255)"`
+	Name      string `gorm:"primaryKey;type:varchar(255)"`
+	PathRegex string `gorm:"type:varchar(255)"`
+}
+
+func (Component) TableName() string {
+	return "components"
+}
+
+type CommitFile struct {
+	domainlayer.DomainEntity
+	CommitSha string `gorm:"type:varchar(40)"`
+	FilePath  string `gorm:"type:varchar(255)"`
+	Additions int
+	Deletions int
+}
+
+func (CommitFile) TableName() string {
+	return "commit_files"
+}
+
+type CommitFileComponent struct {
+	common.NoPKModel
+	CommitFileId  string `gorm:"primaryKey;type:varchar(255)"`
+	ComponentName string `gorm:"type:varchar(255)"`
+}
+
+func (CommitFileComponent) TableName() string {
+	return "commit_file_components"
+}
+
+type commitfileComponent struct{}
+
+func (*commitfileComponent) Up(ctx context.Context, db *gorm.DB) error {
+
+	err := db.Migrator().AutoMigrate(Component{}, CommitFile{}, CommitFileComponent{})
+	if err != nil {
+		return err
+	}
+	return nil
+
+}
+
+func (*commitfileComponent) Version() uint64 {
+	return 202207211505

Review Comment:
   ok



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] xgdyp commented on pull request #2504: feat: add relationship with commit files and its components

Posted by GitBox <gi...@apache.org>.
xgdyp commented on PR #2504:
URL: https://github.com/apache/incubator-devlake/pull/2504#issuecomment-1188753865

   > @xgdyp Please fix the commit message by following https://www.conventionalcommits.org/en/v1.0.0/#summary
   
   OK, I think it will squash it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] xgdyp commented on pull request #2504: feat: add relationship with commit files and its components

Posted by GitBox <gi...@apache.org>.
xgdyp commented on PR #2504:
URL: https://github.com/apache/incubator-devlake/pull/2504#issuecomment-1191102434

   > @xgdyp Nice work. However, there is a conflict that needs to be dealt with. ![image](https://user-images.githubusercontent.com/61080/180145881-f1e60996-c835-41ca-be66-b7f841fe093e.png)
   
   I'll resolve it now


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] xgdyp commented on a diff in pull request #2504: feat: add relationship with commit files and its components

Posted by GitBox <gi...@apache.org>.
xgdyp commented on code in PR #2504:
URL: https://github.com/apache/incubator-devlake/pull/2504#discussion_r927426445


##########
models/migrationscripts/20220721_commitfile_component.go:
##########
@@ -0,0 +1,77 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package migrationscripts
+
+import (
+	"context"
+	"github.com/apache/incubator-devlake/models/common"
+	"github.com/apache/incubator-devlake/models/domainlayer"
+	"gorm.io/gorm"
+)
+
+type Component struct {
+	RepoId    string `gorm:"type:varchar(255)"`
+	Name      string `gorm:"primaryKey;type:varchar(255)"`
+	PathRegex string `gorm:"type:varchar(255)"`
+}
+
+func (Component) TableName() string {
+	return "components"
+}
+
+type CommitFile struct {
+	domainlayer.DomainEntity
+	CommitSha string `gorm:"type:varchar(40)"`
+	FilePath  string `gorm:"type:varchar(255)"`
+	Additions int
+	Deletions int
+}
+
+func (CommitFile) TableName() string {
+	return "commit_files"
+}
+
+type CommitFileComponent struct {
+	common.NoPKModel
+	CommitFileId  string `gorm:"primaryKey;type:varchar(255)"`
+	ComponentName string `gorm:"type:varchar(255)"`
+}
+
+func (CommitFileComponent) TableName() string {
+	return "commit_file_components"
+}
+
+type commitfileComponent struct{}
+
+func (*commitfileComponent) Up(ctx context.Context, db *gorm.DB) error {
+
+	err := db.Migrator().AutoMigrate(Component{}, CommitFile{}, CommitFileComponent{})

Review Comment:
   thanks!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] xgdyp commented on pull request #2504: feat: add relationship with commit files and its components

Posted by GitBox <gi...@apache.org>.
xgdyp commented on PR #2504:
URL: https://github.com/apache/incubator-devlake/pull/2504#issuecomment-1191133238

   hi Klesh, please review again@Klesh


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org