stuttgart-things / machineshop

git based CLI interface for managing configuration as code
Apache License 2.0
1 stars 0 forks source link

[FEATURE] [CREATE] - ADD DELETION OF BRANCH #99

Closed patrick-hermann-sva closed 3 months ago

patrick-hermann-sva commented 3 months ago
// DeleteRef deletes a ref from a repository.
//
// GitHub API docs: https://docs.github.com/rest/git/refs#delete-a-reference
//
//meta:operation DELETE /repos/{owner}/{repo}/git/refs/{ref}
func (s *GitService) DeleteRef(ctx context.Context, owner string, repo string, ref string) (*Response, error) {
    ref = strings.TrimPrefix(ref, "refs/")
    u := fmt.Sprintf("repos/%v/%v/git/refs/%v", owner, repo, refURLEscape(ref))
    req, err := s.client.NewRequest("DELETE", u, nil)
    if err != nil {
        return nil, err
    }

    return s.client.Do(ctx, req, nil)
}
patrick-hermann-sva commented 3 months ago

implemented