<commit_before>class BrowseController < ApplicationController
  before_filter :find_project_and_repository
  before_filter :check_for_commits
  
  def index
    @git = Git.bare(@repository.full_repository_path)
    @commits = @git.log(30)
    @tags_per_sha = returning({}) do |hash|
      @git.tags.each do |tag| 
        hash[tag.sha] ||= []
        hash[tag.sha] << tag.name 
      end
    end
    # TODO: Patch rails to keep track of what it responds to so we can DRY this up
    @atom_auto_discovery = true
    respond_to do |format|
      format.html
      format.atom
    end
  end
  
  def tree
    @git = Git.bare(@repository.full_repository_path)   
    @tree = @git.gtree(params[:sha])
  end
  
  def commit
    @git = Git.bare(@repository.full_repository_path)
    @commit = @git.gcommit(params[:sha])
    @diff = @git.diff(@commit.parent.sha, @commit.sha)
    @comment_count = @repository.comments.count(:all, :conditions => {:sha1 => @commit.sha})
  end
  
  def diff
    @git = Git.bare(@repository.full_repository_path)
    @diff = @git.diff(params[:sha], params[:other_sha])
  end
  
  def blob
    @git = Git.bare(@repository.full_repository_path)
    @blob = @git.gblob(params[:sha])
  end
  
  def raw
    @git = Git.bare(@repository.full_repository_path)
    @blob = @git.gblob(params[:sha])
    render :text => @blob.contents, :content_type => "text/plain"
  end
  
  def log
    @git = Git.bare(@repository.full_repository_path)
    # TODO: paginated logs
  end
  
  def archive<commit_msg>Workaround for initial-commit diffs<commit_after>class BrowseController < ApplicationController
  before_filter :find_project_and_repository
  before_filter :check_for_commits
  
  def index
    @git = Git.bare(@repository.full_repository_path)
    @commits = @git.log(30)
    @tags_per_sha = returning({}) do |hash|
      @git.tags.each do |tag| 
        hash[tag.sha] ||= []
        hash[tag.sha] << tag.name 
      end
    end
    # TODO: Patch rails to keep track of what it responds to so we can DRY this up
    @atom_auto_discovery = true
    respond_to do |format|
      format.html
      format.atom
    end
  end
  
  def tree
    @git = Git.bare(@repository.full_repository_path)   
    @tree = @git.gtree(params[:sha])
  end
  
  def commit
    @git = Git.bare(@repository.full_repository_path)
    @commit = @git.gcommit(params[:sha])
    if @commit.parent
      @diff = @git.diff(@commit.parent.sha || "", @commit.sha)
    else
      # initial commit
      @diff = @commit.diff("") # fIXME: diffs are the wrong way
    end
    @comment_count = @repository.comments.count(:all, :conditions => {:sha1 => @commit.sha})
  end
  
  def diff
    @git = Git.bare(@repository.full_repository_path)
    @diff = @git.diff(params[:sha], params[:other_sha])
  end
  
  def blob
    @git = Git.bare(@repository.full_repository_path)
    @blob = @git.gblob(params[:sha])
  end
  
  def raw
    @git = Git.bare(@repository.full_repository_path)
    @blob = @git.gblob(params[:sha])
    render :text => @blob.contents, :content_type => "text/plain"
  end
  
  def log
    @git = Git.bare(@repository.full_repository_path)
    # TODO: paginated logs
  end
  
  def archive
{'fraction_non_alphanumeric': 0.12515723270440252, 'fraction_numerical': 0.0018867924528301887, 'mean_word_length': 3.0470737913486006, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7132523', 'n_tokens_mistral': 1101, 'n_tokens_neox': 1070, 'n_words': 236}