gitsync

package module
v0.0.0-...-6402a71 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2019 License: MIT Imports: 10 Imported by: 0

README

gitsync

GoDoc

Git-based file synchronization library and command line tool

Documentation

Overview

Package gitsync provides file tree mirroring via git. It is capable of cloning a remote repository and updating the local copy to match the head of a particular branch.

This package assumes that the local copy is non-authoritative and that any local changes found may be discarded. It performs the equivalent of a "git reset hard" whenever the local copy is synchronized.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneOrPull

func CloneOrPull(ctx context.Context, path, origin string, options ...Option) error

CloneOrPull creates an ephemeral Worker and performs a Pull with the given parameters. See Worker.CloneOrPull for details.

Types

type Option

type Option func(*Worker)

Option is a gitsync option.

func Auth

func Auth(auth transport.AuthMethod) Option

Auth returns an option that sets the given authentication method.

func Branch

func Branch(name string) Option

Branch returns an option that sets the given branch name.

func Progress

func Progress(progress sideband.Progress) Option

Progress returns an option that sets the progress output.

type Worker

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

Worker is responsible for keeping local files in sync with a remote. It should be created by calling gitsync.New.

func New

func New(path, origin string, options ...Option) *Worker

New returns a Worker for the repository at the given path.

The path should specify a file system directory to which the contents of the remote branch will be mirrored.

The given origin will be used to access the remote.

New is nondestructive. Calls to CloneOrPull will perform file system initialization and cloning as needed.

func (*Worker) CloneOrPull

func (w *Worker) CloneOrPull(ctx context.Context) error

CloneOrPull attempts to update the local file system to match a particular branch on the origin. It performs the equivalent of git clone, pull and checkout as necessary to accomplish this.

CloneOrPull is destructive. Files within the local copy may be discarded in order for it to accomplish its goal. In the case of failure it may attempt to destroy the local copy and re-clone.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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