<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -------------------------------------------------------------------------------
# Gitline
# by <NAME>
#
# Credits
# * git-radar (https://github.com/michaeldfallen/git-radar)
# * gitHUD (https://github.com/gbataille/gitHUD)
#
# MIT License
# -------------------------------------------------------------------------------

from argparse import ArgumentParser
from string import Template
from subprocess import Popen, PIPE
from threading import Thread

import os

# Constants {{{

bash_fish_colors = {'gray': '\033[30m', 'red': '\033[31m', 'green': '\033[32m', 'yellow': '\033[33m',
                    'blue': '\033[34m', 'magenta': '\033[35m', 'cyan': '\033[36m', 'white': '\033[37m',
                    'reset': '\033[0m'}

zsh_colors = {'gray': '%F{gray}', 'red': '%F{red}', 'green': '%F{green}', 'yellow': '%F{yellow}', 'blue': '%F{blue}',
              'magenta': '%F{magenta}', 'cyan': '%F{cyan}', 'white': '%F{white}', 'reset': '%f'}


# }}}

# Utility functions {{{

def execute(cmd):
    with open(os.devnull) as DEVNULL:
        return Popen(cmd, stdout=PIPE, stderr=DEVNULL, universal_newlines=True).communicate()[0].rstrip()


def read_file(path):
    try:
        with open(path, 'r') as f:
            return f.read().rstrip()
    except IOError:
        return ''


def parse_int(s):
    try:
        return int(s)
    except ValueError:
        return 0


def parallel(tasks):
    threads = [Thread(target=task) for task in tasks]
    for thread in threads:
        thread.start()
    for thread in threads:
        thread.join()


def extract_branch_name(spec, replacement):
    return spec.replace('refs/heads/', replacement)


# }}}

# Repository parsing {{{

class Repository:
    def __init__(self):
        self.directory = ''
        self.git_directory = ''
        self.branch = ''
        self.remote = ''
        self.remote_tracking_branch = ''
        self.commit_hash = ''
        self.commit_tag = ''<commit_msg>Fix remote branch name calculation<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -------------------------------------------------------------------------------
# Gitline
# by <NAME>
#
# Credits
# * git-radar (https://github.com/michaeldfallen/git-radar)
# * gitHUD (https://github.com/gbataille/gitHUD)
#
# MIT License
# -------------------------------------------------------------------------------

from argparse import ArgumentParser
from string import Template
from subprocess import Popen, PIPE
from threading import Thread

import os

# Constants {{{

bash_fish_colors = {'gray': '\033[30m', 'red': '\033[31m', 'green': '\033[32m', 'yellow': '\033[33m',
                    'blue': '\033[34m', 'magenta': '\033[35m', 'cyan': '\033[36m', 'white': '\033[37m',
                    'reset': '\033[0m'}

zsh_colors = {'gray': '%F{gray}', 'red': '%F{red}', 'green': '%F{green}', 'yellow': '%F{yellow}', 'blue': '%F{blue}',
              'magenta': '%F{magenta}', 'cyan': '%F{cyan}', 'white': '%F{white}', 'reset': '%f'}


# }}}

# Utility functions {{{

def execute(cmd):
    with open(os.devnull) as DEVNULL:
        return Popen(cmd, stdout=PIPE, stderr=DEVNULL, universal_newlines=True).communicate()[0].rstrip()


def read_file(path):
    try:
        with open(path, 'r') as f:
            return f.read().rstrip()
    except IOError:
        return ''


def parse_int(s):
    try:
        return int(s)
    except ValueError:
        return 0


def parallel(tasks):
    threads = [Thread(target=task) for task in tasks]
    for thread in threads:
        thread.start()
    for thread in threads:
        thread.join()


def extract_branch_name(spec, replacement):
    spec = spec.replace('refs/heads/', '')
    return replacement + '/' + spec if replacement else spec


# }}}

# Repository parsing {{{

class Repository:
    def __init__(self):
        self.directory = ''
        self.git_directory = ''
        self.branch = ''
        self.remote = ''
        self.remote_tracking_branch = ''
        self.commit_hash = ''
        self.commit_tag = ''
{'fraction_non_alphanumeric': 0.24344844477100172, 'fraction_numerical': 0.02302228753367622, 'mean_word_length': 2.1831644583008574, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, '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': '1936819', 'n_tokens_mistral': 1352, 'n_tokens_neox': 1283, 'n_words': 298}