# Generated by `mix github.gen` from docs/github-api/api.github.com.json.
# Do not edit by hand; re-run the task instead.
defmodule Noizu.Github.Api.Git do
@moduledoc """
GitHub `git` API.
"""
import Noizu.Github
@doc """
Create a blob
@see https://docs.github.com/rest/git/blobs#create-a-blob
"""
def create_blob(body, options \\ nil) do
owner = repo_owner(options)
repo = repo_name(options)
url = github_base() <> "/repos/#{owner}/#{repo}/git/blobs"
body = body
api_call(:post, url, body, Noizu.Github.ShortBlob, options)
end
@doc """
Create a commit
@see https://docs.github.com/rest/git/commits#create-a-commit
"""
def create_commit(body, options \\ nil) do
owner = repo_owner(options)
repo = repo_name(options)
url = github_base() <> "/repos/#{owner}/#{repo}/git/commits"
body = body
api_call(:post, url, body, Noizu.Github.GitCommit, options)
end
@doc """
Create a reference
@see https://docs.github.com/rest/git/refs#create-a-reference
"""
def create_ref(body, options \\ nil) do
owner = repo_owner(options)
repo = repo_name(options)
url = github_base() <> "/repos/#{owner}/#{repo}/git/refs"
body = body
api_call(:post, url, body, Noizu.Github.GitRef, options)
end
@doc """
Create a tag object
@see https://docs.github.com/rest/git/tags#create-a-tag-object
"""
def create_tag(body, options \\ nil) do
owner = repo_owner(options)
repo = repo_name(options)
url = github_base() <> "/repos/#{owner}/#{repo}/git/tags"
body = body
api_call(:post, url, body, Noizu.Github.GitTag, options)
end
@doc """
Create a tree
@see https://docs.github.com/rest/git/trees#create-a-tree
"""
def create_tree(body, options \\ nil) do
owner = repo_owner(options)
repo = repo_name(options)
url = github_base() <> "/repos/#{owner}/#{repo}/git/trees"
body = body
api_call(:post, url, body, Noizu.Github.GitTree, options)
end
@doc """
Delete a reference
@see https://docs.github.com/rest/git/refs#delete-a-reference
"""
def delete_ref(ref, options \\ nil) do
owner = repo_owner(options)
repo = repo_name(options)
url = github_base() <> "/repos/#{owner}/#{repo}/git/refs/#{ref}"
body = %{}
api_call(:delete, url, body, Noizu.Github.Raw, options)
end
@doc """
Get a blob
@see https://docs.github.com/rest/git/blobs#get-a-blob
"""
def get_blob(file_sha, options \\ nil) do
owner = repo_owner(options)
repo = repo_name(options)
url = github_base() <> "/repos/#{owner}/#{repo}/git/blobs/#{file_sha}"
body = %{}
api_call(:get, url, body, Noizu.Github.Blob, options)
end
@doc """
Get a commit object
@see https://docs.github.com/rest/git/commits#get-a-commit-object
"""
def get_commit(commit_sha, options \\ nil) do
owner = repo_owner(options)
repo = repo_name(options)
url = github_base() <> "/repos/#{owner}/#{repo}/git/commits/#{commit_sha}"
body = %{}
api_call(:get, url, body, Noizu.Github.GitCommit, options)
end
@doc """
Get a reference
@see https://docs.github.com/rest/git/refs#get-a-reference
"""
def get_ref(ref, options \\ nil) do
owner = repo_owner(options)
repo = repo_name(options)
url = github_base() <> "/repos/#{owner}/#{repo}/git/ref/#{ref}"
body = %{}
api_call(:get, url, body, Noizu.Github.GitRef, options)
end
@doc """
Get a tag
@see https://docs.github.com/rest/git/tags#get-a-tag
"""
def get_tag(tag_sha, options \\ nil) do
owner = repo_owner(options)
repo = repo_name(options)
url = github_base() <> "/repos/#{owner}/#{repo}/git/tags/#{tag_sha}"
body = %{}
api_call(:get, url, body, Noizu.Github.GitTag, options)
end
@doc """
Get a tree
@see https://docs.github.com/rest/git/trees#get-a-tree
"""
def get_tree(tree_sha, options \\ nil) do
owner = repo_owner(options)
repo = repo_name(options)
url =
(
query =
[
get_field(:recursive, options, nil)
]
|> Enum.filter(& &1)
qs = if query == [], do: "", else: "?" <> Enum.join(query, "&")
github_base() <> "/repos/#{owner}/#{repo}/git/trees/#{tree_sha}" <> qs
)
body = %{}
api_call(:get, url, body, Noizu.Github.GitTree, options)
end
@doc """
List matching references
@see https://docs.github.com/rest/git/refs#list-matching-references
"""
def list_matching_refs(ref, options \\ nil) do
owner = repo_owner(options)
repo = repo_name(options)
url = github_base() <> "/repos/#{owner}/#{repo}/git/matching-refs/#{ref}"
body = %{}
api_call(:get, url, body, Noizu.Github.Collection.GitRef, options)
end
@doc """
Update a reference
@see https://docs.github.com/rest/git/refs#update-a-reference
"""
def update_ref(ref, body, options \\ nil) do
owner = repo_owner(options)
repo = repo_name(options)
url = github_base() <> "/repos/#{owner}/#{repo}/git/refs/#{ref}"
body = body
api_call(:patch, url, body, Noizu.Github.GitRef, options)
end
end