Exemple #1
0
def has_revision(dest, revision):
    """Returns True if revision exists in dest"""
    try:
        run_quiet_cmd(['git', 'log', '--oneline', '-n1', revision], cwd=dest)
        return True
    except subprocess.CalledProcessError:
        return False
Exemple #2
0
def has_revision(dest, revision):
    """Returns True if revision exists in dest"""
    try:
        run_quiet_cmd(['git', 'log', '--oneline', '-n1', revision], cwd=dest)
        return True
    except subprocess.CalledProcessError:
        return False
Exemple #3
0
def has_ref(dest, refname):
    """Returns True if refname exists in dest.
    refname can be a branch or tag name."""
    try:
        run_quiet_cmd(['git', 'show-ref', '-d', refname], cwd=dest)
        return True
    except subprocess.CalledProcessError:
        return False
Exemple #4
0
def has_ref(dest, refname):
    """Returns True if refname exists in dest.
    refname can be a branch or tag name."""
    try:
        run_quiet_cmd(['git', 'show-ref', '-d', refname], cwd=dest)
        return True
    except subprocess.CalledProcessError:
        return False
Exemple #5
0
def is_git_repo(dest):
    """Returns True if dest is a valid git repo"""
    if not os.path.isdir(dest):
        return False

    try:
        run_quiet_cmd(["git", "rev-parse"], cwd=dest)
        return True
    except subprocess.CalledProcessError:
        return False
Exemple #6
0
def has_rev(repo, rev):
    """Returns True if the repository has the specified revision.

    Arguments:
        repo (str):     path to repository
        rev  (str):     revision identifier
    """
    log.info("checking to see if %s exists in %s", rev, repo)
    cmd = ['hg', 'log', '-r', rev, '--template', '{node}']
    try:
        run_quiet_cmd(cmd, cwd=repo)
        log.info("%s exists in %s", rev, repo)
        return True
    except subprocess.CalledProcessError:
        log.info("%s does not exist in %s", rev, repo)
        return False
Exemple #7
0
def has_rev(repo, rev):
    """Returns True if the repository has the specified revision.

    Arguments:
        repo (str):     path to repository
        rev  (str):     revision identifier
    """
    log.info("checking to see if %s exists in %s", rev, repo)
    cmd = ['hg', 'log', '-r', rev, '--template', '{node}']
    try:
        run_quiet_cmd(cmd, cwd=repo)
        log.info("%s exists in %s", rev, repo)
        return True
    except subprocess.CalledProcessError:
        log.info("%s does not exist in %s", rev, repo)
        return False
Exemple #8
0
    # Let's create all the directories first
    try:
        os.makedirs(dest)
    except OSError, e:
        if e.errno == 20:
            # Not a directory error...one of the parents of dest isn't a
            # directory
            raise

    if bare:
        cmd = ['git', 'init', '--bare', '-q', dest]
    else:
        cmd = ['git', 'init', '-q', dest]

    log.info(" ".join(cmd))
    run_quiet_cmd(cmd)


def is_git_repo(dest):
    """Returns True if dest is a valid git repo"""
    if not os.path.isdir(dest):
        return False

    try:
        run_quiet_cmd(["git", "rev-parse"], cwd=dest)
        return True
    except subprocess.CalledProcessError:
        return False


def get_git_dir(dest):
Exemple #9
0
    # Let's create all the directories first
    try:
        os.makedirs(dest)
    except OSError, e:
        if e.errno == 20:
            # Not a directory error...one of the parents of dest isn't a
            # directory
            raise

    if bare:
        cmd = ['git', 'init', '--bare', '-q', dest]
    else:
        cmd = ['git', 'init', '-q', dest]

    log.info(" ".join(cmd))
    run_quiet_cmd(cmd)


def is_git_repo(dest):
    """Returns True if dest is a valid git repo"""
    if not os.path.isdir(dest):
        return False

    try:
        proc = subprocess.Popen(["git", "rev-parse", "--git-dir"],
                                cwd=dest,
                                stdout=subprocess.PIPE)
        if proc.wait() != 0:
            return False
        output = proc.stdout.read().strip()
        git_dir = os.path.normpath(os.path.join(dest, output))