| /* |
| 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 tasks |
| |
| import ( |
| "github.com/apache/devlake/core/errors" |
| "github.com/apache/devlake/core/plugin" |
| "github.com/apache/devlake/helpers/pluginhelper/api" |
| ) |
| |
| func init() { |
| RegisterSubtaskMeta(&CollectCommitsMeta) |
| } |
| |
| const RawCommitTable = "azuredevops_go_api_commits" |
| |
| var CollectCommitsMeta = plugin.SubTaskMeta{ |
| Name: "collectApiCommits", |
| EntryPoint: CollectApiCommits, |
| EnabledByDefault: false, |
| Description: "Collect commit data from Azure DevOps API", |
| DomainTypes: []string{plugin.DOMAIN_TYPE_CODE, plugin.DOMAIN_TYPE_CROSS}, |
| ProductTables: []string{RawCommitTable}, |
| } |
| |
| func CollectApiCommits(taskCtx plugin.SubTaskContext) errors.Error { |
| rawDataSubTaskArgs, data := CreateRawDataSubTaskArgs(taskCtx, RawCommitTable) |
| |
| collector, err := api.NewApiCollector(api.ApiCollectorArgs{ |
| RawDataSubTaskArgs: *rawDataSubTaskArgs, |
| ApiClient: data.ApiClient, |
| PageSize: 100, |
| Incremental: false, |
| UrlTemplate: "{{ if .Params.OrganizationId }}{{ .Params.OrganizationId }}/{{ end }}{{ .Params.ProjectId }}/_apis/git/repositories/{{ .Params.RepositoryId }}/commits?api-version=7.1", |
| Query: BuildPaginator(false), |
| ResponseParser: ParseRawMessageFromValue, |
| AfterResponse: change203To401, |
| }) |
| |
| if err != nil { |
| return err |
| } |
| |
| return collector.Execute() |
| } |