config

package
v4.0.0-rc8+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2017 License: MIT Imports: 6 Imported by: 1

Documentation

Overview

Package config contains the abstraction of config files

Index

Constants

View Source
const (
	// DefaultFetchRefSpec is the default refspec used for fetch.
	DefaultFetchRefSpec = "+refs/heads/*:refs/remotes/%s/*"
	// DefaultPushRefSpec is the default refspec used for push.
	DefaultPushRefSpec = "refs/heads/*:refs/heads/*"
)

Variables

View Source
var (
	ErrInvalid               = errors.New("config invalid remote")
	ErrRemoteConfigNotFound  = errors.New("remote config not found")
	ErrRemoteConfigEmptyURL  = errors.New("remote config: empty URL")
	ErrRemoteConfigEmptyName = errors.New("remote config: empty name")
)
View Source
var (
	ErrModuleEmptyURL  = errors.New("module config: empty URL")
	ErrModuleEmptyPath = errors.New("module config: empty path")
)

Functions

func MatchAny

func MatchAny(l []RefSpec, n plumbing.ReferenceName) bool

MatchAny returns true if any of the RefSpec match with the given ReferenceName

Types

type Config

type Config struct {
	// Core variables
	Core struct {
		// IsBare if true this repository is assumed to be bare and has no
		// working directory associated with it
		IsBare bool
	}
	// Remote list of repository remotes
	Remotes map[string]*RemoteConfig
	// contains filtered or unexported fields
}

Config contains the repository configuration ftp://www.kernel.org/pub/software/scm/git/docs/git-config.html#FILES

func NewConfig

func NewConfig() *Config

NewConfig returns a new empty Config

func (*Config) Marshal

func (c *Config) Marshal() ([]byte, error)

Marshal returns Config encoded as a git-config file

func (*Config) Unmarshal

func (c *Config) Unmarshal(b []byte) error

Unmarshal parses a git-config file and stores it

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the fields and sets the default values

type ConfigStorer

type ConfigStorer interface {
	Config() (*Config, error)
	SetConfig(*Config) error
}

ConfigStorer generic storage of Config object

type Modules

type Modules struct {
	// Submodules is a map of submodules being the key the name of the submodule
	Submodules map[string]*Submodule
	// contains filtered or unexported fields
}

Modules defines the submodules properties, represents a .gitmodules file https://www.kernel.org/pub/software/scm/git/docs/gitmodules.html

func NewModules

func NewModules() *Modules

NewModules returns a new empty Modules

func (*Modules) Marshal

func (m *Modules) Marshal() ([]byte, error)

Marshal returns Modules encoded as a git-config file

func (*Modules) Unmarshal

func (m *Modules) Unmarshal(b []byte) error

Unmarshal parses a git-config file and stores it

type RefSpec

type RefSpec string

RefSpec is a mapping from local branches to remote references The format of the refspec is an optional +, followed by <src>:<dst>, where <src> is the pattern for references on the remote side and <dst> is where those references will be written locally. The + tells Git to update the reference even if it isn’t a fast-forward. eg.: "+refs/heads/*:refs/remotes/origin/*"

https://git-scm.com/book/es/v2/Git-Internals-The-Refspec

func (RefSpec) Dst

Dst returns the destination for the given remote reference

func (RefSpec) IsDelete

func (s RefSpec) IsDelete() bool

IsDelete returns true if the refspec indicates a delete (empty src).

func (RefSpec) IsForceUpdate

func (s RefSpec) IsForceUpdate() bool

IsForceUpdate returns if update is allowed in non fast-forward merges

func (RefSpec) IsValid

func (s RefSpec) IsValid() bool

IsValid validates the RefSpec

func (RefSpec) IsWildcard

func (s RefSpec) IsWildcard() bool

IsWildcard returns true if the RefSpec contains a wildcard

func (RefSpec) Match

func (s RefSpec) Match(n plumbing.ReferenceName) bool

Match match the given plumbing.ReferenceName against the source

func (RefSpec) Src

func (s RefSpec) Src() string

Src return the src side

func (RefSpec) String

func (s RefSpec) String() string

type RemoteConfig

type RemoteConfig struct {
	// Name of the remote
	Name string
	// URL the URL of a remote repository
	URL string
	// Fetch the default set of "refspec" for fetch operation
	Fetch []RefSpec
	// contains filtered or unexported fields
}

RemoteConfig contains the configuration for a given remote repository

func (*RemoteConfig) Validate

func (c *RemoteConfig) Validate() error

Validate validates the fields and sets the default values

type Submodule

type Submodule struct {
	// Name module name
	Name string
	// Path defines the path, relative to the top-level directory of the Git
	// working tree,
	Path string
	// URL defines a URL from which the submodule repository can be cloned.
	URL string
	// Branch is a remote branch name for tracking updates in the upstream
	// submodule. Optional value.
	Branch string
	// contains filtered or unexported fields
}

Submodule defines a submodule

func (*Submodule) Validate

func (m *Submodule) Validate() error

Validate validates the fields and sets the default values

Jump to

Keyboard shortcuts

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