hut

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

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

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

New builds a SourceHut client from the given credentials.

func (*Client) CloseIssue

func (c *Client) CloseIssue(ctx context.Context, repo string, number int) error

CloseIssue closes a ticket by moving it to the closed status.

func (*Client) ClosePR

func (c *Client) ClosePR(ctx context.Context, repo string, number int) error

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

func (c *Client) CommentIssue(ctx context.Context, repo string, number int, body string) error

CommentIssue adds a comment to a ticket.

func (*Client) CommentPR

func (c *Client) CommentPR(ctx context.Context, repo string, number int, body string) error

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

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

func (c *Client) DeleteRepo(ctx context.Context, fullName string) error

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

func (c *Client) GetPR(ctx context.Context, repo string, number int) (operations.PRDetail, error)

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

func (c *Client) ListIssues(ctx context.Context) ([]operations.Issue, error)

ListIssues returns open tickets across the authenticated user's trackers.

func (*Client) ListPRs

func (c *Client) ListPRs(ctx context.Context) ([]operations.PR, error)

ListPRs returns open patchsets across the authenticated user's mailing lists.

func (*Client) ListProjects

func (c *Client) ListProjects(ctx context.Context) ([]operations.Project, error)

ListProjects returns ErrNotSupported: sourcehut has no project concept equivalent to GitHub/GitLab projects.

func (*Client) ListRepos

func (c *Client) ListRepos(ctx context.Context) ([]operations.Repo, error)

ListRepos returns the authenticated user's git.sr.ht repositories.

func (*Client) ListRuns

func (c *Client) ListRuns(ctx context.Context, fullName string) ([]operations.Run, error)

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

func (c *Client) ListWorkflows(ctx context.Context, fullName string) ([]operations.Workflow, error)

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) Name

func (c *Client) Name() string

Name returns the instance name.

func (*Client) PRDiff

func (c *Client) PRDiff(ctx context.Context, repo string, number int) (string, error)

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

func (c *Client) RenameRepo(ctx context.Context, fullName, newName string) (operations.Repo, error)

RenameRepo renames a repository. fullName is user/name.

func (*Client) SetForgeLabel

func (c *Client) SetForgeLabel(label string)

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

func (c *Client) SetInstance(name string)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL