libdotfilesync

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NAME    = "Dotfile Sync"
	VERSION = "0.1.2"
	AUTHOR  = "jochemste"
)

Variables

View Source
var SyncChanged bool = false
View Source
var Syncfilepath string = ".syncinfo"

Functions

func ContentIsDiff

func ContentIsDiff(cont1 string, cont2 string) (bool, error)

func DeleteRepoIfExists

func DeleteRepoIfExists(store_loc string) error

Delete the repository if it exists

func DetermMethod

func DetermMethod(origin string) (string, error)

func ExistsInFS

func ExistsInFS(filename string) bool

func FindInFS

func FindInFS(filename string) (string, error)

Find in filesystem

func FindInFSDir

func FindInFSDir(filename string, files []os.FileInfo, dirname string) (string, error)

Recursive find in directory function (private)

func GetContentFS

func GetContentFS(filename string) (string, error)

func GetFileDescriptorFS

func GetFileDescriptorFS(filename string) (billy.File, error)

func NewFS

func NewFS()

func RepoExists

func RepoExists(store_loc string) bool

Tests if a repository exists

func WriteToFS

func WriteToFS(filename string, content string) error

Types

type Config

type Config struct {
	UserSettings UserConfig
	DoNotChange  DontChangeConfig
}

Configuration struct

func NewConfig

func NewConfig() *Config

Get a new Config object

func (*Config) FromFile

func (config *Config) FromFile(file string) error

Set a Config from a toml file, if the file exists

func (*Config) IsWritable added in v0.1.2

func (config *Config) IsWritable() bool

func (*Config) Print

func (config *Config) Print()

func (*Config) ToFile

func (config *Config) ToFile(file ...string) error

Write the Config object to a file

type DontChangeConfig

type DontChangeConfig struct {
	LastCheck time.Time
	NrSync    int
	Store     string
	File      string
}

Information that is used and adjusted automatically

type FileMap

type FileMap struct {
	Origin      string
	FSPath      string
	Changed     bool
	Message     string
	OriginTime  time.Time
	FSTime      time.Time
	NeedsCommit bool
}

func NewFileMap

func NewFileMap() *FileMap

func (*FileMap) ExistsInFS

func (fm *FileMap) ExistsInFS() bool

func (*FileMap) ExistsLocal

func (fm *FileMap) ExistsLocal() bool

func (*FileMap) FMIsMoreRecent added in v0.1.2

func (fm *FileMap) FMIsMoreRecent() bool

func (*FileMap) GetFSFilename

func (fm *FileMap) GetFSFilename() string

func (*FileMap) GetModTimeOrigin

func (fm *FileMap) GetModTimeOrigin() (time.Time, error)

func (*FileMap) GetOriginFilename

func (fm *FileMap) GetOriginFilename() string

func (*FileMap) HasChanged

func (fm *FileMap) HasChanged() (bool, error)

Determine if a file has changed. Returns true if it has or the file does not exist in the local filesystem and/or the memory filesystem

func (*FileMap) LocalIsMoreRecent added in v0.1.2

func (fm *FileMap) LocalIsMoreRecent() bool

func (*FileMap) Refresh

func (fm *FileMap) Refresh()

func (*FileMap) SetFilename added in v0.1.2

func (fm *FileMap) SetFilename(filename string) error

func (*FileMap) Update

func (fm *FileMap) Update(mode ...string) error

Update the Files in the file map

type FileSystem

type FileSystem struct {
	FS billy.Filesystem
}
var Filesystem FileSystem

type Gitter

type Gitter struct {
	Repository *git.Repository
	Storer     *memory.Storage
	Worktree   *git.Worktree
}

func NewRepo

func NewRepo() *Gitter

func (*Gitter) CloneRepo

func (g *Gitter) CloneRepo(origin string, secret ...string) error

func (*Gitter) CommitToRepo

func (g *Gitter) CommitToRepo(filename string, message string) error

func (*Gitter) PushToRemote

func (g *Gitter) PushToRemote(secret string) error

type SyncConfig

type SyncConfig struct {
	LastSync time.Time
	Files    []SyncFile
}

func NewSyncConfig

func NewSyncConfig() *SyncConfig

func (*SyncConfig) AddFile

func (sc *SyncConfig) AddFile(s SyncFile)

func (*SyncConfig) AddNewFile added in v0.1.2

func (sc *SyncConfig) AddNewFile(filename string)

func (*SyncConfig) FromFS

func (sc *SyncConfig) FromFS() error

func (*SyncConfig) IsInSync added in v0.1.2

func (sc *SyncConfig) IsInSync(filename string) bool

func (*SyncConfig) Print

func (sc *SyncConfig) Print()

func (*SyncConfig) SetLastSync

func (sc *SyncConfig) SetLastSync(t time.Time)

func (*SyncConfig) ToFS

func (sc *SyncConfig) ToFS() error

type SyncFile

type SyncFile struct {
	Name     string
	LastSync time.Time
}

type UserConfig

type UserConfig struct {
	Origin      string
	Files       []string
	AccessToken string
	Mode        string
}

Configuration that is managed by the user

Jump to

Keyboard shortcuts

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