Documentation ¶
Overview ¶
Package git provides easy API access to Sourcehut Git repositories.
Index ¶
- Constants
- type Author
- type Client
- func (c *Client) DeleteRepo(repo string) error
- func (c *Client) GetUser(username string) (sourcehut.User, error)
- func (c *Client) NewRepo(name, description string, visibility RepoVisibility) (*Repo, error)
- func (c *Client) Repo(username, repo string) (*Repo, error)
- func (c *Client) Repos(username string) (RepoIter, error)
- func (c *Client) UpdateRepo(oldName string, repo *Repo) error
- func (c *Client) Version() (string, error)
- type Commit
- type Option
- type Ref
- type Repo
- type RepoIter
- type RepoVisibility
- type Tree
- type TreeType
Constants ¶
const BaseURL = "https://git.sr.ht/api/"
BaseURL is the default public Sourcehut API URL. It is exported for convenience.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client handles communication with the Sourcehut API.
API docs: https://man.sr.ht/git.sr.ht/api.md
func (*Client) DeleteRepo ¶ added in v0.0.3
DeleteRepo removes a repository.
func (*Client) GetUser ¶
GetUser returns information about the provided username, or the currently authenticated user if the username is empty.
func (*Client) NewRepo ¶ added in v0.0.3
func (c *Client) NewRepo(name, description string, visibility RepoVisibility) (*Repo, error)
NewRepo creates and returns a new repository from the provided template.
func (*Client) Repo ¶ added in v0.0.3
Repo returns information about a specific repository owned by the provided username. If an empty username is provided, the authenticated user is used.
func (*Client) Repos ¶
Repos returns an iterator over all repos owned by the provided username. If an empty username is provided, the authenticated user is used.
func (*Client) UpdateRepo ¶ added in v0.0.3
UpdateRepo updates an existing repository. Only the name, description, and visibility will be modified.
If repo.Name differs from oldName, a redirect from the old name to the new name.
type Commit ¶
type Commit struct { ID string `json:"id"` ShortID string `json:"short_id"` Author Author `json:"author"` Committer Author `json:"committer"` Timestamp time.Time `json:"timestamp"` Message string `json:"message"` Tree string `json:"tree"` Signature *struct { Signature string `json:"signature"` Data string `json:"data"` } `json:"signature"` Parents []string `json:"Parents"` }
Commit is a single commit in a repo.
type Option ¶
Option is used to configure an API client.
func Base ¶
Base returns an option that configures the public Sourcehut API URL.
If base does not have a trailing slash, one is added automatically. If unspecified, BaseURL is used.
func SrhtClient ¶
func SrhtClient(client sourcehut.Client) Option
SrhtClient returns an option that configures the client to use the provided sourcehut.Client for API requests. If unspecified, the default sourcehut.Client (with no options of its own) is used.
type Repo ¶
type Repo struct { ID int64 `json:"id"` Created time.Time `json:"created"` Subject string `json:"subject"` Name string `json:"name"` Description string `json:"description"` Visibility RepoVisibility `json:"visibility"` }
Repo represents a repository.
type RepoIter ¶
type RepoIter struct {
*sourcehut.Iter
}
RepoIter is used for iterating over a collection of repos.
type RepoVisibility ¶
type RepoVisibility string
RepoVisibility is the visibility level of a repo.
const ( VisibilityPublic RepoVisibility = "public" VisibilityUnlisted RepoVisibility = "unlisted" VisibilityPrivate RepoVisibility = "private" )
Supported visibility levels.