GhEx.Git (gh_ex v0.3.4)

Copy Markdown View Source

Convenience functions for GitHub's Git reference REST API.

References identify branch heads and tags. Read and delete operations accept either a relative reference such as "heads/main" or a fully qualified one such as "refs/heads/main". Create operations likewise accept either form in attrs.ref and send GitHub the required fully qualified refs/... value.

These thin wrappers return the same {:ok, body, meta} / {:error, reason} shape as GhEx.REST and pass opts through to Req.

Summary

Functions

Creates a Git reference pointing at a commit SHA.

Functions

create_ref(client, owner, repo, attrs, opts \\ [])

@spec create_ref(GhEx.Client.t(), String.t(), String.t(), map(), keyword()) ::
  GhEx.REST.result()

Creates a Git reference pointing at a commit SHA.

attrs contains ref and sha. The reference may be relative ("heads/feature" or "tags/v1.0.0") or fully qualified; the request body always uses GitHub's required "refs/..." form.

delete_ref(client, owner, repo, ref, opts \\ [])

@spec delete_ref(GhEx.Client.t(), String.t(), String.t(), String.t(), keyword()) ::
  GhEx.REST.result()

Deletes a Git reference.

ref accepts the same relative or fully qualified forms as get_ref/5. GitHub refuses to delete the repository's default branch.

get_ref(client, owner, repo, ref, opts \\ [])

@spec get_ref(GhEx.Client.t(), String.t(), String.t(), String.t(), keyword()) ::
  GhEx.REST.result()

Gets one Git reference.

ref is a branch or tag path such as "heads/main", "tags/v1.0.0", or either form prefixed with "refs/".