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