Ejemplo n.º 1
0
func validatedCommitForComment(repo *git.Repository, commit string) result.Result {
	return gg.ResolveSingleCommitHash(repo, commit).FlatMap(func(hash interface{}) result.Result {
		return CommentCountOnCommit(repo, *(hash.(*string))).FlatMap(func(count interface{}) result.Result {
			if count.(uint16) >= maxCommentsOnCommit {
				return result.NewFailure(errors.New(maxCommentError))
			}
			return result.NewSuccess(hash)
		})
	})
}
Ejemplo n.º 2
0
// Finds all comments on a given commit
// @return result.Result<[]*Comment, error>
func CommentsOnCommit(repoPath string, commitHash string) result.Result {
	return gg.WithRepository(repoPath, func(repo *git.Repository) result.Result {
		hash := gg.ResolveSingleCommitHash(repo, commitHash)
		return hash.FlatMap(func(commit interface{}) result.Result {
			return gg.LookupCommit(repo, *(commit.(*string)))
		}).FlatMap(func(commit interface{}) result.Result {
			return commentsOnCommit(repo, commit.(*git.Commit))
		})
	})
}