<commit_before>package com.redpois0n.git;

import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;

import com.redpois0n.git.Change.Type;
import com.redpois0n.gitj.ui.graph.GitGraph;
import com.redpois0n.gitj.ui.graph.GraphEntry;
import com.redpois0n.oslib.OperatingSystem;

public class Repository {

	private File folder;
	private List<Commit> commits;
	private List<Tag> tags;
	private GitGraph graph;

	public Repository(File folder) throws InvalidRepositoryException {
		this(folder, true);
	}
	
	private Repository(File folder, boolean check) throws InvalidRepositoryException {
		this.folder = folder;
		
		if (check && !isValidRepo()) {
			throw new InvalidRepositoryException();
		}
	}

	/**
	 * Returns all commits from this repository
	 * 
	 * @return Commits from cache
	 * @throws Exception
	 */
	public List<Commit> getCommits() throws Exception {
		return getCommits(false);
	}

	/**
	 * Returns all commits from this repository
	 * 
	 * @param update
	 *            If git log should be executed and read
	 * @return Commits either freshly loaded or from cache
	 * @throws Exception
	 */
	public List<Commit> getCommits(boolean update) throws Exception {
		if (!update && commits != null) {
			return commits;
		} else {
			if (commits == null) {
				commits = new ArrayList<Commit>();
			} else {
				commits.clear();
			}

			graph = new GitGraph();
			List<Tag> tags = getTags();
			List<String> raw = run("git", "log", "--pretty=format:Commit;%H;%an;%ae;%ar;%s", "--graph");
			Enumeration<String> e = Collections.enumeration(raw);
			
			GraphEntry entry = null;
			<commit_msg>Show all commits or from one branch<commit_after>package com.redpois0n.git;

import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;

import com.redpois0n.git.Change.Type;
import com.redpois0n.gitj.ui.graph.GitGraph;
import com.redpois0n.gitj.ui.graph.GraphEntry;
import com.redpois0n.oslib.OperatingSystem;

public class Repository {

	private File folder;
	private List<Commit> commits;
	private List<Tag> tags;
	private GitGraph graph;

	public Repository(File folder) throws InvalidRepositoryException {
		this(folder, true);
	}
	
	private Repository(File folder, boolean check) throws InvalidRepositoryException {
		this.folder = folder;
		
		if (check && !isValidRepo()) {
			throw new InvalidRepositoryException();
		}
	}

	/**
	 * Returns all commits from this repository
	 * 
	 * @return Commits from cache
	 * @throws Exception
	 */
	public List<Commit> getCommits() throws Exception {
		return getCommits(false);
	}
	
	public List<Commit> getCommits(boolean update) throws Exception {
		return getCommits(update, true, null);
	}

	/**
	 * Returns all commits from this repository
	 * 
	 * @param update If git log should be executed and read
	 * @param all Show all commits
	 * @param branch What branch to show commits from, can be null if all is true
	 * @return Commits either freshly loaded or from cache
	 * @throws Exception
	 */
	public List<Commit> getCommits(boolean update, boolean all, String branch) throws Exception {
		if (!update && commits != null) {
			return commits;
		} else {
			if (commits == null) {
				commits = new ArrayList<Commit>();
			} else {
				commits.clear();
			}

			graph = new GitGraph();
			List<Tag> tags = getTags();
			List<String> raw = run("git", "log", "--pretty=format:Commit;%H;%an;%ae;%ar;%s", "--graph", all ? "--all" : "", !all ? branch : "");
			Enumeration<String> e = Collections.enumeration(raw);
			
			GraphEntry entry = null;
			
{'fraction_non_alphanumeric': 0.11543225167203369, 'fraction_numerical': 0.0024770869457517958, 'mean_word_length': 4.104930467762326, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, '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': '1441978', 'n_tokens_mistral': 1360, 'n_tokens_neox': 1227, 'n_words': 350}