// 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) }) }
// 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) }) }