Movatterモバイル変換


[0]ホーム

URL:


config

package
v5.16.4Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2025 License:Apache-2.0Imports:14Imported by:1,070

Details

Repository

github.com/go-git/go-git

Links

Documentation

Overview

Package config contains the abstraction of multiple 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/*")
View Source
const (// DefaultPackWindow holds the number of previous objects used to// generate deltas. The value 10 is the same used by git command.DefaultPackWindow =uint(10))

Variables

View Source
var (ErrInvalid               =errors.New("config invalid key in remote or branch")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")ErrModuleBadPath   =errors.New("submodule has an invalid path"))
View Source
var (ErrRefSpecMalformedSeparator =errors.New("malformed refspec, separators are wrong")ErrRefSpecMalformedWildcard  =errors.New("malformed refspec, mismatched number of wildcards"))

Functions

funcMatchAny

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

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

funcPathsadded inv5.1.0

func Paths(scopeScope) ([]string,error)

Paths returns the config file location for a given scope.

Types

typeBranch

type Branch struct {// Name of branchNamestring// Remote name of remote to trackRemotestring// Merge is the local refspec for the branchMergeplumbing.ReferenceName// Rebase instead of merge when pulling. Valid values are// "true" and "interactive".  "false" is undocumented and// typically represented by the non-existence of this fieldRebasestring// Description explains what the branch is for.// Multi-line explanations may be used.//// Original git command to edit://git branch --edit-descriptionDescriptionstring// contains filtered or unexported fields}

Branch contains information on thelocal branches and which remote to track

func (*Branch)Validate

func (b *Branch) Validate()error

Validate validates fields of branch

typeConfig

type Config struct {Core struct {// IsBare if true this repository is assumed to be bare and has no// working directory associated with it.IsBarebool// Worktree is the path to the root of the working tree.Worktreestring// CommentChar is the character indicating the start of a// comment for commands like commit and tagCommentCharstring// RepositoryFormatVersion identifies the repository format and layout version.RepositoryFormatVersionformat.RepositoryFormatVersion}User struct {// Name is the personal name of the author and the committer of a commit.Namestring// Email is the email of the author and the committer of a commit.Emailstring}Author struct {// Name is the personal name of the author of a commit.Namestring// Email is the email of the author of a commit.Emailstring}Committer struct {// Name is the personal name of the committer of a commit.Namestring// Email is the email of the committer of a commit.Emailstring}Pack struct {// Window controls the size of the sliding window for delta// compression.  The default is 10.  A value of 0 turns off// delta compression entirely.Windowuint}Init struct {// DefaultBranch Allows overriding the default branch name// e.g. when initializing a new repository or when cloning// an empty repository.DefaultBranchstring}Extensions struct {// ObjectFormat specifies the hash algorithm to use. The// acceptable values are sha1 and sha256. If not specified,// sha1 is assumed. It is an error to specify this key unless// core.repositoryFormatVersion is 1.//// This setting must not be changed after repository initialization// (e.g. clone or init).ObjectFormatformat.ObjectFormat}// Remotes list of repository remotes, the key of the map is the name// of the remote, should equal to RemoteConfig.Name.Remotes map[string]*RemoteConfig// Submodules list of repository submodules, the key of the map is the name// of the submodule, should equal to Submodule.Name.Submodules map[string]*Submodule// Branches list of branches, the key is the branch name and should// equal Branch.NameBranches map[string]*Branch// URLs list of url rewrite rules, if repo url starts with URL.InsteadOf value, it will be replaced with the// key instead.URLs map[string]*URL// Raw contains the raw information of a config file. The main goal is// preserve the parsed information from the original format, to avoid// dropping unsupported fields.Raw *format.Config}

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

funcLoadConfigadded inv5.1.0

func LoadConfig(scopeScope) (*Config,error)

LoadConfig loads a config file from a given scope. The returned Config,contains exclusively information from the given scope. If it couldn't find aconfig file to the given scope, an empty one is returned.

funcNewConfig

func NewConfig() *Config

NewConfig returns a new empty Config.

funcReadConfigadded inv5.1.0

func ReadConfig(rio.Reader) (*Config,error)

ReadConfig reads a config file from a io.Reader.

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.

typeConfigStorer

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

ConfigStorer generic storage of Config object

typeModules

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 filehttps://www.kernel.org/pub/software/scm/git/docs/gitmodules.html

funcNewModules

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.

typeRefSpec

type RefSpecstring

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 wherethose references will be written locally. The + tells Git to update thereference even if it isn’t a fast-forward.eg.: "+refs/heads/*:refs/remotes/origin/*"

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

func (RefSpec)Dst

Dst returns the destination for the given remote reference.

func (RefSpec)IsDelete

func (sRefSpec) IsDelete()bool

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

func (RefSpec)IsExactSHA1added inv5.1.0

func (sRefSpec) IsExactSHA1()bool

IsExactSHA1 returns true if the source is a SHA1 hash.

func (RefSpec)IsForceUpdate

func (sRefSpec) IsForceUpdate()bool

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

func (RefSpec)IsWildcard

func (sRefSpec) IsWildcard()bool

IsWildcard returns true if the RefSpec contains a wildcard.

func (RefSpec)Match

Match match the given plumbing.ReferenceName against the source.

func (RefSpec)Reverse

func (sRefSpec) Reverse()RefSpec

func (RefSpec)Src

func (sRefSpec) Src()string

Src returns the src side.

func (RefSpec)String

func (sRefSpec) String()string

func (RefSpec)Validate

func (sRefSpec) Validate()error

Validate validates the RefSpec

typeRemoteConfig

type RemoteConfig struct {// Name of the remoteNamestring// URLs the URLs of a remote repository. It must be non-empty. Fetch will// always use the first URL, while push will use all of them.URLs []string// Mirror indicates that the repository is a mirror of remote.Mirrorbool// Fetch the default set of "refspec" for fetch operationFetch []RefSpec// contains filtered or unexported fields}

RemoteConfig contains the configuration for a given remote repository.

func (*RemoteConfig)IsFirstURLLocal

func (c *RemoteConfig) IsFirstURLLocal()bool

func (*RemoteConfig)Validate

func (c *RemoteConfig) Validate()error

Validate validates the fields and sets the default values.

typeScopeadded inv5.1.0

type Scopeint

Scope defines the scope of a config file, such as local, global or system.

const (LocalScopeScope =iotaGlobalScopeSystemScope)

Available ConfigScope's

typeSubmodule

type Submodule struct {// Name module nameNamestring// Path defines the path, relative to the top-level directory of the Git// working tree.Pathstring// URL defines a URL from which the submodule repository can be cloned.URLstring// Branch is a remote branch name for tracking updates in the upstream// submodule. Optional value.Branchstring// 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.

typeURLadded inv5.3.0

type URL struct {// Name new base urlNamestring// Any URL that starts with this value will be rewritten to start, instead, with <base>.// When more than one insteadOf strings match a given URL, the longest match is used.InsteadOfstring// contains filtered or unexported fields}

Url defines Url rewrite rules

func (*URL)ApplyInsteadOfadded inv5.3.0

func (u *URL) ApplyInsteadOf(urlstring)string

func (*URL)Validateadded inv5.3.0

func (b *URL) Validate()error

Validate validates fields of branch

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp