gitclient

package
v0.0.0-...-74adf86 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateCategoryMarkdown

func GenerateCategoryMarkdown(frontMatter CategoryFrontMatter, body string) (string, error)

GenerateCategoryMarkdown generates a markdown file with YAML front-matter for a category

func GenerateCollectionMarkdown

func GenerateCollectionMarkdown(frontMatter CollectionFrontMatter, body string) (string, error)

GenerateCollectionMarkdown generates a markdown file with YAML front-matter for a collection

func GenerateCommitMessage

func GenerateCommitMessage(action string, entityType string, entityID string, summary string) string

GenerateCommitMessage generates a descriptive commit message for catalog changes

func GenerateProductMarkdown

func GenerateProductMarkdown(frontMatter ProductFrontMatter, body string) (string, error)

GenerateProductMarkdown generates a markdown file with YAML front-matter for a product

func GenerateReleaseTagName

func GenerateReleaseTagName() string

GenerateReleaseTagName generates a timestamped release tag name

func GetCategoryFilePath

func GetCategoryFilePath(slug string) string

GetCategoryFilePath returns the file path for a category markdown file Format: categories/{slug}.md

func GetCollectionFilePath

func GetCollectionFilePath(slug string) string

GetCollectionFilePath returns the file path for a collection markdown file Format: collections/{slug}.md

func GetProductFilePath

func GetProductFilePath(sku, categorySlug string) string

GetProductFilePath returns the file path for a product markdown file Format: products/{category-slug}/{SKU}.md

Types

type CategoryFrontMatter

type CategoryFrontMatter struct {
	ID           string  `yaml:"id"`
	Name         string  `yaml:"name"`
	Slug         string  `yaml:"slug"`
	Description  *string `yaml:"description,omitempty"`
	ParentID     *string `yaml:"parent_id,omitempty"`
	DisplayOrder int     `yaml:"display_order"`
	CreatedAt    string  `yaml:"created_at"`
	UpdatedAt    string  `yaml:"updated_at"`
}

CategoryFrontMatter represents category metadata for YAML front-matter

type CollectionFrontMatter

type CollectionFrontMatter struct {
	ID           string   `yaml:"id"`
	Name         string   `yaml:"name"`
	Slug         string   `yaml:"slug"`
	Description  *string  `yaml:"description,omitempty"`
	ProductIDs   []string `yaml:"product_ids"`
	DisplayOrder int      `yaml:"display_order"`
	CreatedAt    string   `yaml:"created_at"`
	UpdatedAt    string   `yaml:"updated_at"`
}

CollectionFrontMatter represents collection metadata for YAML front-matter

type CommitBuilder

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

CommitBuilder handles git commit operations

func NewCommitBuilder

func NewCommitBuilder(repoPath string) (*CommitBuilder, error)

NewCommitBuilder creates a new commit builder for a git repository

func (*CommitBuilder) Commit

func (cb *CommitBuilder) Commit(opts CommitOptions) (string, error)

Commit creates a commit with the staged changes

func (*CommitBuilder) CommitAll

func (cb *CommitBuilder) CommitAll(message string) (string, error)

CommitAll stages and commits all changes in the repository

func (*CommitBuilder) CommitChange

func (cb *CommitBuilder) CommitChange(filePath string, content string, message string) (string, error)

CommitChange is a convenience method to write a file, stage it, and commit in one operation

func (*CommitBuilder) CommitDelete

func (cb *CommitBuilder) CommitDelete(filePath string, message string) (string, error)

CommitDelete is a convenience method to delete a file, stage it, and commit

func (*CommitBuilder) CommitMultiple

func (cb *CommitBuilder) CommitMultiple(changes map[string]string, message string) (string, error)

CommitMultiple commits multiple file changes in a single commit

func (*CommitBuilder) DeleteFile

func (cb *CommitBuilder) DeleteFile(filePath string) error

DeleteFile deletes a file from the repository

func (*CommitBuilder) GetCurrentCommitHash

func (cb *CommitBuilder) GetCurrentCommitHash() string

GetCurrentCommitHash returns the current HEAD commit hash

func (*CommitBuilder) GetStatus

func (cb *CommitBuilder) GetStatus() (git.Status, error)

GetStatus returns the current status of the working tree

func (*CommitBuilder) HasChanges

func (cb *CommitBuilder) HasChanges() (bool, error)

HasChanges checks if there are any uncommitted changes

func (*CommitBuilder) StageAll

func (cb *CommitBuilder) StageAll() error

StageAll stages all changes in the repository

func (*CommitBuilder) StageFile

func (cb *CommitBuilder) StageFile(filePath string) error

StageFile stages a file for commit

func (*CommitBuilder) WriteFile

func (cb *CommitBuilder) WriteFile(filePath string, content string) error

WriteFile writes content to a file in the repository

type CommitOptions

type CommitOptions struct {
	Message   string
	Author    *object.Signature
	Committer *object.Signature
}

CommitOptions contains options for creating a commit

type HTTPGitClient

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

HTTPGitClient handles git operations via HTTP protocol to the git-server

func NewHTTPGitClient

func NewHTTPGitClient(serverURL, repoName, localPath string, logger *zap.Logger) *HTTPGitClient

NewHTTPGitClient creates a new HTTP git client

func (*HTTPGitClient) HealthCheck

func (c *HTTPGitClient) HealthCheck(ctx context.Context) error

HealthCheck verifies connectivity to the git-server

func (*HTTPGitClient) PushChange

func (c *HTTPGitClient) PushChange(ctx context.Context, filePath string, content string, commitMessage string) error

PushChange creates a commit with the given file changes and pushes to git-server

func (*HTTPGitClient) PushDelete

func (c *HTTPGitClient) PushDelete(ctx context.Context, filePath string, commitMessage string) error

PushDelete deletes a file and pushes the change to git-server

func (*HTTPGitClient) PushMultiple

func (c *HTTPGitClient) PushMultiple(ctx context.Context, changes map[string]string, commitMessage string) error

PushMultiple commits multiple file changes in a single commit and pushes

type ProductFrontMatter

type ProductFrontMatter struct {
	ID                string                 `yaml:"id"`
	SKU               string                 `yaml:"sku"`
	Title             string                 `yaml:"title"`
	Price             float64                `yaml:"price"`
	Currency          string                 `yaml:"currency"`
	InventoryStatus   string                 `yaml:"inventory_status"`
	InventoryQuantity *int                   `yaml:"inventory_quantity,omitempty"`
	CategoryID        string                 `yaml:"category_id"`
	CollectionIDs     []string               `yaml:"collection_ids,omitempty"`
	Images            []string               `yaml:"images,omitempty"`
	Metadata          map[string]interface{} `yaml:"metadata,omitempty"`
	CreatedAt         string                 `yaml:"created_at"`
	UpdatedAt         string                 `yaml:"updated_at"`
}

ProductFrontMatter represents product metadata for YAML front-matter

type PushClient

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

PushClient handles git push operations

func NewPushClient

func NewPushClient(repoPath string, remoteName string, remoteURL string) (*PushClient, error)

NewPushClient creates a new push client for a git repository

func (*PushClient) EnsureRemote

func (pc *PushClient) EnsureRemote() error

EnsureRemote ensures the remote exists with the correct URL

func (*PushClient) GetRemoteName

func (pc *PushClient) GetRemoteName() string

GetRemoteName returns the configured remote name

func (*PushClient) GetRemoteURL

func (pc *PushClient) GetRemoteURL() string

GetRemoteURL returns the configured remote URL

func (*PushClient) Push

func (pc *PushClient) Push(opts PushOptions) error

Push pushes commits to the remote repository

func (*PushClient) PushBranch

func (pc *PushClient) PushBranch() error

PushBranch pushes the current branch to remote

func (*PushClient) PushWithRefSpec

func (pc *PushClient) PushWithRefSpec(refSpecs ...string) error

PushWithRefSpec pushes specific refs to remote

type PushOptions

type PushOptions struct {
	// RefSpecs to push (e.g., "refs/heads/main:refs/heads/main")
	// If empty, pushes current branch
	RefSpecs []string

	// Force push (not recommended for shared branches)
	Force bool

	// Auth credentials (if required)
	Auth transport.AuthMethod
}

PushOptions contains options for pushing to remote

type TagClient

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

TagClient handles git tag operations

func NewTagClient

func NewTagClient(repoPath string) (*TagClient, error)

NewTagClient creates a new tag client for a git repository

func (*TagClient) CreateAndPushTag

func (tc *TagClient) CreateAndPushTag(opts TagOptions, remoteName string, remoteURL string) (string, error)

CreateAndPushTag creates a tag and pushes it to remote in one operation

func (*TagClient) CreateTag

func (tc *TagClient) CreateTag(opts TagOptions) (string, error)

CreateTag creates an annotated tag

func (*TagClient) DeleteTag

func (tc *TagClient) DeleteTag(tagName string) error

DeleteTag deletes a tag from the repository

func (*TagClient) GenerateSemverTagName

func (tc *TagClient) GenerateSemverTagName() (string, error)

GenerateSemverTagName generates next semantic version tag Increments patch version (e.g., v1.0.0 -> v1.0.1)

func (*TagClient) GetTag

func (tc *TagClient) GetTag(tagName string) (*object.Tag, error)

GetTag retrieves tag information

func (*TagClient) ListTags

func (tc *TagClient) ListTags() ([]string, error)

ListTags returns all tags in the repository

func (*TagClient) PushAllTags

func (tc *TagClient) PushAllTags(remoteName string, remoteURL string) error

PushAllTags pushes all tags to remote

func (*TagClient) PushTag

func (tc *TagClient) PushTag(tagName string, remoteName string, remoteURL string) error

PushTag pushes a tag to the remote repository

func (*TagClient) TagExists

func (tc *TagClient) TagExists(tagName string) (bool, error)

TagExists checks if a tag exists

type TagOptions

type TagOptions struct {
	// Tag name (e.g., "v1.0.0" or "2026-03-10")
	Name string

	// Tag message
	Message string

	// Tagger signature (optional, defaults to "GitStore Admin")
	Tagger *object.Signature

	// Target commit hash (optional, defaults to HEAD)
	Target string
}

TagOptions contains options for creating a tag

type ValidationError

type ValidationError struct {
	Message string
	File    string
	Line    int
	Details []string
}

ValidationError represents a validation error from the git server

func (*ValidationError) Error

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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