Refactor getCommits.