scripts/github_stats.py
def get_commits(self, repo, organization='llnl'):
        """
        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.
        """
        #JSON
        path = ('../github-data/' + organization + '/' + repo.name + '/commits')
        is_only_today = False
        if not os.path.exists(path): #no previous path, get all commits
            all_commits = repo.iter_commits()
            is_only_today = True
        else:
            files = os.listdir(path)
            date = str(files[-1][:-5])
            if date == str(datetime.date.today()):
                #most recent date is actually today, get previous most recent date
                if len(files) > 2:
                    date = str(files[-2][:-5])
                else:
                    #This means there is only one file, today. Retrieve every commit
                    all_commits = repo.iter_commits()
                    is_only_today = True
            if not is_only_today:#there's a previous saved JSON that's not today
                all_commits = repo.iter_commits(since=date)
        for commit in all_commits:
            self.commits_json[repo.name].append(commit.to_json())
        #for csv
        count = 0
        for commit in repo.iter_commits():
            count += 1
        return count
def get_commits(self, repo, organization='llnl'):
        #JSON
        path = ('../github-data/' + organization + '/' + repo.name + '/commits')
        is_only_today = False
        if not os.path.exists(path): #no previous path, get all commits
            all_commits = repo.iter_commits()
            is_only_today = True
        else:
            files = os.listdir(path)
            date = str(files[-1][:-5])
            if date == str(datetime.date.today()):
                #most recent date is actually today, get previous most recent date
                if len(files) > 2:
                    date = str(files[-2][:-5])
                else:
                    #This means there is only one file, today. Retrieve every commit
                    all_commits = repo.iter_commits()
                    is_only_today = True
            if not is_only_today:#there's a previous saved JSON that's not today
                all_commits = repo.iter_commits(since=date)
        for commit in all_commits:
            self.commits_json[repo.name].append(commit.to_json())
        #for csv
        count = 0
        for commit in repo.iter_commits():
            count += 1
        return count
def get_commits ( self , repo , organization = 'llnl' ) : #JSON path = ( '../github-data/' + organization + '/' + repo . name + '/commits' ) is_only_today = False if not os . path . exists ( path ) : #no previous path, get all commits all_commits = repo . iter_commits ( ) is_only_today = True else : files = os . listdir ( path ) date = str ( files [ - 1 ] [ : - 5 ] ) if date == str ( datetime . date . today ( ) ) : #most recent date is actually today, get previous most recent date if len ( files ) > 2 : date = str ( files [ - 2 ] [ : - 5 ] ) else : #This means there is only one file, today. Retrieve every commit all_commits = repo . iter_commits ( ) is_only_today = True if not is_only_today : #there's a previous saved JSON that's not today all_commits = repo . iter_commits ( since = date ) for commit in all_commits : self . commits_json [ repo . name ] . append ( commit . to_json ( ) ) #for csv count = 0 for commit in repo . iter_commits ( ) : count += 1 return count
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.
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 .