mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-12 12:15:00 +00:00
50ddc61576
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [github.com/google/go-github/v60](https://togithub.com/google/go-github) | `v60.0.0` -> `v61.0.0` | [![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fgoogle%2fgo-github%2fv60/v61.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fgoogle%2fgo-github%2fv60/v61.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fgoogle%2fgo-github%2fv60/v60.0.0/v61.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fgoogle%2fgo-github%2fv60/v60.0.0/v61.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>google/go-github (github.com/google/go-github/v60)</summary> ### [`v61.0.0`](https://togithub.com/google/go-github/releases/tag/v61.0.0) [Compare Source](https://togithub.com/google/go-github/compare/v60.0.0...v61.0.0) This release contains the following breaking API changes: - feat!: Update deprecated endpoints in github/action_variables.go ([#​3104](https://togithub.com/google/go-github/issues/3104)) ...and the following additional changes: - Bump go-github from v59 to v60 in /scrape ([#​3087](https://togithub.com/google/go-github/issues/3087)) - Allow querying rule set information by ID with information returned from GetRulesFromBranch ([#​3089](https://togithub.com/google/go-github/issues/3089)) - Bump codecov/codecov-action from 4.0.2 to 4.1.0 ([#​3091](https://togithub.com/google/go-github/issues/3091)) - Bump github.com/PuerkitoBio/goquery from 1.9.0 to 1.9.1 in /scrape ([#​3092](https://togithub.com/google/go-github/issues/3092)) - Add Protection to Branch struct ([#​3095](https://togithub.com/google/go-github/issues/3095)) - Bump github.com/alecthomas/kong from 0.8.1 to 0.9.0 in /tools ([#​3097](https://togithub.com/google/go-github/issues/3097)) - Bump golang.org/x/net from 0.21.0 to 0.22.0 in /scrape ([#​3096](https://togithub.com/google/go-github/issues/3096)) - Bump google.golang.org/protobuf from 1.28.0 to 1.33.0 in /example ([#​3099](https://togithub.com/google/go-github/issues/3099)) - Add audit log rate limit category and make rate limit category getter public ([#​3088](https://togithub.com/google/go-github/issues/3088)) - Update README.md ([#​3110](https://togithub.com/google/go-github/issues/3110)) - Allow Installation of Custom Properties Permissions ([#​3108](https://togithub.com/google/go-github/issues/3108)) - Add NotificationSetting to NewTeam ([#​3111](https://togithub.com/google/go-github/issues/3111)) - Fix pagination for ListCopilotSeats ([#​3112](https://togithub.com/google/go-github/issues/3112)) - Add .\*.local to .gitignore ([#​3115](https://togithub.com/google/go-github/issues/3115)) - Add CreateOrUpdateRepoCustomPropertyValues ([#​3109](https://togithub.com/google/go-github/issues/3109)) - Bump version of go-github to v61.0.0 ([#​3118](https://togithub.com/google/go-github/issues/3118)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - "every weekend" (UTC), Automerge - "before 4am" (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 [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/woodpecker-ci/woodpecker). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNjkuMiIsInVwZGF0ZWRJblZlciI6IjM3LjI2OS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
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/v61/github"
|
|
|
|
"go.woodpecker-ci.org/woodpecker/v2/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()),
|
|
SCMKind: model.RepoGit,
|
|
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))
|
|
}
|
|
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(),
|
|
SCMKind: model.RepoGit,
|
|
PREnabled: true,
|
|
}
|
|
if repo.FullName == "" {
|
|
repo.FullName = repo.Owner + "/" + repo.Name
|
|
}
|
|
return repo
|
|
}
|
|
|
|
// covertLabels 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
|
|
}
|