def parse_commits(self):
    import Commit
    events = []
    
    # if this is a cloned repository
    if not self.from_feed:
      repo_dir = os.path.join(settings.REPO_ROOT, self.project.url_path)
      
      # add the commits
      backend = get_backend(self.vcs if self.vcs != 'svn' else 'git')
      repository = backend.Repository(repo_dir)

      # inspect the last five days of commits
      for commit in repository.get_recent_commits(self.most_recent_date):
        date = commit.time
        try:
          date = (date - date.utcoffset()).replace(tzinfo=None)
        except:
          pass
          
        # process the diff of this commit
        try:
          diff, added, removed, changed = format_diff(commit.diff)
        except KeyError:
          diff, added, removed, changed = "", "Unknown", "Unknown", "Unknown"
        
        # extract the title of the commit
        try:
          commit_title = re.findall(r"^.*\.\s", commit.message)[0].strip()
        except __HOLE__:
          commit_title = commit.message.split("\n")[0]
        
        # format the commit message
        commit.message = re.sub(r"<p>\s+</p>", "",
          markdown(commit.message.replace(commit_title, "").decode('utf-8'), safe_mode = True))
        
        append_unsanitized = ("<div class=\"light-bar\">{0} file{1} changed," +
          " {2} line{3} added, {4} line{5} removed</div>").format(
            changed, 's' if changed != 1 else '',
            added, 's' if added != 1 else '',
            removed, 's' if removed != 1 else ''
        )
        
        events.append(self.add_event(Commit.Commit,
          title = commit_title,
          summary = commit.message,
          date = date,
          author_name = commit.author,
          from_feed = False,
          append_unsanitized = append_unsanitized,
          extra_args = {
            "diff": diff,
            "repository_id": self.id,
          }))
    
    # this is a feed-driven repository
    else:
      for commit in feedparser.parse(self.repo_rss).entries:
        date = dateutil.parser.parse(commit.date)
        try:
          date = (date - date.utcoffset()).replace(tzinfo=None)
        except:
          pass
        
        events.append(self.add_event(Commit.Commit, 
          title = commit.title, 
          summary = commit.description,
          date = date,
          author_name = commit.author_detail['name'],
          from_feed = True, 
          extra_args = { "repository_id": self.id }
        ))
    
    # find the new most recent date
    dates = [event.date for event in events if event is not None]
    dates.append(self.most_recent_date)
    self.most_recent_date = max(dates)
    self.save()
dataset/ETHPy150Open rcos/Observatory/observatory/dashboard/models/Repository.py/Repository.parse_commits