Documentation
¶
Index ¶
- Constants
- func Add(r *git.Repository, f *git.File, o *AddOptions) error
- func AddAll(r *git.Repository, o *AddOptions) error
- func AddConfig(r *git.Repository, options *ConfigOptions, value string) (err error)
- func Checkout(r *git.Repository, o *CheckoutOptions) error
- func Commit(r *git.Repository, o *CommitOptions) (err error)
- func Config(r *git.Repository, o *ConfigOptions) (value string, err error)
- func Diff(r *git.Repository, hash string) (diff string, err error)
- func DiffFile(f *git.File) (output string, err error)
- func DiffStat(r *git.Repository) (string, error)
- func DiffStatRefs(r *git.Repository, ref1, ref2 string) (string, error)
- func Fetch(r *git.Repository, o *FetchOptions) (err error)
- func Merge(r *git.Repository, options *MergeOptions) error
- func PlainDiff(r *git.Repository) (string, error)
- func PlainStatus(r *git.Repository) (string, error)
- func Pull(r *git.Repository, o *PullOptions) (err error)
- func Reset(r *git.Repository, file *git.File, o *ResetOptions) error
- func ResetAll(r *git.Repository, o *ResetOptions) error
- func Return(d string, c string, args []string) (int, error)
- func Run(d string, c string, args []string) (string, error)
- func StashDiff(r *git.Repository, id int) (string, error)
- func Status(r *git.Repository) ([]*git.File, error)
- type AddOptions
- type CheckoutOptions
- type CommitOptions
- type ConfigOptions
- type ConfigSite
- type FetchOptions
- type MergeOptions
- type Mode
- type PullOptions
- type ResetOptions
- type ResetType
Constants ¶
const ( // ModeLegacy uses traditional git command line tool to operate ModeLegacy = iota // ModeNative uses native implementation of given git command ModeNative )
Variables ¶
This section is empty.
Functions ¶
func Add ¶
func Add(r *git.Repository, f *git.File, o *AddOptions) error
Add is a wrapper function for "git add" command
func AddAll ¶
func AddAll(r *git.Repository, o *AddOptions) error
AddAll function is the wrapper of "git add ." command
func AddConfig ¶
func AddConfig(r *git.Repository, options *ConfigOptions, value string) (err error)
AddConfig adds an entry on the ConfigOptions field.
func Checkout ¶
func Checkout(r *git.Repository, o *CheckoutOptions) error
Checkout is a wrapper function for "git checkout" command.
func Commit ¶
func Commit(r *git.Repository, o *CommitOptions) (err error)
Commit defines which commit command to use.
func Config ¶
func Config(r *git.Repository, o *ConfigOptions) (value string, err error)
Config adds or reads config of a repository
func Diff ¶
func Diff(r *git.Repository, hash string) (diff string, err error)
Diff is a wrapper function for "git diff" command Diff function returns the diff to previous commit detail of the given has of a specific commit
func DiffStat ¶
func DiffStat(r *git.Repository) (string, error)
DiffStat shows current working status "git diff --stat"
func DiffStatRefs ¶
func DiffStatRefs(r *git.Repository, ref1, ref2 string) (string, error)
DiffStatRefs shows diff stat of two refs "git diff a1b2c3..e4f5g6 --stat"
func Fetch ¶
func Fetch(r *git.Repository, o *FetchOptions) (err error)
Fetch branches refs from one or more other repositories, along with the objects necessary to complete their histories
func Merge ¶
func Merge(r *git.Repository, options *MergeOptions) error
Merge incorporates changes from the named commits or branches into the current branch
func PlainDiff ¶
func PlainDiff(r *git.Repository) (string, error)
PlainDiff shows current working status "git diff"
func PlainStatus ¶
func PlainStatus(r *git.Repository) (string, error)
PlainStatus returns the plain status
func Pull ¶
func Pull(r *git.Repository, o *PullOptions) (err error)
Pull incorporates changes from a remote repository into the current branch.
func Reset ¶
func Reset(r *git.Repository, file *git.File, o *ResetOptions) error
Reset is the wrapper of "git reset" command
func ResetAll ¶
func ResetAll(r *git.Repository, o *ResetOptions) error
ResetAll resets the changes in a repository, should be used wise
func Return ¶
Return returns if we supposed to get return value as an int of a command this method can be used. It is practical when you use a command and process a failover according to a specific return code
func Run ¶
Run runs the OS command and return its output. If the output returns error it also encapsulates it as a golang.error which is a return code of the command except zero
Types ¶
type AddOptions ¶
type AddOptions struct { // Update Update bool // Force Force bool // DryRun DryRun bool // Mode is the command mode CommandMode Mode }
AddOptions defines the rules for "git add" command
type CheckoutOptions ¶
CheckoutOptions defines the rules of checkout command
type CommitOptions ¶
type CommitOptions struct { // CommitMsg CommitMsg string // User User string // Email Email string // Mode is the command mode CommandMode Mode }
CommitOptions defines the rules for commit operation
type ConfigOptions ¶
type ConfigOptions struct { // Section Section string // Option Option string // Site should be Global or Local Site ConfigSite // Mode is the command mode CommandMode Mode }
ConfigOptions defines the rules for commit operation
type ConfigSite ¶
type ConfigSite string
ConfigSite defines a string type for the site.
const ( // ConfigSiteLocal defines a local config. ConfigSiteLocal ConfigSite = "local" // ConfigSiteGlobal defines a global config. ConfigSiteGlobal ConfigSite = "global" )
type FetchOptions ¶
type FetchOptions struct { // Name of the remote to fetch from. Defaults to origin. RemoteName string // Credentials holds the user and password information Credentials *git.Credentials // Before fetching, remove any remote-tracking references that no longer // exist on the remote. Prune bool // Show what would be done, without making any changes. DryRun bool // Process logs the output to stdout Progress bool // Force allows the fetch to update a local branch even when the remote // branch does not descend from it. Force bool // Mode is the command mode CommandMode Mode }
FetchOptions defines the rules for fetch operation
type MergeOptions ¶
type MergeOptions struct { // Name of the branch to merge with. BranchName string // Be verbose. Verbose bool // With true do not show a diffstat at the end of the merge. NoStat bool // Mode is the command mode CommandMode Mode }
MergeOptions defines the rules of a merge operation
type Mode ¶
type Mode uint8
Mode indicates that whether command should run native code or use git command to operate.
type PullOptions ¶
type PullOptions struct { // Name of the remote to fetch from. Defaults to origin. RemoteName string // ReferenceName Remote branch to clone. If empty, uses HEAD. ReferenceName string // Fetch only ReferenceName if true. SingleBranch bool // Credentials holds the user and password information Credentials *git.Credentials // Process logs the output to stdout Progress bool // Force allows the pull to update a local branch even when the remote // branch does not descend from it. Force bool // Mode is the command mode CommandMode Mode }
PullOptions defines the rules for pull operation
type ResetOptions ¶
type ResetOptions struct { // Hash is the reference to be resetted Hash string // Type is the mode of a reset operation ResetType ResetType // Mode is the command mode CommandMode Mode }
ResetOptions defines the rules of git reset command
type ResetType ¶
type ResetType string
ResetType defines a string type for reset git command.
const ( // ResetHard Resets the index and working tree. Any changes to tracked // files in the working tree since <commit> are discarded. ResetHard ResetType = "hard" // ResetMixed Resets the index but not the working tree (i.e., the changed // files are preserved but not marked for commit) and reports what has not // been updated. This is the default action. ResetMixed ResetType = "mixed" // ResetMerge Resets the index and updates the files in the working tree // that are different between <commit> and HEAD, but keeps those which are // different between the index and working tree ResetMerge ResetType = "merge" // ResetSoft Does not touch the index file or the working tree at all // (but resets the head to <commit> ResetSoft ResetType = "soft" // ResetKeep Resets index entries and updates files in the working tree // that are different between <commit> and HEAD ResetKeep ResetType = "keep" )