<commit_before>#
# File: git.py
# Methods for common Git operations
#
# Author:
#    <NAME>
#
# History:
#    * 2013-05-02 - Created
#
import subprocess
import os

###############################################################################
# Section: Public methods
###############################################################################
def getFilesByRevision(revision, returnStatus=False):
	if returnStatus:
		result = []
		response = _splitLines(_doGitCommand("diff-tree", ["--name-status", "-r", revision]))

		for line in response:
			status = line[0]
			fileName = line[1:].strip()

			result.append((status, fileName))

	else:
		result = _splitLines(_doGitCommand("diff-tree", ["--name-only", "-r", revision]))

	return result

def getRevisionsAfterDate(date, reverse=False):
	result = []
	args = ["--after=%s" % (date,), "--pretty=format:%H", "--name-status"]

	if reverse:
		args.append("--reverse")
		
	response = _doGitCommand("log", args).split("\n\n")
	
	for block in response:
		lines = block.strip().split("\n")

		if len(lines) > 1:
			item = {
				"revision": lines[0].strip(),
				"files": []
			}

			for i in range(len(lines) - 1):
				line = lines[i + 1]<commit_msg>Added function to get head revision hash number.<commit_after>#
# File: git.py
# Methods for common Git operations
#
# Author:
#    <NAME>
#
# History:
#    * 2013-05-02 - Created
#
import subprocess
import os

###############################################################################
# Section: Public methods
###############################################################################
def getFilesByRevision(revision, returnStatus=False):
	if returnStatus:
		result = []
		response = _splitLines(_doGitCommand("diff-tree", ["--name-status", "-r", revision]))

		for line in response:
			status = line[0]
			fileName = line[1:].strip()

			result.append((status, fileName))

	else:
		result = _splitLines(_doGitCommand("diff-tree", ["--name-only", "-r", revision]))

	return result

def getHeadCommitRevisionHash():
	args = ["-1", "--format=\"%H\""]
	result = _doGitCommand("log", args).strip()

	return result

def getRevisionsAfterDate(date, reverse=False):
	result = []
	args = ["--after=%s" % (date,), "--pretty=format:%H", "--name-status"]

	if reverse:
		args.append("--reverse")
		
	response = _doGitCommand("log", args).split("\n\n")
	
	for block in response:
		lines = block.strip().split("\n")

		if len(lines) > 1:
			item = {
				"revision": lines[0].strip(),
				"files": []
			}

			for i in range(len(lines) - 1):
				line = lines[i + 1]
{'fraction_non_alphanumeric': 0.2849336455893833, 'fraction_numerical': 0.01131928181108509, 'mean_word_length': 4.339583333333334, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 7, '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': '2685662', 'n_tokens_mistral': 897, 'n_tokens_neox': 782, 'n_words': 186}