gitstore

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GitStore

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

func New

func New(basePath string) (*GitStore, error)

func (*GitStore) Archive

func (g *GitStore) Archive(owner, slug, version string) (io.ReadCloser, error)

Archive generates a zip archive for a version, streaming output.

func (*GitStore) BasePath

func (g *GitStore) BasePath() string

BasePath returns the base path of the git store.

func (*GitStore) Exists

func (g *GitStore) Exists(owner, slug string) bool

Exists checks if a repo exists.

func (*GitStore) GetFile

func (g *GitStore) GetFile(owner, slug, version, path string) ([]byte, error)

GetFile reads a single file from a specific version.

func (*GitStore) InitRepo

func (g *GitStore) InitRepo(owner, slug string) error

InitRepo creates a bare repo (idempotent).

func (*GitStore) ListTags

func (g *GitStore) ListTags(owner, slug string) ([]string, error)

ListTags returns all version tags sorted by semver descending.

func (*GitStore) Mirror

func (g *GitStore) Mirror(owner, slug, destPath string) error

Mirror clones a bare repo for backup.

func (*GitStore) Publish

func (g *GitStore) Publish(ctx context.Context, opts PublishOpts) (string, error)

Publish writes files into the repo and creates a version tag.

func (*GitStore) Rename

func (g *GitStore) Rename(owner, oldSlug, newSlug string) error

Rename renames a repo and creates a symlink from old to new.

func (*GitStore) RepoPath

func (g *GitStore) RepoPath(owner, slug string) string

RepoPath returns the bare repo path: {basePath}/{owner}/{slug}.git

type ImportOpts

type ImportOpts struct {
	Slug       string
	OwnerID    string
	TagPattern string
}

type ImportService

type ImportService struct {

	// onNewVersion is called when a new version is imported.
	// It should be set by the caller (e.g., SkillService) to register the version.
	OnNewVersion func(ctx context.Context, owner, slug, version string, repoPath string) error
	// contains filtered or unexported fields
}

func NewImportService

func NewImportService(gs *GitStore, cfg config.ImportConfig) *ImportService

func (*ImportService) Enabled

func (i *ImportService) Enabled() bool

func (*ImportService) HandleWebhook

func (i *ImportService) HandleWebhook(ctx context.Context, event *WebhookEvent) error

HandleWebhook processes a webhook event: fetches the repo and registers the version.

func (*ImportService) ImportFromURL

func (i *ImportService) ImportFromURL(ctx context.Context, repoURL string, opts ImportOpts) error

ImportFromURL clones a repo and registers all version tags.

func (*ImportService) VerifySignature

func (i *ImportService) VerifySignature(payload []byte, signature string) bool

VerifySignature verifies HMAC-SHA256 webhook signature.

type MirrorService

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

func NewMirrorService

func NewMirrorService(gs *GitStore, cfg config.MirrorConfig) *MirrorService

func (*MirrorService) Enabled

func (m *MirrorService) Enabled() bool

func (*MirrorService) PushAll

func (m *MirrorService) PushAll(ctx context.Context) error

PushAll pushes all repos to the remote.

func (*MirrorService) PushMirror

func (m *MirrorService) PushMirror(ctx context.Context, owner, slug string) error

PushMirror pushes a local bare repo to the configured remote.

type PublishOpts

type PublishOpts struct {
	Owner   string
	Slug    string
	Version string            // "1.0.0" → tag "v1.0.0"
	Files   map[string][]byte // path → content
	Author  string
	Email   string
	Message string   // changelog as commit message
	Tags    []string // extra tags
}

type WebhookEvent

type WebhookEvent struct {
	Provider string // "github", "gitlab", "gitea"
	RepoURL  string
	Ref      string // e.g., "refs/tags/v1.0.0"
	Tag      string // e.g., "v1.0.0"
	Commit   string
}

func ParseGitHubWebhook

func ParseGitHubWebhook(payload []byte) (*WebhookEvent, error)

ParseGitHubWebhook parses a GitHub push webhook payload.

func ParseGitLabWebhook

func ParseGitLabWebhook(payload []byte) (*WebhookEvent, error)

ParseGitLabWebhook parses a GitLab tag push webhook payload.

func ParseGiteaWebhook

func ParseGiteaWebhook(payload []byte) (*WebhookEvent, error)

ParseGiteaWebhook parses a Gitea push webhook payload (same format as GitHub).

Jump to

Keyboard shortcuts

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