This is an automated email from the ASF dual-hosted git repository.

klesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new f428fc927 feat(github): Extend exclusion of file extensions to github 
plugin (#8719)
f428fc927 is described below

commit f428fc927fe6ae70dc6f09192f4fc0a8c9ec6329
Author: Ema Abitante <[email protected]>
AuthorDate: Mon Mar 2 13:33:59 2026 +0100

    feat(github): Extend exclusion of file extensions to github plugin (#8719)
    
    * feat(github): extend PR size exclusion for specified file extension to 
github plugin
    
    * fix: register migration script
    
    * fix: move PR size to 'Additional settings' and change so the comma 
doesn't get removed while typing
    
    * fix: linting
---
 backend/plugins/github/api/blueprint_v200.go       | 15 ++++---
 .../20260216_add_pr_size_excluded_extensions.go    | 50 ++++++++++++++++++++++
 .../github/models/migrationscripts/register.go     |  1 +
 backend/plugins/github/models/scope_config.go      | 29 +++++++------
 config-ui/src/plugins/register/github/config.tsx   |  1 +
 .../src/plugins/register/github/transformation.tsx | 33 ++++++++++++++
 6 files changed, 108 insertions(+), 21 deletions(-)

diff --git a/backend/plugins/github/api/blueprint_v200.go 
b/backend/plugins/github/api/blueprint_v200.go
index 708a941b6..6515f24b7 100644
--- a/backend/plugins/github/api/blueprint_v200.go
+++ b/backend/plugins/github/api/blueprint_v200.go
@@ -128,13 +128,14 @@ func makeDataSourcePipelinePlanV200(
                        stage = append(stage, &coreModels.PipelineTask{
                                Plugin: "gitextractor",
                                Options: map[string]interface{}{
-                                       "url":          cloneUrl.String(),
-                                       "name":         githubRepo.FullName,
-                                       "fullName":     githubRepo.FullName,
-                                       "repoId":       
didgen.NewDomainIdGenerator(&models.GithubRepo{}).Generate(connection.ID, 
githubRepo.GithubId),
-                                       "proxy":        connection.Proxy,
-                                       "connectionId": githubRepo.ConnectionId,
-                                       "pluginName":   "github",
+                                       "url":                   
cloneUrl.String(),
+                                       "name":                  
githubRepo.FullName,
+                                       "fullName":              
githubRepo.FullName,
+                                       "repoId":                
didgen.NewDomainIdGenerator(&models.GithubRepo{}).Generate(connection.ID, 
githubRepo.GithubId),
+                                       "proxy":                 
connection.Proxy,
+                                       "connectionId":          
githubRepo.ConnectionId,
+                                       "pluginName":            "github",
+                                       "excludeFileExtensions": 
scopeConfig.PrSizeExcludedFileExtensions,
                                },
                        })
 
diff --git 
a/backend/plugins/github/models/migrationscripts/20260216_add_pr_size_excluded_extensions.go
 
b/backend/plugins/github/models/migrationscripts/20260216_add_pr_size_excluded_extensions.go
new file mode 100644
index 000000000..cfc4337c5
--- /dev/null
+++ 
b/backend/plugins/github/models/migrationscripts/20260216_add_pr_size_excluded_extensions.go
@@ -0,0 +1,50 @@
+/*
+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 (
+       "github.com/apache/incubator-devlake/core/context"
+       "github.com/apache/incubator-devlake/core/errors"
+       "github.com/apache/incubator-devlake/core/plugin"
+       "github.com/apache/incubator-devlake/helpers/migrationhelper"
+)
+
+var _ plugin.MigrationScript = (*addPrSizeExcludedFileExtensions)(nil)
+
+type githubScopeConfig20260216 struct {
+       PrSizeExcludedFileExtensions []string `gorm:"type:json" 
json:"prSizeExcludedFileExtensions" mapstructure:"prSizeExcludedFileExtensions"`
+}
+
+func (githubScopeConfig20260216) TableName() string {
+       return "_tool_github_scope_configs"
+}
+
+type addPrSizeExcludedFileExtensions struct{}
+
+func (script *addPrSizeExcludedFileExtensions) Up(basicRes context.BasicRes) 
errors.Error {
+       return migrationhelper.AutoMigrateTables(
+               basicRes,
+               &githubScopeConfig20260216{},
+       )
+}
+
+func (*addPrSizeExcludedFileExtensions) Version() uint64 { return 
20260216100000 }
+
+func (*addPrSizeExcludedFileExtensions) Name() string {
+       return "add pr_size_excluded_file_extensions to 
_tool_github_scope_configs"
+}
diff --git a/backend/plugins/github/models/migrationscripts/register.go 
b/backend/plugins/github/models/migrationscripts/register.go
index 009497289..65f538f31 100644
--- a/backend/plugins/github/models/migrationscripts/register.go
+++ b/backend/plugins/github/models/migrationscripts/register.go
@@ -57,5 +57,6 @@ func All() []plugin.MigrationScript {
                new(addIndexToGithubJobs),
                new(addRefreshTokenFields),
                new(modifyTokenExpiresAtToNullable),
+               new(addPrSizeExcludedFileExtensions),
        }
 }
diff --git a/backend/plugins/github/models/scope_config.go 
b/backend/plugins/github/models/scope_config.go
index 60b298d36..a19f33db6 100644
--- a/backend/plugins/github/models/scope_config.go
+++ b/backend/plugins/github/models/scope_config.go
@@ -26,20 +26,21 @@ import (
 var _ plugin.ToolLayerScopeConfig = (*GithubScopeConfig)(nil)
 
 type GithubScopeConfig struct {
-       common.ScopeConfig   `mapstructure:",squash" json:",inline" 
gorm:"embedded"`
-       PrType               string            `mapstructure:"prType,omitempty" 
json:"prType" gorm:"type:varchar(255)"`
-       PrComponent          string            
`mapstructure:"prComponent,omitempty" json:"prComponent" 
gorm:"type:varchar(255)"`
-       PrBodyClosePattern   string            
`mapstructure:"prBodyClosePattern,omitempty" json:"prBodyClosePattern" 
gorm:"type:varchar(255)"`
-       IssueSeverity        string            
`mapstructure:"issueSeverity,omitempty" json:"issueSeverity" 
gorm:"type:varchar(255)"`
-       IssuePriority        string            
`mapstructure:"issuePriority,omitempty" json:"issuePriority" 
gorm:"type:varchar(255)"`
-       IssueComponent       string            
`mapstructure:"issueComponent,omitempty" json:"issueComponent" 
gorm:"type:varchar(255)"`
-       IssueTypeBug         string            
`mapstructure:"issueTypeBug,omitempty" json:"issueTypeBug" 
gorm:"type:varchar(255)"`
-       IssueTypeIncident    string            
`mapstructure:"issueTypeIncident,omitempty" json:"issueTypeIncident" 
gorm:"type:varchar(255)"`
-       IssueTypeRequirement string            
`mapstructure:"issueTypeRequirement,omitempty" json:"issueTypeRequirement" 
gorm:"type:varchar(255)"`
-       DeploymentPattern    string            
`mapstructure:"deploymentPattern,omitempty" json:"deploymentPattern" 
gorm:"type:varchar(255)"`
-       ProductionPattern    string            
`mapstructure:"productionPattern,omitempty" json:"productionPattern" 
gorm:"type:varchar(255)"`
-       EnvNamePattern       string            
`mapstructure:"envNamePattern,omitempty" json:"envNamePattern" 
gorm:"type:varchar(255)"`
-       Refdiff              datatypes.JSONMap 
`mapstructure:"refdiff,omitempty" json:"refdiff" swaggertype:"object" 
format:"json"`
+       common.ScopeConfig           `mapstructure:",squash" json:",inline" 
gorm:"embedded"`
+       PrType                       string            
`mapstructure:"prType,omitempty" json:"prType" gorm:"type:varchar(255)"`
+       PrComponent                  string            
`mapstructure:"prComponent,omitempty" json:"prComponent" 
gorm:"type:varchar(255)"`
+       PrBodyClosePattern           string            
`mapstructure:"prBodyClosePattern,omitempty" json:"prBodyClosePattern" 
gorm:"type:varchar(255)"`
+       IssueSeverity                string            
`mapstructure:"issueSeverity,omitempty" json:"issueSeverity" 
gorm:"type:varchar(255)"`
+       IssuePriority                string            
`mapstructure:"issuePriority,omitempty" json:"issuePriority" 
gorm:"type:varchar(255)"`
+       IssueComponent               string            
`mapstructure:"issueComponent,omitempty" json:"issueComponent" 
gorm:"type:varchar(255)"`
+       IssueTypeBug                 string            
`mapstructure:"issueTypeBug,omitempty" json:"issueTypeBug" 
gorm:"type:varchar(255)"`
+       IssueTypeIncident            string            
`mapstructure:"issueTypeIncident,omitempty" json:"issueTypeIncident" 
gorm:"type:varchar(255)"`
+       IssueTypeRequirement         string            
`mapstructure:"issueTypeRequirement,omitempty" json:"issueTypeRequirement" 
gorm:"type:varchar(255)"`
+       DeploymentPattern            string            
`mapstructure:"deploymentPattern,omitempty" json:"deploymentPattern" 
gorm:"type:varchar(255)"`
+       ProductionPattern            string            
`mapstructure:"productionPattern,omitempty" json:"productionPattern" 
gorm:"type:varchar(255)"`
+       EnvNamePattern               string            
`mapstructure:"envNamePattern,omitempty" json:"envNamePattern" 
gorm:"type:varchar(255)"`
+       Refdiff                      datatypes.JSONMap 
`mapstructure:"refdiff,omitempty" json:"refdiff" swaggertype:"object" 
format:"json"`
+       PrSizeExcludedFileExtensions []string          
`mapstructure:"prSizeExcludedFileExtensions" 
json:"prSizeExcludedFileExtensions" gorm:"type:json;serializer:json"`
 }
 
 // GetConnectionId implements plugin.ToolLayerScopeConfig.
diff --git a/config-ui/src/plugins/register/github/config.tsx 
b/config-ui/src/plugins/register/github/config.tsx
index 9a372f984..587f00cb9 100644
--- a/config-ui/src/plugins/register/github/config.tsx
+++ b/config-ui/src/plugins/register/github/config.tsx
@@ -117,6 +117,7 @@ export const GitHubConfig: IPluginConfig = {
         tagsLimit: 10,
         tagsPattern: '/v\\d+\\.\\d+(\\.\\d+(-rc)*\\d*)*$/',
       },
+      prSizeExcludedFileExtensions: [],
     },
   },
 };
diff --git a/config-ui/src/plugins/register/github/transformation.tsx 
b/config-ui/src/plugins/register/github/transformation.tsx
index 0d6473c4d..ef9d4d747 100644
--- a/config-ui/src/plugins/register/github/transformation.tsx
+++ b/config-ui/src/plugins/register/github/transformation.tsx
@@ -442,6 +442,39 @@ const renderCollapseItems = ({
             />
             for calculation
           </div>
+          <h3 style={{ marginBottom: 16, marginTop: 16 }}>
+            <span>PR Size Exclusions</span>
+          </h3>
+          <div style={{ margin: '8px 0' }}>
+            <span>Exclude file extensions (comma-separated, e.g. 
.md,.txt,.json)</span>
+            <Input
+              style={{ width: 360, margin: '0 8px' }}
+              placeholder=".md,.txt,.json"
+              value={(transformation.prSizeExcludedFileExtensions || 
[]).join(',')}
+              onChange={(e) => {
+                // Don't filter during onChange to allow typing commas freely
+                const extensions = e.target.value
+                  .split(',')
+                  .map((s: string) => s.trim());
+                onChangeTransformation({
+                  ...transformation,
+                  prSizeExcludedFileExtensions: extensions,
+                });
+              }}
+              onBlur={(e) => {
+                // Clean up empty entries when user leaves the field
+                const extensions = e.target.value
+                  .split(',')
+                  .map((s: string) => s.trim())
+                  .filter((s: string) => s.length > 0);
+                onChangeTransformation({
+                  ...transformation,
+                  prSizeExcludedFileExtensions: extensions,
+                });
+              }}
+            />
+            <HelpTooltip content="These extensions are ignored when computing 
PR Size (additions/deletions)." />
+          </div>
         </>
       ),
     },

Reply via email to