Working on multi-repo
This commit is contained in:
parent
4edd3eecd0
commit
fed527be4b
|
@ -4,13 +4,14 @@ import dataclasses
|
|||
import git
|
||||
import datetime
|
||||
from collections.abc import Iterator, Sequence
|
||||
from pathlib import Path
|
||||
|
||||
def parse_arguments():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("repo")
|
||||
parser.add_argument('repositories', action='extend', nargs='+', type=Path)
|
||||
return parser.parse_args()
|
||||
|
||||
@dataclasses.dataclass
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class WorkSample:
|
||||
registered_at: datetime.datetime
|
||||
labels: Sequence[str]
|
||||
|
@ -20,18 +21,19 @@ def get_samples_from_project(repo: git.Repo) -> Iterator[WorkSample]:
|
|||
labels = []
|
||||
labels.append('project:git_time_tracker')
|
||||
|
||||
for commit in repo.iter_commits('main'):
|
||||
assert commit.authored_date == commit.committed_date, 'Not yet supported'
|
||||
print(repo.remotes.origin.repo)
|
||||
|
||||
committed_at = datetime.datetime.fromtimestamp(commit.authored_date, tz=datetime.UTC)
|
||||
yield WorkSample(committed_at, tuple(labels))
|
||||
# TODO: Branch on main or master or default
|
||||
for commit in repo.iter_commits('main'):
|
||||
yield WorkSample(datetime.datetime.fromtimestamp(commit.authored_date, tz=datetime.UTC), tuple(labels))
|
||||
yield WorkSample(datetime.datetime.fromtimestamp(commit.committed_date, tz=datetime.UTC), tuple(labels))
|
||||
|
||||
def main():
|
||||
args = parse_arguments()
|
||||
|
||||
repo = git.Repo(args.repo)
|
||||
print(repo)
|
||||
shared_time_stamps: set[WorkSample] = set()
|
||||
for repo_path in args.repositories:
|
||||
repo = git.Repo(repo_path)
|
||||
shared_time_stamps |= set(get_samples_from_project(repo))
|
||||
print('derp', shared_time_stamps)
|
||||
|
||||
# TODO: Branch on main or master or default
|
||||
|
||||
print(list(get_samples_from_project(repo)))
|
||||
|
|
Reference in New Issue
Block a user