Skip to content

Commit

Permalink
Merge pull request #63 from MFreidank/master
Browse files Browse the repository at this point in the history
Missing branch: fall back to default branch
  • Loading branch information
erikbern committed Jul 18, 2018
2 parents 164c54b + e457998 commit ed24f0a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions git_of_theseus/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from __future__ import print_function
import argparse, git, datetime, numpy, pygments.lexers, traceback, time, os, fnmatch, json, progressbar, sys
import warnings

# Some filetypes in Pygments are not necessarily computer code, but configuration/documentation. Let's not include those.
IGNORE_PYGMENTS_FILETYPES = ['*.json', '*.md', '*.ps', '*.eps', '*.txt', '*.xml', '*.xsl', '*.rss', '*.xslt', '*.xsd', '*.wsdl', '*.wsf', '*.yaml', '*.yml']
Expand All @@ -42,6 +43,14 @@ def analyze(repo, cohortfm='%Y', interval=7*24*60*60, ignore=[], only=[], outdir
if not os.path.exists(outdir):
os.makedirs(outdir)

try:
repo.git.checkout(branch)
except repo.exc.GitCommandError:
default_branch = repo.active_branch.name
warnings.warn("Requested branch: '{}' does not exist. Falling back to default branch: '{}'".format(branch, default_branch))

branch = default_branch

print('Listing all commits')
with progressbar.ProgressBar(max_value=progressbar.UnknownLength, widget_kwargs=widget_kwargs) as bar:
for i, commit in enumerate(repo.iter_commits(branch)):
Expand Down

0 comments on commit ed24f0a

Please sign in to comment.