def get_origin_or_auth():
     git_url = git.config("--get", "remote.origin.url").strip()
     if git_url[0:19] == "https://github.com/" and GlobalVars.github_username and GlobalVars.github_password:
         preformat_url = ('https://{}:{}@github.com/' + git_url[19:])
         return preformat_url.format(quote(GlobalVars.github_username), quote(GlobalVars.github_password))
     else:
         return "origin"
import threading
# noinspection PyCompatibility
import regex
import subprocess as sp
import platform
if 'windows' in platform.platform().lower():
    # noinspection PyPep8Naming
    from _Git_Windows import git, GitError
else:
    # noinspection PyUnresolvedReferences
    from sh.contrib import git


CommitInfo = namedtuple('CommitInfo', ['id', 'id_full', 'author', 'message'])

git_url = git.config("--get", "remote.origin.url").strip()
git_url_split = git_url.split("/")
git_user_repo = "Charcoal-SE/SmokeDetector"
if git_url[0:19] == "https://github.com/":
    git_user_repo = "{}/{}".format(git_url_split[3], git_url_split[4][0:-4])


def git_commit_info():
    try:
        data = sp.check_output(['git', 'rev-list', '-1', '--pretty=%h%n%H%n%an%n%s', 'HEAD'],
                               stderr=sp.STDOUT).decode('utf-8')
    except sp.CalledProcessError as e:
        raise OSError("Git error:\n" + e.output) from e
    _, abbrev_id, full_id, author, message = data.strip().split("\n")
    return CommitInfo(id=abbrev_id, id_full=full_id, author=author, message=message)