Exemple #1
0
def cwd_to_rc_path():
    """Scan current and ancestor directories for an existing
    .git-fusion-rc file.

    Return path to .git-fusion-rc file if found, None if not.
    """
    return p4gf_path.cwd_to_rc_file()
def reset_git_enviro():
    """Clear GIT_DIR and other GIT_xxx  environment variables,
    then chdir to GIT_WORK_TREE.

    This undoes any strangeness that might come in from T4 calling 'git
    --git-dir=xxx --work-tree=yyy' which might cause us to erroneously
    operate on the "client-side" git repo when invoked from T4.

    or from git-receive-pack chdir-ing into the .git dir.
    """
    git_env_key = [k for k in os.environ if k.startswith("GIT_")]
    for key in git_env_key:
        del os.environ[key]

    # Find our view name, use that to calculate and chdir into our GIT_WORK_TREE.
    rc_path = p4gf_path.cwd_to_rc_file()
    if (rc_path):
        view_name = rc_path_to_view_name(rc_path)
        LOG.debug("reset_git_enviro rc_path_to_view_name({rc_path}) returned {view_name}"
                  .format(rc_path=rc_path, view_name=view_name))
        p4gf_dir    = rc_path_to_p4gf_dir(rc_path)
        LOG.debug("reset_git_enviro rc_path_to_p4gf_dir({rc_path}) returned {p4gf_dir}"
                  .format(rc_path=rc_path, p4gf_dir=p4gf_dir))
        view_dirs  = p4gf_view_dirs.from_p4gf_dir(p4gf_dir, view_name)
        os.chdir(view_dirs.GIT_WORK_TREE)
Exemple #3
0
def cwd_to_rc_path():
    """Scan current and ancestor directories for an existing
    .git-fusion-rc file.

    Return path to .git-fusion-rc file if found, None if not.
    """
    return p4gf_path.cwd_to_rc_file()
Exemple #4
0
def reset_git_enviro():
    """Clear GIT_DIR and other GIT_xxx  environment variables,
    then chdir to GIT_WORK_TREE.

    This undoes any strangeness that might come in from T4 calling 'git
    --git-dir=xxx --work-tree=yyy' which might cause us to erroneously
    operate on the "client-side" git repo when invoked from T4.

    or from git-receive-pack chdir-ing into the .git dir.
    """
    git_env_key = [k for k in os.environ if k.startswith("GIT_")]
    for key in git_env_key:
        del os.environ[key]

    # Find our view name, use that to calculate and chdir into our GIT_WORK_TREE.
    rc_path = p4gf_path.cwd_to_rc_file()
    if (rc_path):
        view_name = rc_path_to_view_name(rc_path)
        LOG.debug(
            "reset_git_enviro rc_path_to_view_name({rc_path}) returned {view_name}"
            .format(rc_path=rc_path, view_name=view_name))
        p4gf_dir = rc_path_to_p4gf_dir(rc_path)
        LOG.debug(
            "reset_git_enviro rc_path_to_p4gf_dir({rc_path}) returned {p4gf_dir}"
            .format(rc_path=rc_path, p4gf_dir=p4gf_dir))
        view_dirs = p4gf_view_dirs.from_p4gf_dir(p4gf_dir, view_name)
        os.chdir(view_dirs.GIT_WORK_TREE)