dosubot[bot] commented on issue #7732:
URL:
https://github.com/apache/incubator-devlake/issues/7732#issuecomment-2225327718
<!-- Answer -->
The automatic deletion of project data in the GitLab integration is likely
due to cleanup operations performed at the end of tests. Specifically, the
following code snippet shows the deletion of connections, scope configurations,
blueprints, and scopes:
```go
client.SetExpectedStatusCode(http.StatusConflict).DeleteConnection(pluginName,
connection.ID)
client.DeleteScopeConfig(pluginName, connection.ID, scopeConfig.ID)
client.DeleteBlueprint(bp.ID)
for _, scope := range listedScopes {
project := helper.Cast[pluginmodels.GitlabProject](scope.Scope)
client.DeleteScope(pluginName, connection.ID, project.ScopeId(), false)
}
client.DeleteConnection(pluginName, connection.ID)
```
To resolve this issue, you need to remove or comment out these lines of code
that perform the deletion operations
<sup>[[1]](https://github.com/apache/incubator-devlake/blob/main/backend/test/e2e/manual/gitlab/gitlab_test.go)</sup>.
Additionally, the `DeleteScope` function in the `scope_api.go` file is
responsible for deleting plugin data associated with the scope and optionally
the scope itself. You may want to review and modify this function to ensure it
aligns with your requirements:
```go
// DeleteScope delete plugin data associated with the scope and optionally
the scope itself
// @Summary delete plugin data associated with the scope and optionally the
scope itself
// @Description delete data associated with plugin scope
// @Tags plugins/gitlab
// @Param connectionId path int true "connection ID"
// @Param scopeId path int true "scope ID"
// @Param delete_data_only query bool false "Only delete the scope data, not
the scope itself"
// @Success 200
// @Failure 400 {object} shared.ApiBody "Bad Request"
// @Failure 409 {object} srvhelper.DsRefs "References exist to this scope"
// @Failure 500 {object} shared.ApiBody "Internal Error"
// @Router /plugins/gitlab/connections/{connectionId}/scopes/{scopeId}
[DELETE]
func DeleteScope(input *plugin.ApiResourceInput) (*plugin.ApiResourceOutput,
errors.Error) {
return dsHelper.ScopeApi.Delete(input)
}
```
<sup>[[2]](https://github.com/apache/incubator-devlake/blob/main/backend/plugins/gitlab/api/scope_api.go)</sup>.
The `Collect Data in Full Refresh Mode` might not resolve the issue because
it only affects data within the specified time range. If data outside this
range needs to be deleted or if there are other underlying issues causing data
deletion, this mode will not address those problems
<sup>[[3]](https://github.com/apache/incubator-devlake-website/blob/main/docs/Configuration/Tutorial.md)</sup><sup>[[4]](https://github.com/apache/incubator-devlake-website/blob/main/versioned_docs/version-v0.21/Configuration/Tutorial.md)</sup>.
For more detailed information about data deletion events, you can enable
specific logs or error messages in the `DeleteScope` function, which provides
detailed error messages for different failure scenarios
<sup>[[2]](https://github.com/apache/incubator-devlake/blob/main/backend/plugins/gitlab/api/scope_api.go)</sup>.
<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]