def get_newest_commit_from_branch(ref, repo, yamlpath): repo_path = path.join(path.dirname(path.realpath(yamlpath)), 'cassandra') if not path.isdir(repo_path): cmd = ('git', 'clone', '--bare', 'https://github.com/apache/cassandra', repo_path) check_output(cmd).decode('utf8') cmd = ('git', '--git-dir=%s' % repo_path, 'fetch', repo, ref) check_output(cmd).decode('utf8') cmd = ('git', '--git-dir=%s' % repo_path, 'show', '--format=%cd','--date=short', '--quiet', 'FETCH_HEAD') out = check_output(cmd).decode('utf8') return out
def hg_branch_iter_remote(repo, python): with NamedTemporaryFile() as fh: cmd = (hg_list_remote_py % {'repo': repo}).encode('utf8') fh.write(cmd) fh.flush() out = check_output((python, fh.name)) out = literal_eval(out.decode('utf8')) return [i[0] for i in out]
def hg_branch_iter_remote(repo, python): with NamedTemporaryFile() as fh: cmd = (hg_list_remote_py % repo).encode('utf8') fh.write(cmd) fh.flush() out = check_output((python, fh.name)) out = literal_eval(out.decode('utf8')) return [i[0] for i in out]
def git_refs_iter_remote(repo): cmd = ('git', 'ls-remote', repo) out = check_output(cmd).decode('utf8').split(linesep) for sha, ref in (i.split() for i in out if i): if not ref.startswith('refs/'): continue # :todo: generalize if ref.endswith('^{}'): continue yield ref
def svn_ls(url, username=None, password=None, dirsonly=True): cmd = ['svn', 'ls', '--trust-server-cert', '--non-interactive'] # :todo: plaintext (will probably have to use the bindings). if username: cmd += ['--username', username] if password: cmd += ['--password', password] cmd.append(url) out = check_output(cmd).decode('utf8').split(linesep) if dirsonly: out = [i.rstrip('/') for i in out if i.endswith('/')] return out
def svn_ls(url, username=None, password=None, dirsonly=True): cmd = ['svn', 'ls', '--trust-server-cert', '--non-interactive'] # :todo: plaintext (will probably have to use the bindings) if username: cmd += ['--username', username] if password: cmd += ['--password', password] cmd.append(url) out = check_output(cmd).decode('utf8').split(linesep) if dirsonly: out = [i.rstrip('/') for i in out if i.endswith('/')] return out
def git_refs_iter_remote(repo, stale, before, yamlpath): cmd = ('git', 'ls-remote', '--heads', repo) out = check_output(cmd).decode('utf8').split(linesep) for sha, ref in (i.split() for i in out if i): if not ref.startswith('refs/'): continue # :todo: generalize if ref.endswith('^{}'): continue if stale and stale_branch(ref, repo, stale, before, yamlpath): continue yield ref
def svn_ls(url, username=None, password=None, dirsonly=True): cmd = ["svn", "ls", "--trust-server-cert", "--non-interactive"] # :todo: plaintext (will probably have to use the bindings). if username: cmd += ["--username", username] if password: cmd += ["--password", password] cmd.append(url) out = check_output(cmd).decode("utf8").split(linesep) if dirsonly: out = [i.rstrip("/") for i in out if i.endswith("/")] return out
def git_refs_iter_local(repo): cmd = ('git', 'show-ref') out = check_output(cmd, cwd=repo).split(linesep) return (ref for sha, ref in [i.split() for i in out if i])
def hg_branch_iter_local(repo): cmd = ('hg', '-y', 'branches', '-c', '-R', repo) out = check_output(cmd).decode('utf8').split(linesep) out = (re.split('\s+', i, 1) for i in out if i) return (name for name, rev in out)
def hg_branch_iter_local(repo, python, max_branch_age): cmd = ("hg", "-y", "branches", "-c", "-R", repo) out = check_output(cmd).decode("utf8").split(linesep) out = (re.split("\s+", i, 1) for i in out if i) return (name for name, rev in out)