Пример #1
0
// Add a fetch refspec to a remote. Return true if added.
// @return result.Result<bool, error>
func AddFetch(repo *git.Repository, remote *git.Remote, fetchRef string) result.Result {
	f := result.NewResult(remote.FetchRefspecs())
	return f.FlatMap(func(fetches interface{}) result.Result {
		if !contains(fetches.([]string), fetchRef) {
			return BoolResult(true, repo.Remotes.AddFetch(remote.Name(), fetchRef))
		}
		return result.NewSuccess(false)
	})
}
Пример #2
0
// Add a push refspec to a remote. Return true if added.
// @return result.Result<bool, error>
func AddPush(repo *git.Repository, remote *git.Remote, pushRef string) result.Result {
	p := result.NewResult(remote.PushRefspecs())
	return p.FlatMap(func(pushes interface{}) result.Result {
		if !contains(pushes.([]string), pushRef) {
			return BoolResult(true, repo.Remotes.AddPush(remote.Name(), pushRef))
		}
		return result.NewSuccess(false)
	})
}
Пример #3
0
func (p *Project) fetch(remote *git.Remote, refspecs ...string) (err error) {
	opts := &git.FetchOptions{
		RemoteCallbacks: remoteCallbacks,
	}

	// fetch with default reflog message
	err = remote.Fetch(refspecs, opts, "")
	if err != nil {
		return fmt.Errorf("Failed to fetch: %v", err)
	}
	return
}