Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 16 additions & 20 deletions tagpr.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,11 +434,8 @@ func (tp *tagpr) Run(ctx context.Context) error {
parent.Commit.SHA = parent.SHA

// Create a new commit
commit := &github.Commit{
Message: github.Ptr(commitMessage),
Tree: parent.Commit.Tree,
Parents: []*github.Commit{parent.Commit},
}
commit := NewGithubCommit(github.Ptr(commitMessage), parent.Commit.Tree, []*github.Commit{parent.Commit})

if tree != nil {
commit.Tree = tree
}
Expand Down Expand Up @@ -506,11 +503,8 @@ func (tp *tagpr) Run(ctx context.Context) error {
}

// Create a new commit
commit := &github.Commit{
Message: github.Ptr("cherry-pick: " + commitish),
Tree: newCommit.Tree,
Parents: cherryPickCommit.Parents,
}
commit := NewGithubCommit(github.Ptr("cherry-pick: "+commitish), newCommit.Tree, cherryPickCommit.Parents)

tempCommit, resp, err := tp.gh.Git.CreateCommit(ctx, tp.owner, tp.repo, commit, nil)
if err != nil {
showGHError(err, resp)
Expand Down Expand Up @@ -544,11 +538,8 @@ func (tp *tagpr) Run(ctx context.Context) error {
// Create a new commit
// The Author is not set because setting the same Author as the original commit makes it
// difficult to create a Verified Commit.
commit = &github.Commit{
Message: cherryPickCommit.Commit.Message,
Tree: mergeCommit.Commit.Tree,
Parents: []*github.Commit{newCommit},
}
commit = NewGithubCommit(cherryPickCommit.Commit.Message, mergeCommit.Commit.Tree, []*github.Commit{newCommit})

newCommit, resp, err = tp.gh.Git.CreateCommit(ctx, tp.owner, tp.repo, commit, nil)
if err != nil {
showGHError(err, resp)
Expand Down Expand Up @@ -649,11 +640,8 @@ func (tp *tagpr) Run(ctx context.Context) error {
return err
}
// Create a new commit
commit = &github.Commit{
Message: github.Ptr(changelogMessage),
Tree: tree,
Parents: []*github.Commit{newCommit},
}
commit = NewGithubCommit(github.Ptr(changelogMessage), tree, []*github.Commit{newCommit})

newCommit, resp, err = tp.gh.Git.CreateCommit(ctx, tp.owner, tp.repo, commit, nil)
if err != nil {
showGHError(err, resp)
Expand Down Expand Up @@ -926,3 +914,11 @@ func buildChunkSearchIssuesQuery(qualifiers string, shasStr string) (chunkQuerie

return chunkQueries
}

func NewGithubCommit(message *string, tree *github.Tree, parents []*github.Commit) *github.Commit {
return &github.Commit{
Message: message,
Tree: tree,
Parents: parents,
}
}
Loading