Exemplo n.º 1
0
// @return result.Result<bool, error>
func IndexComments(repoPath string) result.Result {
	return openIndex(repoPath, func(repo *git.Repository, index bleve.Index) result.Result {
		results := make([]result.Result, 0)
		batch := index.NewBatch()
		return gg.CommentRefIterator(repo, func(ref *git.Reference) {
			gc.CommentFromRef(repo, ref.Name()).FlatMap(func(c interface{}) result.Result {
				comment := c.(*gc.Comment)
				err := batch.Index(*comment.ID, commentIndex(comment))
				results = append(results, gg.BoolResult(true, err))
				return result.NewSuccess(true)
			})
		}).FlatMap(func(value interface{}) result.Result {
			return result.Combine(func(values ...interface{}) result.Result {
				return gg.BoolResult(true, index.Batch(batch))
			}, results...)
		})
	})
}
Exemplo n.º 2
0
// @return result.Result<bool, error>
func IndexComment(repoPath string, comment *gc.Comment) result.Result {
	return openIndex(repoPath, func(repo *git.Repository, index bleve.Index) result.Result {
		return gg.BoolResult(true, index.Index(*comment.ID, commentIndex(comment)))
	})
}