git

package
v0.0.0-...-3b5ec37 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2018 License: GPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GFV_ANCESTOR   GitFileVersion = 1
	GFV_OUR_HEAD                  = 2
	GFV_THEIR_HEAD                = 3
	GFV_OUR_WD                    = 4
	GFV_THEIR_WD                  = 5
	GFV_GIT_MERGED                = 6
	GFV_INDEX                     = 7
)
View Source
const (
	MergeFileError    = 0
	MergeFileResolved = 1
	MergeFileModified = 2
	MergeFileNew      = 3
	MergeFileDeleted  = 4
	MergeFileConflict = 5
)
View Source
const (
	FileAncestor FileVersion = 1
	FileOur                  = 2
	FileTheir                = 3
	FileWorking              = 4
	FileMerge                = 5
)
View Source
const (
	// The EMB system is in-sync with its Github repo
	EBMInSync = 1 << iota
	// There are staged changes on the EBM that been pushed to Github
	EBMChangesStaged
	// There are unstaged changes on the EBM
	EBMChangesUnstaged
	// EBM is in merged state, and conflicts need to be resolved
	EBMConflicted
	// There are changes on Github that haven't propagated to EBM
	EBMBehind
	// Commits on EBM haven't been propagated to Github. This is perhaps a theoretical
	// consideration, since design suggests no commits happen on EBM that aren't at
	// once pushed.
	EBMAhead
	// EBMUnimplemented is a Git state that EBM cannot handle. This will need to be
	// looked at if we encounter any of these.
	EBMUnimplemented

	// The GitHub repo is the source, and has no parent
	ParentNotExist
	// The parent of the GitHub repo is ahead of the GitHub repo
	ParentAhead
	// The parent of the GitHub repo is behind the GitHub repo: need to issue a PR
	ParentBehind
	// The parent of the GitHub repo, and the GitHub repo are in sync.
	// ParentInSync = (0==(state & (ParentAhead|ParentBehind|ParentNotExist)))
	ParentInSync
	StateNotSet
)
View Source
const DefaultSearchFile = `_data/meta.yml`
View Source
const GithubTokenCookie = "github_token_cookie"

Variables

View Source
var ErrNoGitDirectory = errors.New(`Not a GIT directory`)
View Source
var ErrNoGithubParent = errors.New(`This repo has no github parent: it was not forked.`)
View Source
var ErrNotInConflictedState = errors.New(`This repo is not in a conflicted state.`)
View Source
var ErrNotLoggedIn = errors.New(`No github token cookie found`)
View Source
var ErrRemoteIsNotGithub = fmt.Errorf("Remote is not a github remote")
View Source
var ErrUnknownUser = errors.New(`UnknownUser: no recognized login or ID`)

ErrUnknownUser indicates that Github was unable to resolve the user's name.

Functions

func Checkout

func Checkout(client *Client, repoOwner, repoName, repoUrl string) (string, error)

Checkout checks out the github repo into the cached directory system, and returns the path to the root of the repo. If the client is already checked out, it updates from the origin server. Returns the directory and a possible error.

func Commit

func Commit(client *Client, repoOwner, repoName, message string) (*git2go.Oid, error)

func ContainsFile

func ContainsFile(client *Client, gr *GitRepo) (bool, error)

func ContributeToRepo

func ContributeToRepo(client *Client, repoUserAndName string, private bool, msgCallback func(msg string)) error

ContributeToRepo configures a fork of the repo for the given user, and checks out the newly forked repo.

func CreateFile

func CreateFile(client *Client, user, repoOwner, repoName, path string, content []byte) error

func DeleteFile

func DeleteFile(client *Client, user, repoOwner, repoName, path string) error

func DeltaToString

func DeltaToString(d git2go.Delta) string

func DiffDeltaPath

func DiffDeltaPath(dd git2go.DiffDelta) string

DiffDeltaPath returns the path from a DiffDelta, selecting the OldFile by preference, or the NewFile if the OldFile is not defined

func DiffFlagToString

func DiffFlagToString(f git2go.DiffFlag) string

DiffFlagToString returns a string representation of a git2go.DiffFlag

func DiskSpaceFree

func DiskSpaceFree() (uint64, error)

func DuplicateRepo

func DuplicateRepo(client *Client, githubPassword string,
	templateRepo string, orgName string, newRepo string, private bool) error

DuplicateRepo duplicates the template repo into the user's github repos, and gives it the name newRepo. This is used to start a new book, without being a fork of the EBW electric-book repo. See https://help.github.com/articles/duplicating-a-repository/ for more information.

func FetchRemote

func FetchRemote(repo *git2go.Repository, remoteName string) (*git2go.Remote, error)

FetchRemote fetches all branches of the remote. It is the caller's responsibility to .Free the returned *Remote.

func FetchRemoteForRepo

func FetchRemoteForRepo(client *Client, repoOwner, repoName, remoteName string) (*git2go.Remote, error)

func FetchRemoteForRepoDir

func FetchRemoteForRepoDir(client *Client, repoDir string, remoteName string) (*git2go.Remote, error)

func FileExistsInWorkingDir

func FileExistsInWorkingDir(client *Client, repoOwner, repoName, path string) (bool, error)

func FileRenameInWorkingDir

func FileRenameInWorkingDir(client *Client, repoOwner, repoName, fromPath, toPath string) error

func FreeCommitSlice

func FreeCommitSlice(commits []*git2go.Commit)

FreeCommitSlice frees each of the git2go.Commit pointers in the given slice.

func GetFile

func GetFile(client *Client, user, repoOwner, repoName, path string) ([]byte, error)

GetFile returns the contents of the file at path in users given repo

func GetFileSHA

func GetFileSHA(client *Client, user, repoOwner, repoName, path string) (*string, error)

func GetPullRequest

func GetPullRequest(client *Client, user, repoOwner, repoName string, number int) (*github.PullRequest, error)

func GetUserForDir

func GetUserForDir(d string) (user, token string, err error)

GetUserForDir returns the user and token for the git repo containing the given directory. If an empty string is supplied as the directory, the current working directory is used instead.

func GitCloneTo

func GitCloneTo(client *Client, workingDir string, repoUsername, repoName string) error

GitCloneTo clones a repo to the given working directory.

func GitCurrentBranch

func GitCurrentBranch(clinet *Client, workingDir string) (string, error)

GitCurrentBranch returns the name of the currently checked-out branch.

func GitFindRepoRootDirectory

func GitFindRepoRootDirectory(workingDir string) (string, error)

GitFindRepoRootDirectory returns the first parent directory containing a .git subfolder, or an error if no such directory is found.

func GitMergeAnalysisToString

func GitMergeAnalysisToString(a git2go.MergeAnalysis) string

func GitMergePreferenceToString

func GitMergePreferenceToString(a git2go.MergePreference) string

func GitNotExistError

func GitNotExistError(err error) bool

GitNotExistError returns true if the given error occurred because the specified path did not exist

func GitRemoteRepo

func GitRemoteRepo(workingDir, remote string) (remoteUser, remoteProject string, err error)

GitRemoteRepo returns the remote repo name of the given remote It expects a remote of the form: [remotename] [remoteURL] ([fetch|push)]) so parses the results of `git remote get-url [remote]` which is expected to be a URL, takes the path and strips .git

func GitRepositoryStateToString

func GitRepositoryStateToString(state git2go.RepositoryState) string

func GitStatusToString

func GitStatusToString(status git2go.Status) string

func GithubDeleteRepo

func GithubDeleteRepo(apiToken string, githubUsername string,
	repoName string) error

GithubDeleteRepo deletes a repository on the github systems. See https://developer.github.com/v3/repos/#delete-a-repository Note that this should be used with extreme caution, since this is a total delete of the repo and all it contains, and cannot be undone.

func GithubPaginate

func GithubPaginate(list *github.ListOptions, get func() (*github.Response, error)) error

GithubPaginate handles pagination across Github calls that require a ListOptions class to determine the pagination.

func GithubTokenFromWebRequest

func GithubTokenFromWebRequest(r *http.Request) (string, error)

GithubTokenFromWebRequest returns the github token set with the token.

func HashFile

func HashFile(fn string) (string, error)

HashFile returns the hash of the file at fn

func ListFiles

func ListFiles(client *Client, user, repoOwner, repoName, pathRegexp string) ([]string, error)

ListFiles returns an array of all the files in the repo that match the pathRegexp regular expression.

func ListPullRequests

func ListPullRequests(client *Client, repoOwner, repoName string) ([]*github.PullRequest, error)

ListPullRequests returns a list of the Pull Requests for the given repoOwner/repoName

func PrintPdf

func PrintPdf(client *Client, user, repo string) (string, error)

func PullRequestClose

func PullRequestClose(client *Client, repoOwner, repoName string, number int) error

func PullRequestDir

func PullRequestDir(sha string) (string, error)

PullRequestDir returns the local git_cache location for the given pull request, or if sha is an empty string, the root directory for all prrequest checkouts

func PullRequestRemoteName

func PullRequestRemoteName(pr *github.PullRequest) string

PullRequestRemoteName returns the remote name for this PR when we configure it in our repo

func PullRequestUpdate

func PullRequestUpdate(client *Client, user, repoOwner, repoName string,
	sha string, path string, content []byte) error

PullRequestUpdate just updates the file in the 'master' repo the same as editing in the regular system.

func PullRequestVersions

func PullRequestVersions(client *Client, user, repoOwner, repoName, remoteUrl, remoteSha, filePath string) (string, string, error)

PullRequestVersions returns the local and remote version of the file named in filePath. This is used to match files for pull-request file merging.

func RemoteAdd

func RemoteAdd(client *Client, user, repoOwner, repoName, remoteUrl string) (string, error)

RemoteAdd adds a new Remote to the git remotes

func RemoteName

func RemoteName(remoteUrl string) string

RemoteName returns a name for the remote based on the remoteUrl

func RepoDir

func RepoDir(user, repoOwner, repoName string) (string, error)

RepoDir returns the local git_cache repo working directory location. If repoOwner or repoName is an empty string, the path is returned up to that level. BUT, you cannot just Join the path pieces - you need to call RepoDir again to get the additional parts.

func SaveWorkingFile

func SaveWorkingFile(client *Client, repoOwner, repoName, path string, content []byte) error

SaveWorkingFile saves the named file on the repo in the working directory. It does not commit the file's change.

func StageFile

func StageFile(client *Client, repoOwner, repoName, path string) error

StageFile adds the named file to the index, or removes the file from the index if it does not exist in the working dir. This is intended as a functional equivalent of `git add [path]`

func StatusEntryStatusToString

func StatusEntryStatusToString(s git2go.Status) string

func UpdateFile

func UpdateFile(client *Client, user, repoOwner, repoName, path string, content []byte) error

UpdateFile updates the given file with the given content, and adds it to the git staging area, ready for the next commit.

func UrlUserRepo

func UrlUserRepo(remoteUrl string) (string, string, error)

UrlUserRepo returns the user and repo given a github URL

func Username

func Username(client *Client) (string, error)

Username returns the username of the currently logged in user on GitHub, retrieved from the Client.

Types

type Client

type Client struct {
	*github.Client
	Username string
	Token    string
	Context  context.Context
	User     *github.User
}

func ClientFromCLIConfig

func ClientFromCLIConfig() (*Client, error)

ClientFromConfig returns the client based on the configuration

func ClientFromCLIConfigAlias

func ClientFromCLIConfigAlias(name string) (*Client, error)

ClientFromCLIConfigAlias returns the client for the user with the given alias from the cli config.

func ClientFromCLIConfigNamed

func ClientFromCLIConfigNamed(name string) (*Client, error)

ClientFromCLIConfigNamed returns the client for the named user from the cli config.

func ClientFromUsernamePassword

func ClientFromUsernamePassword(username, password string) (*Client, error)

ClientFromUsernamePassword returns a new GitHub client from the given username-password combination, or from CLI config if both are empty strings.

func ClientFromWebRequest

func ClientFromWebRequest(w http.ResponseWriter, r *http.Request) (*Client, error)

ClientFromWebRequest returns a client for Github communcations from the given web request.

func (*Client) AddAuth

func (c *Client) AddAuth(origUrl string) (string, error)

AddAuth adds username and password authentication to the origUrl from the client credentials.

func (*Client) GithubInvitationAccept

func (c *Client) GithubInvitationAccept(id int, accept bool) error

GithubInvitationAccept accepts or declines the invitation with the given ID.

func (*Client) UserInvitations

func (c *Client) UserInvitations() ([]*GithubInvitation, error)

UserInvitations returns a slice of all the open invitations for the current user.

type CommitInfo

type CommitInfo struct {
	LastModified time.Time
	Committer    string
	// contains filtered or unexported fields
}

func LastCommit

func LastCommit(client *Client, userName, repoName string) (*CommitInfo, error)

LastCommit returns the last commit for the given repo

type ConflictWalkFunc

type ConflictWalkFunc func(git2go.IndexConflict) error

ConflictWalkFunc is the callback function to use with WalkConflicts

type DiffDelta

type DiffDelta struct {
	Type DiffDeltaType
	git2go.DiffDelta
}

DiffDelta is a wrapper around git2go.DiffDelta

func (*DiffDelta) StatusString

func (rd *DiffDelta) StatusString() string

func (*DiffDelta) String

func (rd *DiffDelta) String() string

type DiffDeltaType

type DiffDeltaType int
const (
	HeadToIndex DiffDeltaType = 1 << iota
	IndexToWt
)

type Directory

type Directory struct {
	Files []DirectoryEntry
	// contains filtered or unexported fields
}

func (*Directory) Filter

func (d *Directory) Filter(base string, filter func(fullname string) bool) DirectoryEntry

func (*Directory) IsDirectory

func (d *Directory) IsDirectory() bool

func (*Directory) Map

func (d *Directory) Map() map[string]interface{}

func (*Directory) MarshalJSON

func (d *Directory) MarshalJSON() ([]byte, error)

func (*Directory) Name

func (d *Directory) Name() string

func (*Directory) ReadDirectory

func (d *Directory) ReadDirectory(base string) error

type DirectoryEntry

type DirectoryEntry interface {
	Name() string
	IsDirectory() bool
	Map() map[string]interface{}
	Filter(base string, f func(fullname string) bool) DirectoryEntry
}

func ListAllRepoFiles

func ListAllRepoFiles(client *Client, user, repoOwner, repoName string) (DirectoryEntry, error)

ListAllRepoFiles returns a Directory type with all the files in the repo.

func NewDirectory

func NewDirectory(base string) (DirectoryEntry, error)

type EBWRepoStatus

type EBWRepoStatus struct {
	MergingDescription string `yaml:"merging_description"`
	MergingPRNumber    int    `yaml:"merging_pr_number"`
	// MergingFiles is a list of the files that are in conflict / modified
	// when the merge occurs. Because EBW allows us to delete and commit a delete
	// on the server, the deleted file will not exist in either the repo, the
	// their files, or the index, so it's not possible for us to find out that the
	// file has been deleted and committed (although the file should still exist in
	// HEAD, we would have to work our way through the whole of HEAD looking for it).
	MergingFiles []string `yaml:"merging_files"`
	// LastPRHash contains the Hash of the commit used for the last PR
	// sent from this repo. This is used to determine whether new changes
	// have been made on the repo that the user could push upstream.
	LastPRHash string `yaml:"last_pr_hash"`
	// LastUpstreamMergeHash is the last hash on the upstream remote
	// with which the local has merged. We need this to determine two
	// things- whether we have new PR's to push -
	LastUpstreamMergeHash string `yaml:"last_upstream_merge_hash"`
	// contains filtered or unexported fields
}

EBWRepoStatus constains information on the status of the repo that might not (?) be possible to retrieve from reading the actual repo directory. In particular, it describes, when a merge is in process, which (if any) PR is being merged, and the origin of the merge (e.g. merging a particular PR, or merging with Github, or merging with original book).

func (*EBWRepoStatus) Read

func (rs *EBWRepoStatus) Read(path string) (*EBWRepoStatus, error)

Read reads the EBWRepoStatus from the path provided

func (*EBWRepoStatus) ResetMerge

func (rs *EBWRepoStatus) ResetMerge()

ResetMerge resets all the merge information in the EBWRepoStatus struct

func (*EBWRepoStatus) ToYaml

func (rs *EBWRepoStatus) ToYaml() string

ToYaml converts the EBWRepoStatus to a yaml description

func (*EBWRepoStatus) Write

func (rs *EBWRepoStatus) Write() error

Write writes the EBWRepoStatus back to the file whence it was read.

type File

type File struct {
	// contains filtered or unexported fields
}

func (*File) Filter

func (f *File) Filter(base string, filter func(fullname string) bool) DirectoryEntry

func (*File) IsDirectory

func (f *File) IsDirectory() bool

func (*File) Map

func (f *File) Map() map[string]interface{}

func (*File) MarshalJSON

func (f *File) MarshalJSON() ([]byte, error)

func (*File) Name

func (f *File) Name() string

type FileDiff

type FileDiff struct {
	Delta *git2go.DiffDelta
}

FileDiff contains a difference between two versions of a single file

func (*FileDiff) Close

func (t *FileDiff) Close()

func (*FileDiff) NewFileExists

func (t *FileDiff) NewFileExists() bool

func (*FileDiff) NewFileOidString

func (t *FileDiff) NewFileOidString() string

func (*FileDiff) OldFileExists

func (t *FileDiff) OldFileExists() bool

func (*FileDiff) OldFileOidString

func (t *FileDiff) OldFileOidString() string

func (*FileDiff) Path

func (t *FileDiff) Path() string

Path returns the path of the file in the FileDiff deltas, preferring the old path to the new path

func (*FileDiff) String

func (t *FileDiff) String() string

type FileInfo

type FileInfo struct {
	Path string
	Hash *git2go.Oid
}

func NewFileInfoFromPath

func NewFileInfoFromPath(path string) (*FileInfo, error)

func (*FileInfo) String

func (f *FileInfo) String() string

type FileTree

type FileTree struct {
	Path      func(path ...string) string
	Temporary bool
}

FileTree is a model of a filetree that is stored on disk. The Path() method resolves relative paths into the tree, while the Temporary flag indicates whether the filetree will be removed on cleanup.

func (*FileTree) Cleanup

func (ft *FileTree) Cleanup() error

Cleanup performs any necessary cleanup on a FileTree

func (*FileTree) Exists

func (ft *FileTree) Exists(path string) (bool, error)

Exists returns true if the given path exists on the FileTree or false otherwise.

func (*FileTree) Read

func (ft *FileTree) Read(path string) ([]byte, error)

Read reads the given path from the FileTree

func (*FileTree) Remove

func (ft *FileTree) Remove(path string) error

Remove removes the given path from the FileTree

func (*FileTree) Sync

func (ft *FileTree) Sync(r *Repo, version FileVersion) error

Sync synchronizes a FileTree with a given version of a merging repo.

func (*FileTree) Write

func (ft *FileTree) Write(path string, data []byte) error

Write writes the given data to the specified path on the FileTree. If data is nil, the file is deleted.

type FileVersion

type FileVersion int

type Git

type Git struct {
	Context    context.Context
	Repository *git2go.Repository
	Log        logger.Logger
	// contains filtered or unexported fields
}

Git struct provides the commands that the command-line git repo would provide, with, perhaps, some slight additionals. Largely, it works off the git2go library, and manages a few presumed things about the library, but scanning for github username-password, etc. It also manages the EBWRepoStatus, which is an extended-status form for a Git repo.

func OpenGit

func OpenGit(repoDir string, log logger.Logger) (*Git, error)

OpenGit opens a Git Repo at the given directory, and configures the logger for the git repo

func (*Git) AddAllStagedFilesToIndex

func (g *Git) AddAllStagedFilesToIndex() error

Adds all staged working dir files to the index.

func (*Git) AddAuth

func (g *Git) AddAuth(origUrl string) (string, error)

AddAuth adds username and password authentication to the original url taken from the repo origin client credentials.

func (*Git) AddRemote

func (g *Git) AddRemote(remoteName, cloneURL string) error

AddRemote adds the named remote to Git with the given clone URL. If the remote already exists, AddRemote does not change it.

func (*Git) AddToIndex

func (g *Git) AddToIndex(path string) error

AddToIndex adds the file at path to the index, if it exists, or deletes the file in the index if it does not exist.

func (*Git) AheadBehind

func (g *Git) AheadBehind(remoteName string) (int, int, error)

AheadBehind returns the commits that HEAD is ahead, and that HEAD is behind remote.

func (*Git) CatFileVersion

func (g *Git) CatFileVersion(path string, v GitFileVersion, auto *bool) ([]byte, error)

CatFileVersion returns the contents of the path for the given GitFileVersion

func (*Git) Close

func (g *Git) Close() error

Close closes the git repo and frees any associated resources.

func (*Git) Commit

func (g *Git) Commit(message string) (*git2go.Oid, error)

Commit commits the staged changes on the repo with the given message. Commit also cleans up any meta-state that exists as a result of committing a merge- it closes PR's and updates the EBW status.

func (*Git) CommitFileDiffs

func (g *Git) CommitFileDiffs(oldObject, newObject *git2go.Object) ([]*FileDiff, error)

CommitFileDiffs returns a slice of FileDiffs for all differences between the two commits. oldObject and newObject need to be objects that can resolve to Trees / Commits. If null==oldObject, oldObject will be set to the current repo HEAD.

func (*Git) ConflictFileDiffs

func (g *Git) ConflictFileDiffs(oldCommitObject, newCommitObject *git2go.Object) error

ConflictFileDiffs sets all file differences between the two supplied commits to a conflict state. If nil==oldCommitObject, oldCommitObject will be set to the current repo's HEAD

func (*Git) DefaultSignature

func (g *Git) DefaultSignature() (*git2go.Signature, error)

DefaultSignature guesses at a signature for the repo based on the git username and config

func (*Git) Error

func (g *Git) Error(err error) error

Error logs an error and returns an error, or returns nil if err is nil.

func (*Git) ExistsFileVersion

func (g *Git) ExistsFileVersion(path string, v GitFileVersion, auto *bool) (bool, error)

ExistsFileVersion returns whether the path exists for the given GitFileVersion

func (*Git) FetchRefspecs

func (g *Git) FetchRefspecs(remoteName string) ([]string, error)

FetchRefspecs fetches the refspecs for the named remote.

func (*Git) FetchRemote

func (g *Git) FetchRemote(remoteName string) error

FetchRemote fetches the named remote into our repo.

func (*Git) GetBranch

func (g *Git) GetBranch(remoteBranch string) (*git2go.Object, error)

GetBranch looks up the branch with the given name, where the name could be HEAD, a branch name, or a remote/branch name format.

func (*Git) GetUpstreamRemote

func (g *Git) GetUpstreamRemote() (user string, name string, err error)

GetUpstreamRemote returns the owner and repo-name for the repo's upstream remote.

func (*Git) GetUpstreamRemoteActions

func (g *Git) GetUpstreamRemoteActions() (GitRemoteAction, error)

GetUpstreamRemoteActions indicates the possible actions we could perform on upstream repo.

func (*Git) GithubClient

func (g *Git) GithubClient() (*github.Client, error)

GitubClient returns a github.Client configured with the password for the `origin` remote of this git repo. It ONLY uses the password, hence it requires the password to be a github TOKEN. If the password is not a token, the github client it returns will not work.

func (*Git) GithubClosePullRequest

func (g *Git) GithubClosePullRequest(merged bool) error

GithubClosePullRequest closes the currently open pull-request on github.

func (*Git) GithubRemote

func (g *Git) GithubRemote(remoteName string) (*GithubRemote, error)

GithubCanSubmitPR returns true if this repo has a github parent - an upstream repo - and the current repo differs from the upstream remote at the last point that the upstream remote was merged.

func (*Git) GithubRepo

func (g *Git) GithubRepo() (*github.Repository, error)

GithubRepo returns github.Repository for the github repo that this repo was cloned from.

func (*Git) GithubUser

func (g *Git) GithubUser() (*github.User, error)

GithubUser returns the github user for this repo

func (*Git) HasConflicts

func (g *Git) HasConflicts() (bool, error)

HasConflicts returns true if the repo has conflicted files

func (*Git) HasUpstreamRemote

func (g *Git) HasUpstreamRemote() (bool, error)

HasUpstreamRemote returns true if the repo has an upstream remote - ie a parent to the github repo

func (*Git) Infof

func (g *Git) Infof(fmt string, args ...interface{})

func (*Git) IsFileConflicted

func (g *Git) IsFileConflicted(path string) (bool, error)

IsFileConflicted returns true if the file at the given path is in a conflicted state.

func (*Git) IsMerging

func (g *Git) IsMerging() bool

IsMerging returns true if the repo is merging

func (*Git) IsOurHeadInWd

func (g *Git) IsOurHeadInWd(path string) (bool, error)

func (*Git) ListConflictedFiles

func (g *Git) ListConflictedFiles() ([]string, error)

ListConflictedFiles returns a list of the files that are conflicted in the repo.

func (*Git) ListDiffsIndexToWt

func (g *Git) ListDiffsIndexToWt() ([]*DiffDelta, error)

ListDiffsIndexToWt returns the RepoDiffs for the difference between the index and the working tree.

func (*Git) MergeAnalysis

func (g *Git) MergeAnalysis(remoteName string) (git2go.MergeAnalysis, git2go.MergePreference, error)

MergeAnalysis returns the git2go analysis of possible merge options with the given remote.

func (*Git) MergeBranch

func (g *Git) MergeBranch(remoteName string, resolve MergeResolution) (bool, error)

MergeBranch merges the remote branch with the given resolution. The return values are TRUE if a fast-forward was possible, false if no fast-forward was effected.

func (*Git) MergeCanFastForward

func (g *Git) MergeCanFastForward(remoteName string) (bool, error)

MergeCanFastForward returns true if it is possible for this merge to fast-foward to the given remote.

func (*Git) MergePullRequest

func (g *Git) MergePullRequest(pullRequestNumber int, remoteName, pullRequestSHA string) error

MergePullRequest does a merge with the given PullRequest identified by number and pullRequestSHA

func (*Git) MergingFilesList

func (g *Git) MergingFilesList() ([]*IndexFileStatusAbbreviated, error)

MergingFilesList returns a list of the files that are currently in the process of being merged to resolve the current conflict state

func (*Git) MergingPRNumber

func (g *Git) MergingPRNumber() (int, error)

MergingPRNumber returns the number of the PR currently being merged, or 0 if no PR is currently being merged.

func (*Git) Path

func (g *Git) Path(path ...string) string

Path returns the disk-based path for the repo or any path inside the repo

func (*Git) PathEBWConfig

func (g *Git) PathEBWConfig(path ...string) string

PathEBWConfig returns the path to the ebw config directory

func (*Git) PathTheir

func (g *Git) PathTheir(path ...string) string

PathTheir returns the path to the cached checkout of 'their' when a merge is in progress.

func (*Git) PrintEBWRepoStatus

func (g *Git) PrintEBWRepoStatus(out io.Writer)

PrintEBWRepoStatus prints the info from the EBWRepoStatus to the io.Writer

func (*Git) PullAbort

func (g *Git) PullAbort(closePullRequest bool) error

PullAbort aborts a merge that is in progress. This isn't quite like `git merge --abort`, because this is in fact simply a RESET to HEAD, which occurs in spite of, or while ignoring, any changed files in WD. `git merge --abort`, though, will fail if there are modified files in WD (or something like that).

func (*Git) PullOrigin

func (g *Git) PullOrigin() error

PullOrigin pulls the repo origin and attempts an auto-merge with master branch. If the merge succeeds, a new commit is generated.

func (*Git) PullUpstream

func (g *Git) PullUpstream() error

PullUpstream pulls the repo upstream and attempts to auto-merge with the master branch. If the merge succeeds without conflict, a new commit is generated.

func (*Git) Push

func (g *Git) Push(remoteName, remoteBranch string) error

Push pushes the current branch to the named remote and remote branch

func (*Git) RemoteUser

func (g *Git) RemoteUser(remoteName string) (string, string, error)

RemoteUser returns the username and password of the remote git user.

func (*Git) RemoveConflict

func (g *Git) RemoveConflict(path string) error

RemoveConflict resolves the conflict on the file at the given path with the file in the WD, or deletes if the file does not exist in the WD

func (*Git) RepoState

func (g *Git) RepoState() *GitRepoState

RepoState returns the state of the repo. Per https://libgit2.github.com/libgit2/#HEAD/group/repository/git_repository_state this determines the status of a git repository - ie, whether an operation (merge, cherry-pick, etc) is in progress.

func (*Git) SHAHead

func (g *Git) SHAHead() (string, error)

SHAHead returns the SHA of the TREE of the HEAD of the repo as a string.

func (*Git) SHARemote

func (g *Git) SHARemote(remoteName string, fetch bool) (string, error)

SHARemote returns the SHA of the TREE of the HEAD of the remote repo as a string. If fetch is true, it will fetch the remote first.

func (*Git) SetRemoteUserPassword

func (g *Git) SetRemoteUserPassword(remoteName, username, password string) error

SetRemoteUserPassword sets the username and password for the given remote. It sets the fetch URL, and the pushurl if there is one configured.

func (*Git) SetUpstreamRemote

func (g *Git) SetUpstreamRemote() error

SetUpstreamRemote sets the remote `upstream` for the repo.

func (*Git) SetUsernameEmail

func (g *Git) SetUsernameEmail(name, email string) error

SetUsernameEmail sets the git user.name and user.email configuration values.

func (*Git) StagedFiles

func (g *Git) StagedFiles() ([]*IndexFileStatus, error)

StagedFiles returns a list of the files currently staged in the index.

func (*Git) UpdateRemoteGithubIdentity

func (g *Git) UpdateRemoteGithubIdentity(username, password string) error

UpdateRemoteGithubIdentity updates all github remotes for the git repo inserting the given username and password for each URL.

func (*Git) WalkConflicts

func (g *Git) WalkConflicts(f ConflictWalkFunc) error

WalkConflicts calls the ConflictWalkFunc for every conflict in the index.

func (*Git) WriteVersionToWd

func (g *Git) WriteVersionToWd(path string, v GitFileVersion) error

WriteVersionToWd writes the given version of the file to the wd.

type GitFileVersion

type GitFileVersion int

func ParseGitFileVersion

func ParseGitFileVersion(in string) (GitFileVersion, error)

ParseGitFileVersion converts a string to a GitFileVersion

type GitRemoteAction

type GitRemoteAction int
const (
	GitRemoteActionNone     GitRemoteAction = 0
	GitRemoteActionCreatePR GitRemoteAction = 1
	GitRemoteActionPull                     = 2
)

func (GitRemoteAction) CanCreatePR

func (ra GitRemoteAction) CanCreatePR() bool

func (GitRemoteAction) CanPull

func (ra GitRemoteAction) CanPull() bool

func (GitRemoteAction) InSync

func (ra GitRemoteAction) InSync() bool

func (GitRemoteAction) String

func (ra GitRemoteAction) String() string

type GitRepo

type GitRepo struct {
	*github.Repository
	// contains filtered or unexported fields
}

func FetchRepos

func FetchRepos(client *Client, page, perPage int) ([]*GitRepo, error)

FetchRepos fetches all the repositories for the client

func (*GitRepo) CanPush

func (g *GitRepo) CanPush() bool

CanPush returns true if this user can push to the repo, or false otherwise

func (*GitRepo) GetLastCommit

func (gr *GitRepo) GetLastCommit() *CommitInfo

func (*GitRepo) GetTotalPRs

func (gr *GitRepo) GetTotalPRs() int

func (*GitRepo) RepoOwner

func (g *GitRepo) RepoOwner() string

GetRepoOwner returns the github username of the owner of the repo.

func (*GitRepo) RepoOwnerNiceName

func (g *GitRepo) RepoOwnerNiceName() string

RepoOwnerNiceName returns the users name or login if the name isn't available.

type GitRepoState

type GitRepoState struct {
	RepositoryState git2go.RepositoryState
}

GitRepoState wraps the state of a repo.

func (*GitRepoState) String

func (rs *GitRepoState) String() string

type GithubInvitation

type GithubInvitation struct {
	*github.RepositoryInvitation
}

type GithubRemote

type GithubRemote struct {
	Owner string
	Repo  string
}

type IndexFileStatus

type IndexFileStatus struct {
	*git2go.StatusEntry
}

func NewIndexFileStatus

func NewIndexFileStatus(se git2go.StatusEntry) *IndexFileStatus

func (*IndexFileStatus) Abbreviated

func (ifs *IndexFileStatus) Abbreviated() *IndexFileStatusAbbreviated

func (*IndexFileStatus) Path

func (ifs *IndexFileStatus) Path() string

func (*IndexFileStatus) StatusString

func (ifs *IndexFileStatus) StatusString() string

type IndexFileStatusAbbreviated

type IndexFileStatusAbbreviated struct {
	Path   string
	Status string
}

type MergeFileInfo

type MergeFileInfo struct {
	Working *FileInfo
	Their   *FileInfo
	Index   *FileInfo
}

func (*MergeFileInfo) String

func (mf *MergeFileInfo) String() string

type MergeFileResolutionState

type MergeFileResolutionState int

func (*MergeFileResolutionState) MarshalJSON

func (m *MergeFileResolutionState) MarshalJSON() ([]byte, error)

func (MergeFileResolutionState) String

func (m MergeFileResolutionState) String() string

type MergeResolution

type MergeResolution int
const (
	// ResolveAutomatically will attempt to auto-merge
	// all files. If a file can be auto-merged, it will be added to the
	// index and wd in a resolved state, and marked as resolved in the index.
	// If the file cannot be automatically resolved, it will be marked as
	// conflicted in the index, and the WD will contain the git-merge
	// result.
	ResolveAutomatically MergeResolution = 1
	// ResolveConficted will leave all files in the merge in a
	// conflicted state, even in the situation where Git might have been
	// able to resolve the merge.
	ResolveConflicted = 2
)

type PullRequest

type PullRequest struct {
	*github.PullRequest
}

type PullRequestDiff

type PullRequestDiff struct {
	Path       string `json:"path"`
	RemotePath string `json:"remote_path"`
	RemoteHash string `json:"remote_hash"`
	LocalPath  string `json:"local_path"`
	LocalHash  string `json:"local_hash"`

	Equal bool `json:"equal"`
}

func GetPathDiff

func GetPathDiff(localRoot, remoteRoot, path string) (*PullRequestDiff, error)

func GetPathDiffList

func GetPathDiffList(localPath, remotePath string, pathRegexp string) ([]*PullRequestDiff, error)

func PullRequestDiffList

func PullRequestDiffList(client *Client, repoOwner, repoName string,
	pr *github.PullRequest) ([]*PullRequestDiff, error)

func PullRequestDiffListByNumber

func PullRequestDiffListByNumber(client *Client, repoOwner, repoName string,
	prNumber int) ([]*PullRequestDiff, error)

func (*PullRequestDiff) String

func (prd *PullRequestDiff) String() string

type PullRequestInfo

type PullRequestInfo struct {
	PRCount int
	// contains filtered or unexported fields
}

func TotalPRs

func TotalPRs(client *Client, userName, repoName string) (*PullRequestInfo, error)

TotalPRs returns the number of prs for a repo

type Repo

type Repo struct {
	*git2go.Repository
	Dir string

	Client    *Client
	RepoOwner string
	RepoName  string

	EBWRepoStatus *EBWRepoStatus

	Log *logrus.Entry
	Git *Git
	// contains filtered or unexported fields
}

Repo is a struct mapped to a directory on dist with a checked-out github repo. The directory does not necessarily have to be configured against the server git_cache, but could be retrieved with NewRepoForDir(..), which allows creating the repo against an existing directory possibly in a different location.

func NewRepo

func NewRepo(client *Client, repoOwner, repoName string) (*Repo, error)

NewRepo returns a new Repo struct configured against the directory with the checked-out repo.

func NewRepoForDir

func NewRepoForDir(client *Client, repoDir string, isCLI bool) (*Repo, error)

NewRepoForDir returns a new repo configured for the given directory.

func (*Repo) AddAllStagedFilesToIndex

func (r *Repo) AddAllStagedFilesToIndex() error

AddAllToIndex adds all staged files to the index, including deleting files from the index if they don't exist in the WD.

func (*Repo) AddRemote

func (r *Repo) AddRemote(remoteName string, remoteCloneURL string) error

AddRemote adds the given remoteName with the given CloneURL, but does not change any existing remote with the given remoteName

func (*Repo) AddToIndex

func (r *Repo) AddToIndex(path string) error

AddToIndex adds the file at path to the index, if it exists, or deletes the file in the index if it does not exist.

func (*Repo) AutoProcessState

func (r *Repo) AutoProcessState() (bool, error)

AutoProcessState runs automatic state processing on a repo, and returns true if the repo state has changed

func (*Repo) BranchCreate

func (r *Repo) BranchCreate(name string, force bool) (string, *git2go.Oid, error)

BranchCreate creates the named branch on the repo. The force param is set to true if you wish to overwrite an existing branch with the same name. If no name is provided, this function will assign a name based on the template PR_{{username}}_{{prN}} for the current head, where prN is the N+1 for N the total number of pull requests on the repo.

func (*Repo) CLI

func (r *Repo) CLI() bool

CLI returns true if this repo is working against a CLI, false if we're in a server situation.

func (*Repo) CanCreatePR

func (r *Repo) CanCreatePR() (bool, error)

CanCreatePR returns true if the Upstream repo is behind the Github repo, and there has been a new commit since the last PR was issued.

func (*Repo) CanPush

func (r *Repo) CanPush() (bool, error)

CanPush returns true if the user can push to the repo.

func (*Repo) Checkout

func (r *Repo) Checkout() error

Checkout checks out the repository into the repo directory.

func (*Repo) Cleanup

func (r *Repo) Cleanup() error

Cleanup cleans up the state of the repo, and also removes any temporary files that a merge or conflict state might have created. This is probably only necessary to call from CloseConflict - any other version should not be required.

func (*Repo) CleanupConflictTemporaryFiles

func (r *Repo) CleanupConflictTemporaryFiles() error

CleanupConflictTemporaryFiles cleans up any temporary files used in a conflict resolution.

func (*Repo) Close

func (r *Repo) Close()

Close closes the repo and any resources it is using

func (*Repo) CloseConflict

func (r *Repo) CloseConflict(message, notes string) error

CloseConflict closes the conflict on the repo, including closing PR's if PR merges are in process.

func (*Repo) Commit

func (r *Repo) Commit(message string, notes string) (*git2go.Oid, error)

Commit commits the changes on the repo with the given message.

func (*Repo) CommitAll

func (r *Repo) CommitAll(message, notes string) (*git2go.Oid, error)

CommitAll works like `git commit -am` first adding all working-dir modified files to the index.

func (*Repo) CommitIfNoConflicts

func (r *Repo) CommitIfNoConflicts() (bool, error)

CommitIfNoConflicts will commit the changes to the repo if there are no conflicted files in the repo. Returns true if the commit succeeded, false otherwise.

func (*Repo) ConfigPath

func (r *Repo) ConfigPath(path ...string) string

ConfigPath returns the path mapped into the EBW `config` directory

func (*Repo) DiffsIndexToWt

func (r *Repo) DiffsIndexToWt() ([]*DiffDelta, error)

DiffsIndexToWt returns the RepoDiffs for the difference between the index and the working tree.

func (*Repo) DumpIndex

func (r *Repo) DumpIndex() error

DumpIndex dumps the current contents of the git index to stdout

func (*Repo) Error

func (r *Repo) Error(err error) error

Error logs an error if an error is set, or returns nil

func (*Repo) Errorf

func (r *Repo) Errorf(formatter string, args ...interface{}) error

Errorf logs an error from the formatter and arguments describing the error

func (*Repo) FetchRemote

func (r *Repo) FetchRemote(remoteName string) error

FetchRemote fetches the named remote for the repo.

func (*Repo) FileBlob

func (r *Repo) FileBlob(fileId *git2go.Oid) ([]byte, error)

FileBlob returns the file contents as a Blob

func (*Repo) FileCat

func (r *Repo) FileCat(path string, version FileVersion) (bool, []byte, error)

FileCat returns the contents of a conflicted or merged file. The first bool parameter indicates whether the files exists.

func (*Repo) FileGit

func (r *Repo) FileGit(path string) (automergeable bool, raw []byte, err error)

FileGit returns the GIT version of a conflicted file. The first bool return indicates whether the file can be automerged.

func (*Repo) FileInfoFromIndex

func (r *Repo) FileInfoFromIndex(path string) (*FileInfo, error)

FileInfoFromIndex returns FileInfo for the given path from the Index

func (*Repo) GetRepoState

func (r *Repo) GetRepoState() (RepoState, error)

GetRepoState returns the RepoState for the repo, cached if the repo state has been computed before.

func (*Repo) GetUpstreamPullRequestsCount

func (r *Repo) GetUpstreamPullRequestsCount() (int, error)

GetUpstreamPullRequestsCount returns the number of PR's that the upstream github repo has.

func (*Repo) GithubRepo

func (r *Repo) GithubRepo() (*github.Repository, error)

GithubRepo returns the github Repository for this repo.

func (*Repo) HasConflictedFiles

func (r *Repo) HasConflictedFiles() (bool, error)

HasConflictedFiles returns true if the repo has conflicted files, false if there are no conflicts in the repo.

func (*Repo) HasUpstreamRemote

func (r *Repo) HasUpstreamRemote() (bool, error)

HasUpstreamRemote returns true if the repo has an upstream remote - ie a parent to the github repo

func (*Repo) IndexEntry

func (r *Repo) IndexEntry(path string) (*git2go.IndexEntry, error)

IndexEntry returns the libgit2 entry from the Index for the given path.

func (*Repo) Infof

func (r *Repo) Infof(format string, args ...interface{})

Infof logs the format and args as an sprintf info level log message

func (*Repo) IsFileConflicted

func (r *Repo) IsFileConflicted(path string) (bool, error)

IsFileConflicted returns whether the given file is in conflict in the repo

func (*Repo) ListConflictedFiles

func (r *Repo) ListConflictedFiles() ([]string, error)

ListConflictedFiles returns a list of all the currently conflicted files in the repo

func (*Repo) ListRepoConflicts

func (r *Repo) ListRepoConflicts() ([]*RepoConflict, error)

ListRepoConflicts lists all the conflicted files in the repo. (The repo must be in a Merge state in order for there to be conflicted files at all.) It doesn't appear to be necessary that the repo is in a merge state in order to have conflicts - I've definitely managed to get conflicts in a repo that is in RepoStateNone. TODO: Investigate why it appears possible to be conflicted while in git2go.RepoStateNone

func (*Repo) MergeCommits

func (r *Repo) MergeCommits(includeHead bool) ([]*git2go.Commit, error)

MergeCommits returns a slice of the Commits that contributed to this merge. includeHead indicates whether to include the HEAD commit - this should always be TRUE. The caller needs to free the Commit structures. Use the handy FreeCommitSlice([]*Commit) to do so.

func (*Repo) MergeFileInfo

func (r *Repo) MergeFileInfo(path string) (*MergeFileInfo, error)

MergeFileInfo returns the MergeFileInfo for the named path in the Working dir, the Their dir, and the Index

func (*Repo) MergeFileResolutionState

func (r *Repo) MergeFileResolutionState(path string) (MergeFileResolutionState, error)

MergeFileResolutionState returns the state of the merging file at the given path.

func (*Repo) MergeWith

func (r *Repo) MergeWith(remote, branch string, resolve ResolveMergeOption, conflicted bool, prNumber int, description string) error

MergeWith merges the repo with the given remote and branch, and configures all the EBW Server required configurations for correct conflict management. At present MergeWith will not work on the command line unless the user is within a EBW Server structured git repo.

func (*Repo) MergingFilesList

func (r *Repo) MergingFilesList() ([]*IndexFileStatusAbbreviated, error)

MergingFilesList returns a slice of all the files in the repo that are merging, with a status indication for each.

func (*Repo) MergingPRNumber

func (r *Repo) MergingPRNumber() (int, error)

MergingPRNumber returns the number of the current PR being merged, or 0 if no PR is currently being merged.

func (*Repo) MustRepoState

func (r *Repo) MustRepoState() RepoState

func (*Repo) PrintLocalChanges

func (r *Repo) PrintLocalChanges() error

PrintLocalChanges prints all locally chnaged files that aren't staged.

func (*Repo) PrintStatusList

func (r *Repo) PrintStatusList() error

PrintStatusList prints the information from the status list for the repo. It is primarily at this point intended as a debugging tool.

func (*Repo) Pull

func (r *Repo) Pull(remoteName, branchName string) error

Pull fetches and merges this repo with the branchName of the remote repo. Note that Pull will leave the repo in the Merge state. You need to fix any conflicts, and then commit.

func (*Repo) PullAbort

func (r *Repo) PullAbort(closePullRequest bool) error

PullAbort aborts a merge that is in progress. This isn't quite like `git merge --abort`, because this is in fact simply a RESET to HEAD, which occurs in spite of, or while ignoring, any changed files in WD. `git merge --abort`, though, will fail if there are modified files in WD (or something like that).

func (*Repo) PullOrigin

func (r *Repo) PullOrigin() error

PullOrigin pulls the repos origin into the repo, merging per git merge rules.

func (*Repo) PullPR

func (r *Repo) PullPR(prNumber int) error

PullPR pulls the given PR into the repo, doing a our-their merge on conflicted files.

func (*Repo) PullRequest

func (r *Repo) PullRequest(number int) (*github.PullRequest, error)

PullRequest returns the pull request with the given number for the repo.

func (*Repo) PullRequestClose

func (r *Repo) PullRequestClose(number int, merged bool) error

PullRequestClose closes the given PR, with the merged indication and the given message.

func (*Repo) PullRequestCreate

func (r *Repo) PullRequestCreate(title, notes string) (int, error)

PullRequestCreate creates a new Pull Request from the user's repo to the upstream repo. In order to ensure that changes to the user's repo aren't propagated with the PR, we branch at the point of PR creation.

func (*Repo) PullRequestFetch

func (r *Repo) PullRequestFetch(number int, pr *github.PullRequest) error

PullRequestFetch fetches the numbered pull request so that it can be merged with the current repo. The pr can be supplied in the second parameter, on the off-chance that you've already fetched it: no point making two GitHub API calls.

func (*Repo) PullRequestList

func (r *Repo) PullRequestList() ([]*github.PullRequest, error)

PullRequestList returns a list of the PullRequests for this repo.

func (*Repo) PullRequestMerge

func (r *Repo) PullRequestMerge(number int) error

PullRequestMerge merges the PR with the given number with the HEAD of the current repo.

func (*Repo) PullUpstream

func (r *Repo) PullUpstream() error

PullUpstream pulls the repos upstream into the repo, merging per git merge rules.

func (*Repo) Push

func (r *Repo) Push(remoteName, branchName string) error

Push implements 'git push remote branch' for the repo. TODO: Check whether my ref string is able to push not just from our master-to-master, but also from master -> x or x -> y

func (*Repo) PushOrigin

func (r *Repo) PushOrigin() error

PushOrigin is a shorthand to push the repo to origin/master.

func (*Repo) RepoOwnerAndName

func (r *Repo) RepoOwnerAndName() (string, string, error)

RepoOwnerAndName returns the repo owner and name for the repo.

func (*Repo) RepoPath

func (r *Repo) RepoPath(path ...string) string

Path returns the path to the filename INSIDE THE GIT REPO constructed from the concatenated elements passed to RepoPath. If you don't provide any elements, the repo dir is returned.

func (*Repo) RepoStateString

func (r *Repo) RepoStateString() (string, error)

func (*Repo) RepoStateStringNoError

func (r *Repo) RepoStateStringNoError() string

func (*Repo) ResetConflictedFilesInWorkingDir

func (r *Repo) ResetConflictedFilesInWorkingDir(chooseOurs, conflictedOnly bool,
	filter func(r *Repo, path string, entry *git2go.StatusEntry) bool) error

ResetConflictedFilesInWorkingDir goes through conflicted files in the working directory and sets them to either our version or their version. The file remains in conflict.

func (*Repo) ResetState

func (r *Repo) ResetState()

ResetState resets a repo's state so that the next call to GetRepoState will recompute the repo's state.

func (*Repo) RevertDiffDelta

func (r *Repo) RevertDiffDelta(rd *DiffDelta) error

RevertDiffDelta reverts the DiffDelta on this repo.

func (*Repo) RevertLocalChanges

func (r *Repo) RevertLocalChanges() error

RevertLocalChanges reverts all local changed files that aren't staged. Using EBM, we should never have local changes that aren't staged, so these files are generated by processes that run on the repo. We don't want to keep them, since they can cause issues with pulling new files.

func (*Repo) RunGit

func (r *Repo) RunGit(args ...string) error

RunGit runs git in the repo directory with the given arguments.

func (*Repo) SearchForFiles

func (r *Repo) SearchForFiles(fn string, filter func(in string) bool) ([]string, error)

SearchForFiles returns a list of all files that match the given regexp. It ignores all files that are ignored in Git, and skips all ignored directories.

func (*Repo) SetUpstreamRemote

func (r *Repo) SetUpstreamRemote() error

SetUpstreamRemote configures the `upstream` remote in the github repo. It discovers the upstream remote by looking for the repo's parent on Github.

func (*Repo) StagedFiles

func (r *Repo) StagedFiles() ([]*IndexFileStatus, error)

StagedFiles returns the list of files staged but not committed in the repository.

func (*Repo) StagedFilesAbbreviated

func (r *Repo) StagedFilesAbbreviated() ([]*IndexFileStatusAbbreviated, error)

StagedFilesAbbreviated returns an easily JSON encoded list of staged files with paths.

func (*Repo) Stash

func (r *Repo) Stash(msg string) (*git2go.Oid, error)

Stash stashes all current working directory files with the given message.

func (*Repo) StatusCount

func (r *Repo) StatusCount() (int, int, error)

StatusCount returns the number of uncommitted items in the index-head and the workingdir-index for the repo.

func (*Repo) StatusList

func (r *Repo) StatusList() (*git2go.StatusList, error)

StatusList returns the list of status entries for the repo. The caller needs to .Free() the returned object.

func (*Repo) StatusListFilenames

func (r *Repo) StatusListFilenames() ([]string, error)

StatusListFilenames returns a slice on only the filenames of the files appearing in the StatusList

func (*Repo) TheirPath

func (r *Repo) TheirPath(path ...string) string

TheirPath returns the path to the `their` version of a file used during Merge resolution.

func (*Repo) TheirTree

func (r *Repo) TheirTree() *FileTree

TheirTree returns a FileTree instance into the merge-conflict temporary `their` tree

func (*Repo) Unstash

func (r *Repo) Unstash() error

Unstash unstashes previously stashed working directory files.

func (*Repo) UpdateFileBinary

func (r *Repo) UpdateFileBinary(path string, raw []byte) error

UpdateFileBinary writes the given file and updates it in git.

func (*Repo) WorkingTree

func (r *Repo) WorkingTree() *FileTree

WorkingTree returns a FileTree instance into the working directory for the repo.

type RepoConflict

type RepoConflict struct {
	Path          string
	Automergeable bool
	Status        git2go.Status
}

RepoConflict provides details on a conflicted file in the repo.

func (*RepoConflict) String

func (rc *RepoConflict) String() string

type RepoDiffStats

type RepoDiffStats struct {
	Ahead  int
	Behind int
}

func CompareCommits

func CompareCommits(client *Client, repoName string, repoOwnerA string,
	repoBranchA string, repoOwnerB string, repoBranchB string) (*RepoDiffStats, error)

type RepoState

type RepoState int

RepoState describes the state of the repo with regard to it's GitHub origin repo, and the parent of that GitHub repo.

func (RepoState) LocalAhead

func (rs RepoState) LocalAhead() bool

func (RepoState) LocalBehind

func (rs RepoState) LocalBehind() bool

func (RepoState) LocalChanges

func (rs RepoState) LocalChanges() bool

func (RepoState) LocalChangesStaged

func (rs RepoState) LocalChangesStaged() bool

func (RepoState) LocalChangesUnstaged

func (rs RepoState) LocalChangesUnstaged() bool

func (RepoState) LocalConflicted

func (rs RepoState) LocalConflicted() bool

func (RepoState) LocalInSync

func (rs RepoState) LocalInSync() bool

func (RepoState) LocalUnimplemented

func (rs RepoState) LocalUnimplemented() bool

func (RepoState) ParentAhead

func (rs RepoState) ParentAhead() bool

func (RepoState) ParentBehind

func (rs RepoState) ParentBehind() bool

func (RepoState) ParentInSync

func (rs RepoState) ParentInSync() bool

func (RepoState) ParentNotExist

func (rs RepoState) ParentNotExist() bool

func (RepoState) String

func (rs RepoState) String() string

type ResolveMergeOption

type ResolveMergeOption int
const (
	ResolveMergeOur ResolveMergeOption = 1 << iota
	ResolveMergeTheir
	ResolveMergeGit
)

type StatusEntry

type StatusEntry struct {
	git2go.StatusEntry
}

func (*StatusEntry) Filename

func (se *StatusEntry) Filename() string

Filename returns the name of the file based on the HEAD-Index status.

func (*StatusEntry) StatusType

func (se *StatusEntry) StatusType() string

StatusType returns a textual type description of the HEAD-Index status of the entry

type StatusList

type StatusList struct {
	*git2go.StatusList
}

func GitStatusList

func GitStatusList(ctxt context.Context, repoDir string) (*StatusList, error)

GitStatusList returns the status list for a particular repo. If the caller provides a Context, the StatusList will be freed when the Context is done. Otherhe caller MUST call .Free on the StatusList when done.

func (*StatusList) Statuses

func (s *StatusList) Statuses() chan *StatusEntry

Jump to

Keyboard shortcuts

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