git_sync

package module
v0.0.0-...-d6ed2b2 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: Unlicense Imports: 24 Imported by: 0

README

GIT sync

Simple web service to:

  • pull git repository as git bundle (full and partial) from a remote repository
  • push git bundles through the web service to some other remote repository

This is useful to synchronize "offline" repositories.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAuthFailed = errors.New("authentication failed")
)

Functions

This section is empty.

Types

type BundleInfo

type BundleInfo struct {
	IsComplete    bool
	ContainsRef   string
	RequiresRef   string
	HashAlgorithm string
	IsOkay        bool
}

func ParseBundleVerifyOutput

func ParseBundleVerifyOutput(output string) BundleInfo

func (BundleInfo) Validate

func (b BundleInfo) Validate() error

type BundleOptions

type BundleOptions struct {
	// since, is the lookback duration for the bundle. Optional.
	Since time.Duration

	// after timestamp, optional
	After time.Time
}

func (BundleOptions) HasAny

func (opt BundleOptions) HasAny() bool

type CommandError

type CommandError struct {
	// Error is the underlying error that occurred
	Err error

	// Message is an optional error message
	Message string

	// ExitCode represents the exit status or error code of the command
	ExitCode int

	// StdErr contains the error output from the command execution
	StdErr string
}

CommandError is a custom error struct for capturing detailed command execution errors

func NewCommandError

func NewCommandError(err error, msg string, status int, stdErr string) *CommandError

NewCommandError creates a new CommandError instance

func (*CommandError) Error

func (e *CommandError) Error() string

Implement the error interface

func (*CommandError) Unwrap

func (e *CommandError) Unwrap() error

Unwrap allows for error unwrapping, supporting Go 1.13+ error handling

type GIT

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

func NewGIT

func NewGIT(tempDir string, remoteRepo RemoteRepo) (*GIT, error)

func (*GIT) ApplyBundleToLocal

func (g *GIT) ApplyBundleToLocal(r io.Reader) error

apply bundle to local repo with "git fetch"

func (*GIT) CreateBundleFromLocal

func (g *GIT) CreateBundleFromLocal(opt BundleOptions) ([]byte, error)

func (GIT) ExistsLocal

func (g GIT) ExistsLocal() (bool, error)

func (*GIT) GetBundleInfo

func (g *GIT) GetBundleInfo(bundleData []byte) (BundleInfo, error)

func (*GIT) GetBundleListHeads

func (g *GIT) GetBundleListHeads(bundleData []byte) ([]Head, error)

func (*GIT) PushLocalToRemote

func (g *GIT) PushLocalToRemote() error

func (*GIT) SyncRepoToLocalTemp

func (g *GIT) SyncRepoToLocalTemp() (*git.Worktree, error)

clones repo from remoteURL if not exists, otherwise pulls the latest changes Returns nil worktree if remote does not exist

type GitPullHandler

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

func NewGitPullHandler

func NewGitPullHandler(tempDir string) *GitPullHandler

func (*GitPullHandler) ServeHTTP

func (h *GitPullHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type GitPushHandler

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

func NewGitPushHandler

func NewGitPushHandler(tempDir string) *GitPushHandler

func (*GitPushHandler) ServeHTTP

func (h *GitPushHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type GogsAdmin

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

func NewGogsAdmin

func NewGogsAdmin(user, password, baseURL string) *GogsAdmin

func (*GogsAdmin) CreateRandomRepo

func (g *GogsAdmin) CreateRandomRepo(branch string) (RemoteRepo, error)
type Head struct {
	CommitID string
	Ref      string
}

func ParseBundleListHeadsOutput

func ParseBundleListHeadsOutput(output string) ([]Head, error)

type RemoteRepo

type RemoteRepo struct {
	URL    string
	Branch string
	Token  string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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