mirror of
https://github.com/apricote/releaser-pleaser.git
synced 2026-02-10 19:57:03 +00:00
wip
This commit is contained in:
parent
8b3bd3ca27
commit
901b5977e6
5 changed files with 32 additions and 24 deletions
|
|
@ -26,7 +26,7 @@ type Forge interface {
|
|||
|
||||
// EnsureLabelsExist verifies that all desired labels are available on the repository. If labels are missing, they
|
||||
// are created them.
|
||||
EnsureLabelsExist(context.Context, []rp.Label) error
|
||||
EnsureLabelsExist(context.Context, []Label) error
|
||||
|
||||
// PullRequestForBranch returns the open pull request between the branch and Options.BaseBranch. If no open PR
|
||||
// exists, it returns nil.
|
||||
|
|
@ -41,7 +41,7 @@ type Forge interface {
|
|||
|
||||
// SetPullRequestLabels updates the pull/merge request identified through the ID of
|
||||
// the ReleasePullRequest to the current labels.
|
||||
SetPullRequestLabels(ctx context.Context, pr *rp.ReleasePullRequest, remove, add []rp.Label) error
|
||||
SetPullRequestLabels(ctx context.Context, pr *rp.ReleasePullRequest, remove, add []Label) error
|
||||
|
||||
// ClosePullRequest closes the pull/merge request identified through the ID of
|
||||
// the ReleasePullRequest, as it is no longer required.
|
||||
|
|
@ -49,7 +49,7 @@ type Forge interface {
|
|||
|
||||
// PendingReleases returns a list of ReleasePullRequest. The list should contain all pull/merge requests that are
|
||||
// merged and have the matching label.
|
||||
PendingReleases(context.Context, rp.Label) ([]*rp.ReleasePullRequest, error)
|
||||
PendingReleases(context.Context, Label) ([]*rp.ReleasePullRequest, error)
|
||||
|
||||
// CreateRelease creates a release on the Forge, pointing at the commit with the passed in details.
|
||||
CreateRelease(ctx context.Context, commit git.Commit, title, changelog string, prerelease, latest bool) error
|
||||
|
|
@ -59,3 +59,6 @@ type Options struct {
|
|||
Repository string
|
||||
BaseBranch string
|
||||
}
|
||||
|
||||
// Label is the string identifier of a pull/merge request label on the forge.
|
||||
type Label string
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ func (g *GitHub) prForCommit(ctx context.Context, commit git.Commit) (*git.PullR
|
|||
return gitHubPRToPullRequest(pullrequest), nil
|
||||
}
|
||||
|
||||
func (g *GitHub) EnsureLabelsExist(ctx context.Context, labels []rp.Label) error {
|
||||
func (g *GitHub) EnsureLabelsExist(ctx context.Context, labels []forge.Label) error {
|
||||
existingLabels := make([]string, 0, len(labels))
|
||||
|
||||
page := 1
|
||||
|
|
@ -362,7 +362,7 @@ func (g *GitHub) CreatePullRequest(ctx context.Context, pr *rp.ReleasePullReques
|
|||
// TODO: String ID?
|
||||
pr.ID = ghPR.GetNumber()
|
||||
|
||||
err = g.SetPullRequestLabels(ctx, pr, []rp.Label{}, pr.Labels)
|
||||
err = g.SetPullRequestLabels(ctx, pr, []forge.Label{}, pr.Labels)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -385,7 +385,7 @@ func (g *GitHub) UpdatePullRequest(ctx context.Context, pr *rp.ReleasePullReques
|
|||
return nil
|
||||
}
|
||||
|
||||
func (g *GitHub) SetPullRequestLabels(ctx context.Context, pr *rp.ReleasePullRequest, remove, add []rp.Label) error {
|
||||
func (g *GitHub) SetPullRequestLabels(ctx context.Context, pr *rp.ReleasePullRequest, remove, add []forge.Label) error {
|
||||
for _, label := range remove {
|
||||
_, err := g.client.Issues.RemoveLabelForIssue(
|
||||
ctx, g.options.Owner, g.options.Repo,
|
||||
|
|
@ -426,7 +426,7 @@ func (g *GitHub) ClosePullRequest(ctx context.Context, pr *rp.ReleasePullRequest
|
|||
return nil
|
||||
}
|
||||
|
||||
func (g *GitHub) PendingReleases(ctx context.Context, pendingLabel rp.Label) ([]*rp.ReleasePullRequest, error) {
|
||||
func (g *GitHub) PendingReleases(ctx context.Context, pendingLabel forge.Label) ([]*rp.ReleasePullRequest, error) {
|
||||
page := 1
|
||||
|
||||
var prs []*rp.ReleasePullRequest
|
||||
|
|
@ -512,10 +512,10 @@ func gitHubPRToPullRequest(pr *github.PullRequest) *git.PullRequest {
|
|||
}
|
||||
|
||||
func gitHubPRToReleasePullRequest(pr *github.PullRequest) *rp.ReleasePullRequest {
|
||||
labels := make([]rp.Label, 0, len(pr.Labels))
|
||||
labels := make([]forge.Label, 0, len(pr.Labels))
|
||||
for _, label := range pr.Labels {
|
||||
labelName := rp.Label(label.GetName())
|
||||
if slices.Contains(rp.KnownLabels, rp.Label(label.GetName())) {
|
||||
labelName := forge.Label(label.GetName())
|
||||
if slices.Contains(rp.KnownLabels, forge.Label(label.GetName())) {
|
||||
labels = append(labels, labelName)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue