<commit_before>package controllers;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;

import models.Project;

import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.NoHeadException;
import org.tmatesoft.svn.core.SVNException;

import play.mvc.Controller;
import play.mvc.Result;
import playRepository.Commit;
import playRepository.RepositoryService;
import utils.RequestUtil;
import views.html.code.history;
import views.html.code.diff;

public class CodeHistoryApp extends Controller {

    private static final int HISTORY_ITEM_LIMIT = 25;

    public static Result history(String userName, String projectName) throws IOException,
            UnsupportedOperationException, ServletException, NoHeadException, GitAPIException,
            SVNException {
        Project project = Project.findByName(projectName);
        String url = CodeApp.getURL(userName, projectName);
        String pageStr = RequestUtil.getFirstValueFromQuery(request().queryString(), "page");
        int page = 0;
        if (pageStr != null) {
            page = Integer.parseInt(pageStr);
        }

        List<Commit> commits = RepositoryService.getRepository(project).getHistory(page,
                HISTORY_ITEM_LIMIT);

        return ok(history.render(url, project, commits, page));
    }

    public static Result show(String userName, String projectName, String commitId)
            throws IOException, UnsupportedOperationException, ServletException, GitAPIException,
            SVNException {
        Project project = Project.findByName(projectName);
        String patch = RepositoryService.getRepository(project).getPatch(commitId);

        return ok(diff.render(project, patch));
    }<commit_msg>code: Add the error handling for NoHeadException.<commit_after>package controllers;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;

import models.Project;

import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.NoHeadException;
import org.tmatesoft.svn.core.SVNException;

import play.mvc.Controller;
import play.mvc.Result;
import playRepository.Commit;
import playRepository.RepositoryService;
import utils.RequestUtil;
import views.html.code.history;
import views.html.code.nohead;
import views.html.code.diff;

public class CodeHistoryApp extends Controller {

    private static final int HISTORY_ITEM_LIMIT = 25;

    public static Result history(String userName, String projectName) throws IOException,
            UnsupportedOperationException, ServletException, GitAPIException,
            SVNException {
        Project project = Project.findByName(projectName);
        String url = CodeApp.getURL(userName, projectName);
        String pageStr = RequestUtil.getFirstValueFromQuery(request().queryString(), "page");
        int page = 0;
        if (pageStr != null) {
            page = Integer.parseInt(pageStr);
        }

        try {
            List<Commit> commits = RepositoryService.getRepository(project).getHistory(page,
                    HISTORY_ITEM_LIMIT);
            return ok(history.render(url, project, commits, page));
        } catch (NoHeadException e) {
            return ok(nohead.render(url, project));
        }
    }

    public static Result show(String userName, String projectName, String commitId)
            throws IOException, UnsupportedOperationException, ServletException, GitAPIException,
            SVNException {
        Project project = Project.findByName(projectName);
        String patch = RepositoryService.getRepository(project).getPatch(commitId);

        return ok(diff.render(project, patch));
    }
{'fraction_non_alphanumeric': 0.08672232695933207, 'fraction_numerical': 0.0016159439806086723, 'mean_word_length': 3.636704119850187, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2869088', 'n_tokens_mistral': 986, 'n_tokens_neox': 975, 'n_words': 228}