Skip to content
Merged
Show file tree
Hide file tree
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
20 changes: 10 additions & 10 deletions applier.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (a *Applier) Apply(ctx context.Context, f *gitdiff.File) (*github.TreeEntry
if entry.Content != nil {
blob, _, err := a.client.Git.CreateBlob(ctx, a.owner, a.repo, github.Blob{
Content: entry.Content,
Encoding: github.Ptr("base64"),
Encoding: new("base64"),
})
if err != nil {
return nil, fmt.Errorf("create blob failed: %w", err)
Expand Down Expand Up @@ -113,8 +113,8 @@ func (a *Applier) applyCreate(ctx context.Context, f *gitdiff.File) (*github.Tre
path := f.NewName
newEntry := &github.TreeEntry{
Path: &path,
Mode: github.Ptr(getMode(f, nil)),
Type: github.Ptr("blob"),
Mode: new(getMode(f, nil)),
Type: new("blob"),
Content: &c,
}
a.entries[path] = newEntry
Expand Down Expand Up @@ -164,8 +164,8 @@ func (a *Applier) applyModify(ctx context.Context, f *gitdiff.File) (*github.Tre
path := f.NewName
newEntry := &github.TreeEntry{
Path: &path,
Mode: github.Ptr(getMode(f, entry)),
Type: github.Ptr("blob"),
Mode: new(getMode(f, entry)),
Type: new("blob"),
}

if len(f.TextFragments) > 0 || f.BinaryFragment != nil {
Expand Down Expand Up @@ -258,19 +258,19 @@ func (a *Applier) Commit(ctx context.Context, tmpl *github.Commit, header *gitdi
}

c.Tree = &github.Tree{
SHA: github.Ptr(a.tree),
SHA: new(a.tree),
}
c.Parents = []*github.Commit{
a.commit,
}

if header != nil {
c.Message = github.Ptr(header.Message())
c.Message = new(header.Message())
c.Author = makeCommitAuthor(header.Author, header.AuthorDate)
c.Committer = makeCommitAuthor(header.Committer, header.CommitterDate)
}
if c.Message == nil || *c.Message == "" {
c.Message = github.Ptr("Apply patch with patch2pr")
c.Message = new("Apply patch with patch2pr")
}

commit, _, err := a.client.Git.CreateCommit(ctx, a.owner, a.repo, c, nil)
Expand Down Expand Up @@ -407,10 +407,10 @@ func makeCommitAuthor(id *gitdiff.PatchIdentity, d time.Time) *github.CommitAuth
a := &github.CommitAuthor{}
if id != nil {
if id.Name != "" {
a.Name = github.Ptr(id.Name)
a.Name = new(id.Name)
}
if id.Email != "" {
a.Email = github.Ptr(id.Email)
a.Email = new(id.Email)
}
}
if !d.IsZero() {
Expand Down
8 changes: 4 additions & 4 deletions applier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,14 @@ func createBranch(t *testing.T, tctx *TestContext) {
treePath := strings.TrimPrefix(path, root)
entry := github.TreeEntry{
Path: &treePath,
Type: github.Ptr("blob"),
Mode: github.Ptr(getGitMode(info)),
Type: new("blob"),
Mode: new(getGitMode(info)),
}

if strings.HasSuffix(d.Name(), ".bin") {
c := base64.StdEncoding.EncodeToString(content)
blob, _, err := tctx.Client.Git.CreateBlob(tctx, tctx.Repo.Owner, tctx.Repo.Name, github.Blob{
Encoding: github.Ptr("base64"),
Encoding: new("base64"),
Content: &c,
})
if err != nil {
Expand Down Expand Up @@ -314,7 +314,7 @@ func createBranch(t *testing.T, tctx *TestContext) {
}

commitToCreate := github.Commit{
Message: github.Ptr("Base commit for test"),
Message: new("Base commit for test"),
Tree: tree,
}

Expand Down
2 changes: 1 addition & 1 deletion reference.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (r *Reference) Set(ctx context.Context, sha string, force bool) error {
if exists {
if _, _, err := r.client.Git.UpdateRef(ctx, r.owner, r.repo, r.ref, github.UpdateRef{
SHA: sha,
Force: github.Ptr(force),
Force: new(force),
}); err != nil {
return fmt.Errorf("update ref failed: %w", err)
}
Expand Down
Loading