Refactor create_commit and get_commit methods