<commit_before>import sys
import os
import commands
import fnmatch
import re
import subprocess, shlex

mcp_home = sys.argv[1]
mcp_dir = os.path.abspath(mcp_home)

print(mcp_dir)
sys.path.append(mcp_dir)

from runtime.commands import Commands
Commands._version_config = os.path.join(mcp_dir,Commands._version_config)

def cmdsplit(args):
    if os.sep == '\\':
        args = args.replace('\\', '\\\\')
    return shlex.split(args)
                    
def cleanDirs(path):
    if not os.path.isdir(path):
        return
 
    files = os.listdir(path)
    if len(files):
        for f in files:
            fullpath = os.path.join(path, f)
            if os.path.isdir(fullpath):
                cleanDirs(fullpath)
 
    files = os.listdir(path)
    if len(files) == 0:
        os.rmdir(path)
        
def main():
    print("Obtaining version information from git")
    cmd = "git describe --long --match='[^(jenkins)]*'"
    try:
      process = subprocess.Popen(cmdsplit(cmd), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1)
      vers, _ = process.communicate()
    except OSError:
      print("Git not found")
      vers="v1.0-0-deadbeef"
    (major,minor,rev,githash)=re.match("v(\d+).(\d+)-(\d+)-(.*)",vers).groups()

    (mcpversion,mcclientversion,mcserverversion) = re.match("[.\w]+ \(data: ([.\w]+), client: ([.\w.]+), server: ([.\w.]+)\)",Commands.fullversion()).groups()
    
    if os.getenv("GIT_BRANCH") is None:
      cmd = "git rev-parse --abbrev-ref HEAD"
      try:
        process = subprocess.Popen(cmdsplit(cmd), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1)
        branch, _ = process.communicate()
      except OSError:
        print("Git not found")
        branch="none"
    else:
      branch=os.getenv("GIT_BRANCH")

    with open("fmlversion.properties","w") as f:
      f.write("%s=%s\n" %("fmlbuild.major.number",major))
      f.write("%s=%s\n" %("fmlbuild.minor.number",minor))
      f.write("%s=%s\n" %("fmlbuild.revision.number",rev))
      f.write("%s=%s\n" %("fmlbuild.githash",githash))
      f.write("%s=%s\n" %("fmlbuild.mcpversion",mcpversion))
      f.write("%s=%s\n" %("fmlbuild.mcversion",mcclientversion))
      f.write("%s=%s\n" %("fmlbuild.branch",branch))

    print("Version information: FML %s.%s.%s (%s) using MCP %s for minecraft %s" % (major, minor, rev, branch, mcpversion, mcclientversion))
    
if __name__ == '__main__':
    main()<commit_msg>Last part of branch name only please<commit_after>import sys
import os
import commands
import fnmatch
import re
import subprocess, shlex

mcp_home = sys.argv[1]
mcp_dir = os.path.abspath(mcp_home)

print(mcp_dir)
sys.path.append(mcp_dir)

from runtime.commands import Commands
Commands._version_config = os.path.join(mcp_dir,Commands._version_config)

def cmdsplit(args):
    if os.sep == '\\':
        args = args.replace('\\', '\\\\')
    return shlex.split(args)
                    
def cleanDirs(path):
    if not os.path.isdir(path):
        return
 
    files = os.listdir(path)
    if len(files):
        for f in files:
            fullpath = os.path.join(path, f)
            if os.path.isdir(fullpath):
                cleanDirs(fullpath)
 
    files = os.listdir(path)
    if len(files) == 0:
        os.rmdir(path)
        
def main():
    print("Obtaining version information from git")
    cmd = "git describe --long --match='[^(jenkins)]*'"
    try:
      process = subprocess.Popen(cmdsplit(cmd), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1)
      vers, _ = process.communicate()
    except OSError:
      print("Git not found")
      vers="v1.0-0-deadbeef"
    (major,minor,rev,githash)=re.match("v(\d+).(\d+)-(\d+)-(.*)",vers).groups()

    (mcpversion,mcclientversion,mcserverversion) = re.match("[.\w]+ \(data: ([.\w]+), client: ([.\w.]+), server: ([.\w.]+)\)",Commands.fullversion()).groups()
    
    if os.getenv("GIT_BRANCH") is None:
      cmd = "git rev-parse --abbrev-ref HEAD"
      try:
        process = subprocess.Popen(cmdsplit(cmd), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=-1)
        branch, _ = process.communicate()
      except OSError:
        print("Git not found")
        branch="none"
    else:
      branch=os.getenv("GIT_BRANCH").rpartition('/')[2]

    with open("fmlversion.properties","w") as f:
      f.write("%s=%s\n" %("fmlbuild.major.number",major))
      f.write("%s=%s\n" %("fmlbuild.minor.number",minor))
      f.write("%s=%s\n" %("fmlbuild.revision.number",rev))
      f.write("%s=%s\n" %("fmlbuild.githash",githash))
      f.write("%s=%s\n" %("fmlbuild.mcpversion",mcpversion))
      f.write("%s=%s\n" %("fmlbuild.mcversion",mcclientversion))
      f.write("%s=%s\n" %("fmlbuild.branch",branch))

    print("Version information: FML %s.%s.%s (%s) using MCP %s for minecraft %s" % (major, minor, rev, branch, mcpversion, mcclientversion))
    
if __name__ == '__main__':
    main()
{'fraction_non_alphanumeric': 0.18278253773969808, 'fraction_numerical': 0.0030599755201958386, 'mean_word_length': 3.055417700578991, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7005775', 'n_tokens_mistral': 1812, 'n_tokens_neox': 1765, 'n_words': 321}