lib/ghtorrent/ghtorrent.rb
def ensure_repo_commit(user, repo, sha)
      project = ensure_repo(user, repo)

      if project.nil?
        warn "Repo #{user}/#{repo} does not exist"
        return
      end

      commitid = db[:commits].first(:sha => sha)[:id]

      exists = db[:project_commits].first(:project_id => project[:id],
                                           :commit_id => commitid)
      if exists.nil?
        db[:project_commits].insert(
            :project_id => project[:id],
            :commit_id => commitid
        )
        info "Added commit_assoc #{sha} with #{user}/#{repo}"
        db[:project_commits].first(:project_id => project[:id],
                                    :commit_id => commitid)
      else
        debug "Association of commit #{sha} with repo #{user}/#{repo} exists"
        exists
      end
    end
def ensure_repo_commit(user, repo, sha)
      project = ensure_repo(user, repo)

      if project.nil?
        warn "Repo #{user}/#{repo} does not exist"
        return
      end

      commitid = db[:commits].first(:sha => sha)[:id]

      exists = db[:project_commits].first(:project_id => project[:id],
                                           :commit_id => commitid)
      if exists.nil?
        db[:project_commits].insert(
            :project_id => project[:id],
            :commit_id => commitid
        )
        info "Added commit_assoc #{sha} with #{user}/#{repo}"
        db[:project_commits].first(:project_id => project[:id],
                                    :commit_id => commitid)
      else
        debug "Association of commit #{sha} with repo #{user}/#{repo} exists"
        exists
      end
    end
Make sure that a commit has been associated with the provided repo
 ==Parameters:
  [user] The user that owns the repo this commit has been submitted to
  [repo] The repo receiving the commit
  [sha] The commit SHA