mirror of
https://codeberg.org/crowci/crow.git
synced 2025-08-09 07:42:52 +03:00
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [github.com/google/go-github/v69](https://github.com/google/go-github) | require | major | `v69.2.0` -> `v70.0.0` | --- ### Release Notes <details> <summary>google/go-github (github.com/google/go-github/v69)</summary> ### [`v70.0.0`](https://github.com/google/go-github/releases/tag/v70.0.0) [Compare Source](https://github.com/google/go-github/compare/v69.2.0...v70.0.0) This release contains the following breaking API changes: - feat!: Add support for network-configurations endpoints for organization ([#​3511](https://github.com/google/go-github/issues/3511)) BREAKING CHANGE: `EnterpriseNetwork*` structs have been replaced with `Network*` structs. - refactor!: Update package types to align with webhook event ([#​3515](https://github.com/google/go-github/issues/3515)) BREAKING CHANGE: `PackageVersion.Body` and `PackageVersion.Metadata` are both now `json.RawMessage`. ...and the following additional changes: - build(deps): bump github.com/alecthomas/kong from 1.8.0 to 1.8.1 in /tools ([#​3485](https://github.com/google/go-github/issues/3485)) - build(deps): bump github.com/google/go-github/v69 from 69.0.0 to 69.2.0 in /scrape ([#​3483](https://github.com/google/go-github/issues/3483)) - build(deps): bump github.com/google/go-cmp from 0.6.0 to 0.7.0 in /tools ([#​3490](https://github.com/google/go-github/issues/3490)) - Bump github.com/google/go-cmp from 0.6.0 to 0.7.0 ([#​3494](https://github.com/google/go-github/issues/3494)) - build(deps): bump actions/cache from 4.2.0 to 4.2.1 in the actions group ([#​3492](https://github.com/google/go-github/issues/3492)) - fix: Resolve '400 Custom domains' error on GitHub Enterprise Server ([#​3489](https://github.com/google/go-github/issues/3489)) - Correct the runIDFromURLRE regex to properly match the callbackURL ([#​3495](https://github.com/google/go-github/issues/3495)) - feat: Add support for GitHub-hosted runner API endpoints ([#​3487](https://github.com/google/go-github/issues/3487)) - feat: Add support for network-configurations endpoints ([#​3497](https://github.com/google/go-github/issues/3497)) - build(deps): bump codecov/codecov-action from 5.3.1 to 5.4.0 ([#​3500](https://github.com/google/go-github/issues/3500)) - build(deps): bump actions/cache from 4.2.1 to 4.2.2 in the actions group ([#​3499](https://github.com/google/go-github/issues/3499)) - Add created_at field to Reaction ([#​3501](https://github.com/google/go-github/issues/3501)) - Add reason parameter to MergeGroupEvent ([#​3508](https://github.com/google/go-github/issues/3508)) - fix(ci): ensure 'auto' toolchain applies to generate ([#​3436](https://github.com/google/go-github/issues/3436)) - Bump dependency versions from dependabot warnings ([#​3512](https://github.com/google/go-github/issues/3512)) - Bump go-jose to v4.0.5 ([#​3513](https://github.com/google/go-github/issues/3513)) - build(deps): bump golang.org/x/net from 0.33.0 to 0.36.0 in /example ([#​3514](https://github.com/google/go-github/issues/3514)) - docs: Update readme and examples for updated go-github-ratelimit and introduce go-github-pagination ([#​3504](https://github.com/google/go-github/issues/3504)) - Add validity filter to secret scanning alert list options ([#​3516](https://github.com/google/go-github/issues/3516)) - build(deps): bump github.com/alecthomas/kong from 1.8.1 to 1.9.0 in /tools ([#​3518](https://github.com/google/go-github/issues/3518)) - build(deps): bump github.com/getkin/kin-openapi from 0.129.0 to 0.130.0 in /tools ([#​3517](https://github.com/google/go-github/issues/3517)) - feat: Add automatic_copilot_code_review_enabled parameter to ruleset API ([#​3506](https://github.com/google/go-github/issues/3506)) - Bump version of go-github to v70.0.0 ([#​3520](https://github.com/google/go-github/issues/3520)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - "* * * * 0,6" (UTC), Automerge - "* 0-3 * * *" (UTC). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4yMTEuMCIsInVwZGF0ZWRJblZlciI6IjM5LjIxMS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmN5IPCfk6bvuI8iXX0=--> Reviewed-on: https://codeberg.org/crowci/crow/pulls/115 Co-authored-by: crowci-bot <admin@crowci.dev> Co-committed-by: crowci-bot <admin@crowci.dev>
172 lines
5.1 KiB
Go
172 lines
5.1 KiB
Go
// Copyright 2022 Woodpecker Authors
|
|
// Copyright 2018 Drone.IO Inc.
|
|
//
|
|
// Licensed 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 github
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/google/go-github/v70/github"
|
|
|
|
"codeberg.org/crowci/crow/v3/server/model"
|
|
)
|
|
|
|
const (
|
|
statusPending = "pending"
|
|
statusSuccess = "success"
|
|
statusFailure = "failure"
|
|
statusError = "error"
|
|
)
|
|
|
|
const (
|
|
descPending = "this pipeline is pending"
|
|
descSuccess = "the pipeline was successful"
|
|
descFailure = "the pipeline failed"
|
|
descBlocked = "the pipeline requires approval"
|
|
descDeclined = "the pipeline was rejected"
|
|
descError = "oops, something went wrong"
|
|
)
|
|
|
|
const (
|
|
headRefs = "refs/pull/%d/head" // pull request unmerged
|
|
mergeRefs = "refs/pull/%d/merge" // pull request merged with base
|
|
refSpec = "%s:%s"
|
|
)
|
|
|
|
// convertStatus is a helper function used to convert a Woodpecker status to a
|
|
// GitHub commit status.
|
|
func convertStatus(status model.StatusValue) string {
|
|
switch status {
|
|
case model.StatusPending, model.StatusRunning, model.StatusBlocked, model.StatusSkipped:
|
|
return statusPending
|
|
case model.StatusFailure, model.StatusDeclined:
|
|
return statusFailure
|
|
case model.StatusSuccess:
|
|
return statusSuccess
|
|
default:
|
|
return statusError
|
|
}
|
|
}
|
|
|
|
// convertDesc is a helper function used to convert a Woodpecker status to a
|
|
// GitHub status description.
|
|
func convertDesc(status model.StatusValue) string {
|
|
switch status {
|
|
case model.StatusPending, model.StatusRunning:
|
|
return descPending
|
|
case model.StatusSuccess:
|
|
return descSuccess
|
|
case model.StatusFailure:
|
|
return descFailure
|
|
case model.StatusBlocked:
|
|
return descBlocked
|
|
case model.StatusDeclined:
|
|
return descDeclined
|
|
default:
|
|
return descError
|
|
}
|
|
}
|
|
|
|
// convertRepo is a helper function used to convert a GitHub repository
|
|
// structure to the common Woodpecker repository structure.
|
|
func convertRepo(from *github.Repository) *model.Repo {
|
|
repo := &model.Repo{
|
|
ForgeRemoteID: model.ForgeRemoteID(fmt.Sprint(from.GetID())),
|
|
Name: from.GetName(),
|
|
FullName: from.GetFullName(),
|
|
ForgeURL: from.GetHTMLURL(),
|
|
IsSCMPrivate: from.GetPrivate(),
|
|
Clone: from.GetCloneURL(),
|
|
CloneSSH: from.GetSSHURL(),
|
|
Branch: from.GetDefaultBranch(),
|
|
Owner: from.GetOwner().GetLogin(),
|
|
Avatar: from.GetOwner().GetAvatarURL(),
|
|
Perm: convertPerm(from.GetPermissions()),
|
|
PREnabled: true,
|
|
}
|
|
return repo
|
|
}
|
|
|
|
// convertPerm is a helper function used to convert a GitHub repository
|
|
// permissions to the common Woodpecker permissions structure.
|
|
func convertPerm(perm map[string]bool) *model.Perm {
|
|
return &model.Perm{
|
|
Admin: perm["admin"],
|
|
Push: perm["push"],
|
|
Pull: perm["pull"],
|
|
}
|
|
}
|
|
|
|
// convertRepoList is a helper function used to convert a GitHub repository
|
|
// list to the common Woodpecker repository structure.
|
|
func convertRepoList(from []*github.Repository) []*model.Repo {
|
|
var repos []*model.Repo
|
|
for _, repo := range from {
|
|
repos = append(repos, convertRepo(repo))
|
|
}
|
|
fmt.Print("test")
|
|
return repos
|
|
}
|
|
|
|
// convertTeamList is a helper function used to convert a GitHub team list to
|
|
// the common Woodpecker repository structure.
|
|
func convertTeamList(from []*github.Organization) []*model.Team {
|
|
var teams []*model.Team
|
|
for _, team := range from {
|
|
teams = append(teams, convertTeam(team))
|
|
}
|
|
return teams
|
|
}
|
|
|
|
// convertTeam is a helper function used to convert a GitHub team structure
|
|
// to the common Woodpecker repository structure.
|
|
func convertTeam(from *github.Organization) *model.Team {
|
|
return &model.Team{
|
|
Login: from.GetLogin(),
|
|
Avatar: from.GetAvatarURL(),
|
|
}
|
|
}
|
|
|
|
// convertRepoHook is a helper function used to extract the Repository details
|
|
// from a webhook and convert to the common Woodpecker repository structure.
|
|
func convertRepoHook(eventRepo *github.PushEventRepository) *model.Repo {
|
|
repo := &model.Repo{
|
|
ForgeRemoteID: model.ForgeRemoteID(fmt.Sprint(eventRepo.GetID())),
|
|
Owner: eventRepo.GetOwner().GetLogin(),
|
|
Name: eventRepo.GetName(),
|
|
FullName: eventRepo.GetFullName(),
|
|
ForgeURL: eventRepo.GetHTMLURL(),
|
|
IsSCMPrivate: eventRepo.GetPrivate(),
|
|
Clone: eventRepo.GetCloneURL(),
|
|
CloneSSH: eventRepo.GetSSHURL(),
|
|
Branch: eventRepo.GetDefaultBranch(),
|
|
PREnabled: true,
|
|
}
|
|
if repo.FullName == "" {
|
|
repo.FullName = repo.Owner + "/" + repo.Name
|
|
}
|
|
return repo
|
|
}
|
|
|
|
// convertLabels is a helper function used to convert a GitHub label list to
|
|
// the common Woodpecker label structure.
|
|
func convertLabels(from []*github.Label) []string {
|
|
labels := make([]string, len(from))
|
|
for i, label := range from {
|
|
labels[i] = *label.Name
|
|
}
|
|
return labels
|
|
}
|