def get_commits(self, repo, organization='<STR_LIT>'):
<EOL>path = ('<STR_LIT>' + organization + '<STR_LIT:/>' + repo.name + '<STR_LIT>')<EOL>is_only_today = False<EOL>if not os.path.exists(path): <EOL><INDENT>all_commits = repo.iter_commits()<EOL>is_only_today = True<EOL><DEDENT>else:<EOL><INDENT>files = os.listdir(path)<EOL>date = str(files[-<NUM_LIT:1>][:-<NUM_LIT:5>])<EOL>if date == str(datetime.date.today()):<EOL><INDENT>if len(files) > <NUM_LIT:2>:<EOL><INDENT>date = str(files[-<NUM_LIT:2>][:-<NUM_LIT:5>])<EOL><DEDENT>else:<EOL><INDENT>all_commits = repo.iter_commits()<EOL>is_only_today = True<EOL><DEDENT><DEDENT>if not is_only_today:<EOL><INDENT>all_commits = repo.iter_commits(since=date)<EOL><DEDENT><DEDENT>for commit in all_commits:<EOL><INDENT>self.commits_json[repo.name].append(commit.to_json())<EOL><DEDENT>count = <NUM_LIT:0><EOL>for commit in repo.iter_commits():<EOL><INDENT>count += <NUM_LIT:1><EOL><DEDENT>return count<EOL>
Retrieves the number of commits to a repo in the organization. If it is
the first time getting commits for a repo, it will get all commits and
save them to JSON. If there are previous commits saved, it will only get
commits that have not been saved to disk since the last date of commits.