# Path: weechat/common/path.py
# def project_path_join(*args):
#     """Join multiple paths after settings.BASE_DIR."""
#     return __path_join(settings.BASE_DIR, *args)


import re
from django.utils.safestring import mark_safe
from weechat.common.path import project_path_join


def split_commit(commit):
    """
    Return repository and commit id with a commit name, with one of these
    formats:

        org/repo@commit
        repo@commit
        commit

    Default repository is weechat/weechat.
    """
    if '@' not in commit:
        return ('weechat/weechat', commit)
    repo, commit_id = commit.split('@', 1)
    if '/' not in repo:
        repo = f'weechat/{repo}'
    return (repo, commit_id)


def commits_links(commits):
    """Replace commits or branches by GitHub URLs."""
    if not commits:
        return ''

    # read SVG with git commit/branch
    filename = project_path_join('templates', 'svg', 'git-commit.html')
    with open(filename, 'r', encoding='utf-8') as _file:
        svg_commit = _file.read().strip()

# Path: weechat/common/path.py
# def project_path_join(*args):
#     """Join multiple paths after settings.BASE_DIR."""
#     return __path_join(settings.BASE_DIR, *args)


# Path: weechat/common/tracker.py
import re
from django.utils.safestring import mark_safe
from weechat.common.path import project_path_join



def split_commit(commit):
    """
    Return repository and commit id with a commit name, with one of these
    formats:

        org/repo@commit
        repo@commit
        commit

    Default repository is weechat/weechat.
    """
    if '@' not in commit:
        return ('weechat/weechat', commit)
    repo, commit_id = commit.split('@', 1)
    if '/' not in repo:
        repo = f'weechat/{repo}'
    return (repo, commit_id)


def commits_links(commits):
    """Replace commits or branches by GitHub URLs."""
    if not commits:
        return ''

    # read SVG with git commit/branch
    filename = project_path_join('templates', 'svg', 'git-commit.html')
    with open(filename, 'r', encoding='utf-8') as _file:
        svg_commit = _file.read().strip()

    filename = project_path_join('templates', 'svg', 'git-branch.html')