Documentation
¶
Index ¶
- Constants
- func Executable(gitBinPath *string) string
- func IsGitErrorCode(err error, codes ...string) bool
- func ParseGitConfig(text string) map[string]string
- func ParseGitStatusNumstat(text string) map[string]NumStat
- func ParseGitSubmodule(text string) []map[string]string
- func ParseGitTags(text string) []string
- func ParseInt(value string, fallback int) (int, error)
- func ParsePatchDiffResult(patchLineList []bool, text string) string
- type Branch
- type Command
- type Commit
- type CommitFile
- type Error
- type FileLineDiff
- type FileStatus
- type LogResult
- type NumStat
- type Remote
- type Result
- type RevParseResult
- type Runner
- type Service
- func (s *Service) AutoStashExecuteAndPop(ctx context.Context, repoPath string, args []string, timeout time.Duration) (string, error)
- func (s *Service) Commit(ctx context.Context, repoPath string, amend, emptyCommit bool, message *string, ...) (string, error)
- func (s *Service) CurrentBranch(ctx context.Context, repoPath string) (string, error)
- func (s *Service) DiffFile(ctx context.Context, repoPath, filename, oldFilename, sha1 string, ...) (string, error)
- func (s *Service) DiscardAllChanges(ctx context.Context, repoPath string) (string, error)
- func (s *Service) DiscardChangesInFile(ctx context.Context, repoPath, filename string) (string, error)
- func (s *Service) Head(ctx context.Context, repoPath string) ([]Commit, error)
- func (s *Service) Log(ctx context.Context, repoPath string, ...) (LogResult, error)
- func (s *Service) ResolveConflicts(ctx context.Context, repoPath string, files []string) (string, error)
- func (s *Service) RevParse(ctx context.Context, repoPath string) RevParseResult
- func (s *Service) RunMutation(ctx context.Context, repoPath string, args ...string) (string, error)
- func (s *Service) Status(ctx context.Context, repoPath, file string) (Status, error)
- type SimpleError
- type Status
- type VersionInfo
Constants ¶
View Source
const DefaultTimeout = 2 * time.Minute
View Source
const RequiredVersion = ">=1.8.x"
Variables ¶
This section is empty.
Functions ¶
func Executable ¶
func IsGitErrorCode ¶
func ParseGitConfig ¶
func ParseGitStatusNumstat ¶
func ParseGitSubmodule ¶
func ParseGitTags ¶
func ParsePatchDiffResult ¶
ParsePatchDiffResult reproduces Ungit-compatible partial-staging transformation. Each boolean corresponds, in order, to a +/- line in the diff. Selected changes are retained while unselected additions are removed and unselected deletions become context lines. Hunk headers are adjusted to keep the resulting patch valid for git apply --cached.
Types ¶
type Branch ¶
func ParseGitBranches ¶
type Commit ¶
type Commit struct {
Refs []string `json:"refs"`
FileLineDiffs []FileLineDiff `json:"fileLineDiffs"`
Additions int `json:"additions"`
Deletions int `json:"deletions"`
SHA1 string `json:"sha1"`
Parents []string `json:"parents"`
IsHead bool `json:"isHead"`
AuthorName string `json:"authorName,omitempty"`
AuthorEmail string `json:"authorEmail,omitempty"`
CommitterName string `json:"committerName,omitempty"`
CommitterEmail string `json:"committerEmail,omitempty"`
AuthorDate string `json:"authorDate,omitempty"`
CommitDate string `json:"commitDate,omitempty"`
ReflogID string `json:"reflogId,omitempty"`
ReflogName string `json:"reflogName,omitempty"`
ReflogAuthorName string `json:"reflogAuthorName,omitempty"`
ReflogAuthorEmail string `json:"reflogAuthorEmail,omitempty"`
SignatureDate string `json:"signatureDate,omitempty"`
SignatureMade string `json:"signatureMade,omitempty"`
Message string `json:"message"`
}
func ParseGitLog ¶
type CommitFile ¶
type Error ¶
type Error struct {
IsGitError bool `json:"isGitError"`
ErrorCode string `json:"errorCode"`
Command string `json:"command"`
WorkingDirectory string `json:"workingDirectory"`
ErrorText string `json:"error"`
Message string `json:"message"`
Stderr string `json:"stderr"`
Stdout string `json:"stdout"`
StdoutLower string `json:"stdoutLower"`
StderrLower string `json:"stderrLower"`
}
func (*Error) MarshalJSON ¶
type FileLineDiff ¶
type FileStatus ¶
type FileStatus struct {
FileName string `json:"fileName"`
OldFileName string `json:"oldFileName"`
DisplayName string `json:"displayName"`
Staged bool `json:"staged"`
Removed bool `json:"removed"`
IsNew bool `json:"isNew"`
Conflict bool `json:"conflict"`
Renamed bool `json:"renamed"`
Type string `json:"type"`
Additions any `json:"additions"`
Deletions any `json:"deletions"`
}
type Remote ¶
type Remote struct {
Name string `json:"name"`
FetchURL string `json:"fetchUrl,omitempty"`
PushURL string `json:"pushUrl,omitempty"`
URL string `json:"url,omitempty"`
}
func ParseGitRemotes ¶
type RevParseResult ¶
type Service ¶
type Service struct {
Runner *Runner
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) AutoStashExecuteAndPop ¶
func (s *Service) AutoStashExecuteAndPop(ctx context.Context, repoPath string, args []string, timeout time.Duration) (string, error)
AutoStashExecuteAndPop matches Ungit-compatible autoStashExecuteAndPop wrapper. It intentionally uses plain `git stash` just like the Node implementation.
func (*Service) CurrentBranch ¶
func (*Service) DiscardAllChanges ¶
func (*Service) DiscardChangesInFile ¶
func (*Service) ResolveConflicts ¶
func (*Service) RevParse ¶
func (s *Service) RevParse(ctx context.Context, repoPath string) RevParseResult
func (*Service) RunMutation ¶
type SimpleError ¶
func (*SimpleError) Error ¶
func (e *SimpleError) Error() string
type Status ¶
type Status struct {
Branch string `json:"branch"`
Files map[string]FileStatus `json:"files"`
InRebase bool `json:"inRebase"`
InMerge bool `json:"inMerge"`
InCherry bool `json:"inCherry"`
CommitMessage string `json:"commitMessage,omitempty"`
InConflict bool `json:"inConflict"`
}
func ParseGitStatus ¶
type VersionInfo ¶
type VersionInfo struct {
RequiredVersion string `json:"requiredVersion"`
Version string `json:"version"`
Satisfied bool `json:"satisfied"`
Error string `json:"error,omitempty"`
}
func GetVersionInfo ¶
func GetVersionInfo(ctx context.Context, gitBinPath *string) VersionInfo
Click to show internal directories.
Click to hide internal directories.