This is an automated email from the ASF dual-hosted git repository.
abeizn pushed a commit to branch fix-gitlab-scope-config
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/fix-gitlab-scope-config by
this push:
new 31e861f3d fix: nil pointer when gitlab scope config==nil
31e861f3d is described below
commit 31e861f3dab77e59027bca0cacb42d9c6147b3ed
Author: abeizn <[email protected]>
AuthorDate: Thu Nov 2 14:56:52 2023 +0800
fix: nil pointer when gitlab scope config==nil
---
backend/plugins/gitlab/impl/impl.go | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/backend/plugins/gitlab/impl/impl.go
b/backend/plugins/gitlab/impl/impl.go
index bf25186f9..2de57fa02 100644
--- a/backend/plugins/gitlab/impl/impl.go
+++ b/backend/plugins/gitlab/impl/impl.go
@@ -149,7 +149,6 @@ func (p Gitlab) PrepareTaskData(taskCtx plugin.TaskContext,
options map[string]i
if err != nil {
return nil, err
}
-
if op.ProjectId != 0 {
var scope *models.GitlabProject
// support v100 & advance mode
@@ -181,17 +180,21 @@ func (p Gitlab) PrepareTaskData(taskCtx
plugin.TaskContext, options map[string]i
}
}
- if op.ScopeConfig == nil && op.ScopeConfigId != 0 {
- var scopeConfig models.GitlabScopeConfig
- db := taskCtx.GetDal()
- err = db.First(&scopeConfig, dal.Where("id = ?",
op.ScopeConfigId))
- if err != nil {
- if db.IsErrorNotFound(err) {
- return nil, errors.Default.Wrap(err,
fmt.Sprintf("can not find scopeConfigs by scopeConfigId [%d]",
op.ScopeConfigId))
+ if op.ScopeConfig == nil {
+ if op.ScopeConfigId != 0 {
+ var scopeConfig models.GitlabScopeConfig
+ db := taskCtx.GetDal()
+ err = db.First(&scopeConfig, dal.Where("id = ?",
op.ScopeConfigId))
+ if err != nil {
+ if db.IsErrorNotFound(err) {
+ return nil, errors.Default.Wrap(err,
fmt.Sprintf("can not find scopeConfigs by scopeConfigId [%d]",
op.ScopeConfigId))
+ }
+ return nil, errors.Default.Wrap(err,
fmt.Sprintf("fail to find scopeConfigs by scopeConfigId [%d]",
op.ScopeConfigId))
}
- return nil, errors.Default.Wrap(err, fmt.Sprintf("fail
to find scopeConfigs by scopeConfigId [%d]", op.ScopeConfigId))
+ op.ScopeConfig = &scopeConfig
+ } else {
+ op.ScopeConfig = &models.GitlabScopeConfig{}
}
- op.ScopeConfig = &scopeConfig
}
regexEnricher := helper.NewRegexEnricher()