Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions backend/plugins/github/api/blueprint_v200.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
})

Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}
1 change: 1 addition & 0 deletions backend/plugins/github/models/migrationscripts/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,6 @@ func All() []plugin.MigrationScript {
new(addIndexToGithubJobs),
new(addRefreshTokenFields),
new(modifyTokenExpiresAtToNullable),
new(addPrSizeExcludedFileExtensions),
}
}
29 changes: 15 additions & 14 deletions backend/plugins/github/models/scope_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions config-ui/src/plugins/register/github/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export const GitHubConfig: IPluginConfig = {
tagsLimit: 10,
tagsPattern: '/v\\d+\\.\\d+(\\.\\d+(-rc)*\\d*)*$/',
},
prSizeExcludedFileExtensions: [],
},
},
};
33 changes: 33 additions & 0 deletions config-ui/src/plugins/register/github/transformation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
</>
),
},
Expand Down
Loading