emit only unique commits
This commit is contained in:
parent
150688d9bd
commit
cec7cad2bf
1 changed files with 20 additions and 13 deletions
|
@ -4,7 +4,7 @@ Git commits data: crawls filesystem
|
|||
|
||||
from pathlib import Path
|
||||
from datetime import datetime, timezone
|
||||
from typing import List, NamedTuple, Optional, Dict, Any, Iterator
|
||||
from typing import List, NamedTuple, Optional, Dict, Any, Iterator, Set
|
||||
|
||||
from ..common import PathIsh, LazyLogger
|
||||
from mycfg import commits as config
|
||||
|
@ -69,10 +69,16 @@ def _git_root(git_dir: PathIsh) -> Path:
|
|||
return gd # must be bare
|
||||
|
||||
|
||||
def _repo_commits_aux(gr: git.Repo, rev: str) -> Iterator[Commit]:
|
||||
def _repo_commits_aux(gr: git.Repo, rev: str, emitted: Set[str]) -> Iterator[Commit]:
|
||||
# without path might not handle pull heads properly
|
||||
for c in gr.iter_commits(rev=rev):
|
||||
if by_me(c):
|
||||
if not by_me(c):
|
||||
continue
|
||||
sha = c.hexsha
|
||||
if sha in emitted:
|
||||
continue
|
||||
emitted.add(sha)
|
||||
|
||||
repo = str(_git_root(gr.git_dir))
|
||||
|
||||
yield Commit(
|
||||
|
@ -80,15 +86,16 @@ def _repo_commits_aux(gr: git.Repo, rev: str) -> Iterator[Commit]:
|
|||
authored_dt=fix_datetime(c.authored_datetime),
|
||||
message=c.message.strip(),
|
||||
repo=repo,
|
||||
sha=c.hexsha,
|
||||
sha=sha,
|
||||
ref=rev,
|
||||
)
|
||||
|
||||
|
||||
def repo_commits(repo: PathIsh):
|
||||
gr = git.Repo(str(repo))
|
||||
emitted: Set[str] = set()
|
||||
for r in gr.references:
|
||||
yield from _repo_commits_aux(gr=gr, rev=r.path)
|
||||
yield from _repo_commits_aux(gr=gr, rev=r.path, emitted=emitted)
|
||||
|
||||
|
||||
def canonical_name(repo: Path) -> str:
|
||||
|
|
Loading…
Add table
Reference in a new issue