summaryrefslogtreecommitdiffstats
path: root/gita/common.py
blob: abbef5fbd871c449704c8e94fc296a842a1ad56e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import os


def get_config_dir(root=None) -> str:
    if root is None:
        root = os.environ.get('XDG_CONFIG_HOME') or os.path.join(
            os.path.expanduser('~'), '.config')
        return os.path.join(root, "gita")
    else:
        return os.path.join(root, ".gita")


def get_config_fname(fname: str, root=None) -> str:
    """
    Return the file name that stores the repo locations.
    """
    return os.path.join(get_config_dir(root), fname)