6
0
mirror of https://github.com/grdl/git-get.git synced 2026-02-05 16:33:48 +00:00

Add ahead/behind detection, clean up tests

This commit is contained in:
Grzegorz Dlugoszewski
2020-05-28 16:21:07 +02:00
parent 0b371341e7
commit ca9be3d98f
5 changed files with 375 additions and 214 deletions

View File

@@ -53,11 +53,24 @@ func OpenRepo(path string) (r *Repo, err error) {
func newRepo(repo *git.Repository) *Repo {
return &Repo{
repo: repo,
Status: &RepoStatus{
HasUntrackedFiles: false,
HasUncommittedChanges: false,
Branches: make(map[string]*BranchStatus),
},
repo: repo,
Status: &RepoStatus{},
}
}
// Fetch performs a git fetch on all remotes
func (r *Repo) Fetch() error {
remotes, err := r.repo.Remotes()
if err != nil {
return errors.Wrap(err, "Failed getting remotes")
}
for _, remote := range remotes {
err = remote.Fetch(&git.FetchOptions{})
if err != nil {
return errors.Wrapf(err, "Failed fetching remote %s", remote.Config().Name)
}
}
return nil
}