package com.atlassian.stash.internal.scm.git.command.revlist;

import com.atlassian.bitbucket.commit.AbstractCommitCallback;
import com.atlassian.bitbucket.commit.Commit;

import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * Helper class for testing purposes only.
 */
public class CollectingCommitCallback extends AbstractCommitCallback implements Iterable<Commit> {

    public final List<Commit> commits = new ArrayList<>();

    @Override
    public boolean onCommit(@Nonnull Commit commit) {
        commits.add(commit);

        return true;
    }

    @Override
    public Iterator<Commit> iterator() {
        return commits.iterator();
    }
}
