Delete via api
This commit is contained in:
parent
ff97fc138d
commit
9113092f5c
3 changed files with 9 additions and 7 deletions
|
|
@ -1014,6 +1014,14 @@ func PullRequestReady(client *Client, repo ghrepo.Interface, pr *PullRequest) er
|
|||
return err
|
||||
}
|
||||
|
||||
func BranchDeleteRemote(client *Client, repo ghrepo.Interface, branch string) error {
|
||||
var response struct {
|
||||
NodeID string `json:"node_id"`
|
||||
}
|
||||
path := fmt.Sprintf("/repos/%s/%s/git/refs/heads/%s", repo.RepoOwner, repo.RepoName, branch)
|
||||
return client.REST("GET", path, nil, &response)
|
||||
}
|
||||
|
||||
func min(a, b int) int {
|
||||
if a < b {
|
||||
return a
|
||||
|
|
|
|||
|
|
@ -586,7 +586,7 @@ func prMerge(cmd *cobra.Command, args []string) error {
|
|||
}
|
||||
}
|
||||
|
||||
err = git.DeleteRemoteBranch(pr.HeadRefName)
|
||||
err = api.BranchDeleteRemote(apiClient, baseRepo, pr.HeadRefName)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("failed to delete remote branch %s: %w", utils.Cyan(pr.HeadRefName), err)
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -209,12 +209,6 @@ func DeleteLocalBranch(branch string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
func DeleteRemoteBranch(branch string) error {
|
||||
configCmd := GitCommand("push", "origin", "--delete", branch)
|
||||
_, err := run.PrepareCmd(configCmd).Output()
|
||||
return err
|
||||
}
|
||||
|
||||
func HasLocalBranch(branch string) bool {
|
||||
configCmd := GitCommand("rev-parse", "--verify", "refs/heads/"+branch)
|
||||
_, err := run.PrepareCmd(configCmd).Output()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue