forgejo

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2025 License: MPL-2.0 Imports: 28 Imported by: 0

Documentation

Overview

templ: version: v0.3.943

Index

Constants

This section is empty.

Variables

View Source
var DefaultBaseURL = internal.MustWebURL("https://next.forgejo.org")

Functions

func HandleEvent

func HandleEvent(r *http.Request, secret string) (*vcs.EventPayload, error)

func Icon added in v0.3.24

func Icon() templ.Component

func NewTokenClient

func NewTokenClient(opts vcs.NewTokenClientOptions) (vcs.Client, error)

func RegisterVCSKind added in v0.3.24

func RegisterVCSKind(vcsService *vcs.Service, defaultURL *internal.WebURL, skipTLSVerification bool)

func SendEventRequest

func SendEventRequest(t *testing.T, event string, url, secret string, payload []byte)

SendEventRequest sends a forgejo event via a http request to the url, signed with the secret,

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func (*Client) CreateWebhook

func (c *Client) CreateWebhook(ctx context.Context, opts vcs.CreateWebhookOptions) (string, error)

func (*Client) DeleteWebhook

func (c *Client) DeleteWebhook(ctx context.Context, opts vcs.DeleteWebhookOptions) error

func (*Client) GetCommit

func (c *Client) GetCommit(ctx context.Context, repo vcs.Repo, refname string) (vcs.Commit, error)

GetCommit retrieves commit from the repo with the given git ref

func (*Client) GetDefaultBranch added in v0.3.24

func (c *Client) GetDefaultBranch(ctx context.Context, identifier string) (string, error)

func (*Client) GetRepoTarball

func (c *Client) GetRepoTarball(ctx context.Context, opts vcs.GetRepoTarballOptions) ([]byte, string, error)

func (*Client) GetWebhook

func (c *Client) GetWebhook(ctx context.Context, opts vcs.GetWebhookOptions) (vcs.Webhook, error)

func (*Client) ListPullRequestFiles

func (c *Client) ListPullRequestFiles(ctx context.Context, repo vcs.Repo, pull int) ([]string, error)

ListPullRequestFiles returns the paths of files that are modified in the pull request

func (*Client) ListRepositories

func (c *Client) ListRepositories(ctx context.Context, opts vcs.ListRepositoriesOptions) ([]vcs.Repo, error)

func (*Client) ListTags

func (c *Client) ListTags(ctx context.Context, opts vcs.ListTagsOptions) ([]string, error)

func (*Client) SetStatus

func (c *Client) SetStatus(ctx context.Context, opts vcs.SetStatusOptions) error

func (*Client) UpdateWebhook

func (c *Client) UpdateWebhook(ctx context.Context, id string, opts vcs.UpdateWebhookOptions) error

type GithubEvent

type GithubEvent string

The name of the event sent in the X-Github-Event header

type PullRequestEvent

type PullRequestEvent struct {
	Action      string              `json:"action"`
	CommitID    string              `json:"commit_id"`
	Number      int64               `json:"number"`
	PullRequest forgejo.PullRequest `json:"pull_request"`
	Repository  forgejo.Repository  `json:"repository"`
	Sender      forgejo.User        `json:"sender"`
}

type PushEvent

type PushEvent struct {
	Ref        string             `json:"ref"`
	Before     string             `json:"before"`
	After      string             `json:"after"`
	CompareURL string             `json:"compare_url"`
	HeadCommit *forgejo.Commit    `json:"head_commit"`
	Commits    []forgejo.Commit   `json:"commits"`
	Repository forgejo.Repository `json:"repository"`
	Pusher     forgejo.User       `json:"pusher"`
	Sender     forgejo.User       `json:"sender"`
}

type TestServer

type TestServer struct {

	// webhook created/updated/deleted events channel
	WebhookEvents chan webhookEvent

	*httptest.Server
	// contains filtered or unexported fields
}

func NewTestServer

func NewTestServer(t *testing.T, opts ...TestServerOption) (*TestServer, *url.URL)

func (*TestServer) GetStatus

func (s *TestServer) GetStatus(t *testing.T, ctx context.Context) *forgejo.Status

GetStatus retrieves a commit status event off the queue, timing out after 10 seconds if nothing is on the queue.

func (*TestServer) HasWebhook

func (s *TestServer) HasWebhook() bool

func (*TestServer) SendEvent

func (s *TestServer) SendEvent(t *testing.T, event string, payload []byte)

SendEvent sends an event to the registered webhook.

type TestServerOption

type TestServerOption func(*TestServer)

func WithArchive

func WithArchive(tarball []byte) TestServerOption

func WithCommit

func WithCommit(commit string) TestServerOption

func WithDefaultBranch

func WithDefaultBranch(branch string) TestServerOption

func WithDisableTLS

func WithDisableTLS() TestServerOption

func WithHandler

func WithHandler(path string, h http.HandlerFunc) TestServerOption

func WithHook

func WithHook(hook hook) TestServerOption

func WithPullRequest

func WithPullRequest(pullNumber string, changedPaths ...string) TestServerOption

func WithRefs

func WithRefs(refs ...testref) TestServerOption

func WithRepo

func WithRepo(repo vcs.Repo) TestServerOption

func WithUsername

func WithUsername(username user.Username) TestServerOption

Jump to

Keyboard shortcuts

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