Skip to content

Commit 9113092

Browse files
committed
Delete via api
1 parent ff97fc1 commit 9113092

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

api/queries_pr.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,14 @@ func PullRequestReady(client *Client, repo ghrepo.Interface, pr *PullRequest) er
10141014
return err
10151015
}
10161016

1017+
func BranchDeleteRemote(client *Client, repo ghrepo.Interface, branch string) error {
1018+
var response struct {
1019+
NodeID string `json:"node_id"`
1020+
}
1021+
path := fmt.Sprintf("/repos/%s/%s/git/refs/heads/%s", repo.RepoOwner, repo.RepoName, branch)
1022+
return client.REST("GET", path, nil, &response)
1023+
}
1024+
10171025
func min(a, b int) int {
10181026
if a < b {
10191027
return a

command/pr.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ func prMerge(cmd *cobra.Command, args []string) error {
586586
}
587587
}
588588

589-
err = git.DeleteRemoteBranch(pr.HeadRefName)
589+
err = api.BranchDeleteRemote(apiClient, baseRepo, pr.HeadRefName)
590590
if err != nil {
591591
err = fmt.Errorf("failed to delete remote branch %s: %w", utils.Cyan(pr.HeadRefName), err)
592592
return err

git/git.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,6 @@ func DeleteLocalBranch(branch string) error {
209209
return err
210210
}
211211

212-
func DeleteRemoteBranch(branch string) error {
213-
configCmd := GitCommand("push", "origin", "--delete", branch)
214-
_, err := run.PrepareCmd(configCmd).Output()
215-
return err
216-
}
217-
218212
func HasLocalBranch(branch string) bool {
219213
configCmd := GitCommand("rev-parse", "--verify", "refs/heads/"+branch)
220214
_, err := run.PrepareCmd(configCmd).Output()

0 commit comments

Comments
 (0)