def commit_author_time_and_branch_ref(run, master_branch): get_refs = for_each_ref('refs/remotes/origin/**', format='%(refname:short) %(authordate:unix)') with run(get_refs) as program: for branch, t in columns(program.stdout): get_time = log(f"{master_branch}..{branch}", format='%at') with run(get_time) as inner_program: for author_time, in columns(inner_program.stdout): yield int(author_time), branch
def diff_of_commits_between(run, upstream: str, head: str) -> Iterable[str]: cmd = cherry(upstream, head) proc = run(cmd) stdout = proc_to_stdout(proc) for sign, commit in columns(stdout): if sign == '+': yield commit
def fetch_tags_and_sha(run, match_tag): proc = run(TAGS_WITH_COMMIT_SHA_CMD) stdout = proc_to_stdout(proc) return ( (tag_and_maybe_sha[0], tag_and_maybe_sha[1]) for tag_and_maybe_sha in columns(stdout) if len(tag_and_maybe_sha) > 1 and match_tag(tag_and_maybe_sha[0]) )
def parse_tags_with_author_date(lines: Iterable[str]) -> Iterable[Tuple[str, int]]: return ((tag, int(date)) for tag, date in columns(lines))
def parse_tags_with_date(lines: Iterable[str]) -> Iterable[Tuple[str, int]]: return ((tag_and_maybe_date[0], int(tag_and_maybe_date[1])) for tag_and_maybe_date in columns(lines) if len(tag_and_maybe_date) > 1)
def test_two_columns(): assert list(columns(["a c", "b d"])) == [["a", "c"], ["b", "d"]]
def test_single_column(): assert list(columns(["a", "b"])) == [["a"], ["b"]]