Documentation
¶
Overview ¶
Package hut provides access to SourceHut (git.sr.ht, todo.sr.ht and lists.sr.ht) via their GraphQL APIs.
SourceHut removed its legacy REST APIs in late 2025; every service now exposes a single GraphQL endpoint (/query) authenticated with an OAuth 2.0 bearer token. The username is resolved from the token (the `me` query), so it is no longer required in the config.
Index ¶
- type Client
- func (c *Client) CloseIssue(ctx context.Context, repo string, number int) error
- func (c *Client) ClosePR(ctx context.Context, repo string, number int) error
- func (c *Client) CommentIssue(ctx context.Context, repo string, number int, body string) error
- func (c *Client) CommentPR(ctx context.Context, repo string, number int, body string) error
- func (c *Client) CreateIssue(ctx context.Context, in operations.IssueInput) (operations.IssueDetail, error)
- func (c *Client) CreatePR(ctx context.Context, in operations.PRInput) (operations.PRDetail, error)
- func (c *Client) CreateRepo(ctx context.Context, in operations.RepoInput) (operations.Repo, error)
- func (c *Client) DeleteRepo(ctx context.Context, fullName string) error
- func (c *Client) FetchSpec(ctx context.Context, repo string, number int) (operations.FetchSpec, error)
- func (c *Client) GetIssue(ctx context.Context, repo string, number int) (operations.IssueDetail, error)
- func (c *Client) GetPR(ctx context.Context, repo string, number int) (operations.PRDetail, error)
- func (c *Client) ListIssues(ctx context.Context) ([]operations.Issue, error)
- func (c *Client) ListPRs(ctx context.Context) ([]operations.PR, error)
- func (c *Client) ListProjects(ctx context.Context) ([]operations.Project, error)
- func (c *Client) ListRepos(ctx context.Context) ([]operations.Repo, error)
- func (c *Client) ListRuns(ctx context.Context, fullName string) ([]operations.Run, error)
- func (c *Client) ListWorkflows(ctx context.Context, fullName string) ([]operations.Workflow, error)
- func (c *Client) MergePR(ctx context.Context, repo string, number int, opts operations.MergeOptions) error
- func (c *Client) Name() string
- func (c *Client) PRDiff(ctx context.Context, repo string, number int) (string, error)
- func (c *Client) RenameRepo(ctx context.Context, fullName, newName string) (operations.Repo, error)
- func (c *Client) SetForgeLabel(label string)
- func (c *Client) SetInstance(name string)
- func (c *Client) SetVisibility(ctx context.Context, fullName string, private bool) (operations.Repo, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to the SourceHut GraphQL services on behalf of the configured user.
func New ¶
func New(cfg operations.SourceHutConfig) (*Client, error)
New builds a SourceHut client from the given credentials.
func (*Client) CloseIssue ¶
CloseIssue closes a ticket by moving it to the closed status.
func (*Client) ClosePR ¶
ClosePR closes a patchset.
lists.sr.ht has no patchset state change: a patchset's status is driven by reviewer actions, so the patchset is deleted instead, which is the only way to withdraw one from review.
func (*Client) CommentIssue ¶
CommentIssue adds a comment to a ticket.
func (*Client) CommentPR ¶
CommentPR adds a comment to a patchset.
lists.sr.ht threads comments by thread id rather than by patchset number, so the patchset's thread is resolved first.
func (*Client) CreateIssue ¶
func (c *Client) CreateIssue(ctx context.Context, in operations.IssueInput) (operations.IssueDetail, error)
CreateIssue opens a new ticket on a tracker.
func (*Client) CreatePR ¶
func (c *Client) CreatePR(ctx context.Context, in operations.PRInput) (operations.PRDetail, error)
CreatePR opens a patchset.
The head branch and commit cannot be set through the API: SourceHut accepts patches by email or over the git push-email interface, so the caller supplies the pushed state and forgit records the resulting patchset.
func (*Client) CreateRepo ¶
func (c *Client) CreateRepo(ctx context.Context, in operations.RepoInput) (operations.Repo, error)
CreateRepo creates a git.sr.ht repository owned by the authenticated user.
func (*Client) DeleteRepo ¶
DeleteRepo deletes a repository. fullName is user/name.
func (*Client) FetchSpec ¶
func (c *Client) FetchSpec(ctx context.Context, repo string, number int) (operations.FetchSpec, error)
FetchSpec returns how to fetch a patchset's branch locally.
SourceHut has no pull request ref namespace. A patchset is a mail series whose commits a maintainer applies to a branch, so there is no single ref that stands in for the review. The caller must name the branch to fetch.
func (*Client) GetIssue ¶
func (c *Client) GetIssue(ctx context.Context, repo string, number int) (operations.IssueDetail, error)
GetIssue returns a single ticket in full.
func (*Client) GetPR ¶
GetPR returns a single patchset in full.
SourceHut's pull request analogue is a patchset on a mailing list. Patchsets are not strictly per-repository: a single patchset may carry changes for several repositories, so repo is the mailing list name here.
func (*Client) ListIssues ¶
ListIssues returns open tickets across the authenticated user's trackers.
func (*Client) ListPRs ¶
ListPRs returns open patchsets across the authenticated user's mailing lists.
func (*Client) ListProjects ¶
ListProjects returns ErrNotSupported: sourcehut has no project concept equivalent to GitHub/GitLab projects.
func (*Client) ListRuns ¶
ListRuns returns builds.sr.ht jobs associated with a repository. fullName is user/name.
builds.sr.ht jobs are owned by a user, not by a repository: the GraphQL API offers no per-repository job query. Jobs submitted by git.sr.ht carry the repository name as one of their tags, so the authenticated user's jobs are listed and filtered on that tag. Manually submitted jobs that do not tag the repository are therefore not reported.
func (*Client) ListWorkflows ¶
ListWorkflows returns ErrNotSupported: sourcehut has no workflow-definition concept. Build manifests (.build.yml) are submitted per job rather than registered on the repository, so there is nothing to enumerate; the jobs themselves are reported by ListRuns.
func (*Client) MergePR ¶
func (c *Client) MergePR(ctx context.Context, repo string, number int, opts operations.MergeOptions) error
MergePR merges a patchset.
SourceHut has no merge button: patches are applied by a maintainer with git-am or the series-merge helper on the repository itself.
func (*Client) PRDiff ¶
PRDiff returns the diff of a patchset.
lists.sr.ht does not expose a diff through GraphQL; each patchset revision is an ordinary git patch whose series is fetched from git.sr.ht, so the unified diff is produced locally from the fetched commits instead of the API.
func (*Client) RenameRepo ¶
RenameRepo renames a repository. fullName is user/name.
func (*Client) SetForgeLabel ¶
SetForgeLabel overrides the forge label the client stamps on returned resources. Used to give user-named aliases the right identity in listings while the SourceHut client does the API work.
func (*Client) SetInstance ¶
SetInstance names this client's instance (default: the forge type).
func (*Client) SetVisibility ¶
func (c *Client) SetVisibility(ctx context.Context, fullName string, private bool) (operations.Repo, error)
SetVisibility changes whether a repository is private. fullName is user/name.