mirror of
https://github.com/apricote/releaser-pleaser.git
synced 2026-02-07 10:17:02 +00:00
refactor: resuse general PR struct
This commit is contained in:
parent
36a0b90bcd
commit
929d00d696
3 changed files with 18 additions and 14 deletions
|
|
@ -526,9 +526,7 @@ func gitHubPRToReleasePullRequest(pr *github.PullRequest) *releasepr.ReleasePull
|
||||||
}
|
}
|
||||||
|
|
||||||
return &releasepr.ReleasePullRequest{
|
return &releasepr.ReleasePullRequest{
|
||||||
ID: pr.GetNumber(),
|
PullRequest: *gitHubPRToPullRequest(pr),
|
||||||
Title: pr.GetTitle(),
|
|
||||||
Description: pr.GetBody(),
|
|
||||||
Labels: labels,
|
Labels: labels,
|
||||||
|
|
||||||
Head: pr.GetHead().GetRef(),
|
Head: pr.GetHead().GetRef(),
|
||||||
|
|
|
||||||
|
|
@ -28,14 +28,9 @@ func init() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReleasePullRequest
|
|
||||||
//
|
|
||||||
// TODO: Reuse [git.PullRequest]
|
|
||||||
type ReleasePullRequest struct {
|
type ReleasePullRequest struct {
|
||||||
ID int
|
git.PullRequest
|
||||||
Title string
|
Labels []Label
|
||||||
Description string
|
|
||||||
Labels []Label
|
|
||||||
|
|
||||||
Head string
|
Head string
|
||||||
ReleaseCommit *git.Commit
|
ReleaseCommit *git.Commit
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import (
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
|
"github.com/apricote/releaser-pleaser/internal/git"
|
||||||
"github.com/apricote/releaser-pleaser/internal/versioning"
|
"github.com/apricote/releaser-pleaser/internal/versioning"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -36,7 +37,9 @@ func TestReleasePullRequest_GetOverrides(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "prefix in description",
|
name: "prefix in description",
|
||||||
pr: ReleasePullRequest{
|
pr: ReleasePullRequest{
|
||||||
Description: "```rp-prefix\n## Foo\n\n- Cool thing\n```",
|
PullRequest: git.PullRequest{
|
||||||
|
Description: "```rp-prefix\n## Foo\n\n- Cool thing\n```",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
want: ReleaseOverrides{Prefix: "## Foo\n\n- Cool thing"},
|
want: ReleaseOverrides{Prefix: "## Foo\n\n- Cool thing"},
|
||||||
wantErr: assert.NoError,
|
wantErr: assert.NoError,
|
||||||
|
|
@ -44,7 +47,9 @@ func TestReleasePullRequest_GetOverrides(t *testing.T) {
|
||||||
{
|
{
|
||||||
name: "suffix in description",
|
name: "suffix in description",
|
||||||
pr: ReleasePullRequest{
|
pr: ReleasePullRequest{
|
||||||
Description: "```rp-suffix\n## Compatibility\n\nNo compatibility guarantees.\n```",
|
PullRequest: git.PullRequest{
|
||||||
|
Description: "```rp-suffix\n## Compatibility\n\nNo compatibility guarantees.\n```",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
want: ReleaseOverrides{Suffix: "## Compatibility\n\nNo compatibility guarantees."},
|
want: ReleaseOverrides{Suffix: "## Compatibility\n\nNo compatibility guarantees."},
|
||||||
wantErr: assert.NoError,
|
wantErr: assert.NoError,
|
||||||
|
|
@ -105,7 +110,9 @@ Suffix Things
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
pr := &ReleasePullRequest{
|
pr := &ReleasePullRequest{
|
||||||
Description: tt.description,
|
PullRequest: git.PullRequest{
|
||||||
|
Description: tt.description,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
got, err := pr.ChangelogText()
|
got, err := pr.ChangelogText()
|
||||||
if !tt.wantErr(t, err, fmt.Sprintf("ChangelogText()")) {
|
if !tt.wantErr(t, err, fmt.Sprintf("ChangelogText()")) {
|
||||||
|
|
@ -129,7 +136,11 @@ func TestReleasePullRequest_SetTitle(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "simple update",
|
name: "simple update",
|
||||||
pr: &ReleasePullRequest{Title: "foo: bar"},
|
pr: &ReleasePullRequest{
|
||||||
|
PullRequest: git.PullRequest{
|
||||||
|
Title: "foo: bar",
|
||||||
|
},
|
||||||
|
},
|
||||||
args: args{
|
args: args{
|
||||||
branch: "main",
|
branch: "main",
|
||||||
version: "v1.0.0",
|
version: "v1.0.0",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue