diff --git a/applier.go b/applier.go index 8394cff..1091749 100644 --- a/applier.go +++ b/applier.go @@ -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) @@ -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 @@ -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 { @@ -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) @@ -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() { diff --git a/applier_test.go b/applier_test.go index 6e43530..3f50ed8 100644 --- a/applier_test.go +++ b/applier_test.go @@ -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 { @@ -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, } diff --git a/reference.go b/reference.go index 15bb1c5..4ed01c3 100644 --- a/reference.go +++ b/reference.go @@ -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) }