Exemplo n.º 1
0
 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"
Exemplo n.º 2
0
if tuple(int(x) for x in platform.python_version_tuple()) < (3, 5, 0):
    raise RuntimeError(
        "SmokeDetector requires Python version 3.5 or newer to run.")

# However, we're considering the potential to deprecate 3.5 so we need to prepare
# from this with a warning in the logs about it.
if tuple(int(x) for x in platform.python_version_tuple()) < (3, 6, 0):
    log(
        'warning',
        'SmokeDetector may remove support for versions of Python before '
        '3.6.0 in the future, please consider upgrading your instances of '
        'SmokeDetector to use Python 3.6 or newer.')

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%an%n%s', 'HEAD'],
            stderr=sp.STDOUT).decode('utf-8')
    except sp.CalledProcessError as e:
        raise OSError("Git error:\n" + e.output) from e
    _, full_id, author, message = data.strip().split("\n")
    return CommitInfo(id=full_id[:7],