@@ -4,6 +4,7 @@ from collections import defaultdict
44from pathlib import Path
55import sys
66from dataclasses import dataclass , asdict
7+ import tqdm
78
89import yaml
910
@@ -56,10 +57,20 @@ def get_git_remotes(repo):
5657 return dict (remotes )
5758
5859def get_work_trees (repo ):
59- with with_pushd (repo ):
60- primary , * worktrees = [Path (_ .split ()[0 ]) for _ in !(git worktree list ).itercheck ()]
60+ a = $(git - C @(repo ) worktree list - - porcelain )
61+
62+ primary , * rest = [
63+ {
64+ k : v
65+ for k , v in [
66+ ___ .split (" " ) if " " in ___ else ("branch" , None ) for ___ in __
67+ ]
68+ }
69+ for __ in [_ .split ("\n " ) for _ in a .split ("\n \n " ) if len (_ )]
70+ ]
71+
72+ return primary , rest
6173
62- return primary , worktrees
6374
6475def get_hg_remotes (repo ):
6576 """Given a path to a repository,
@@ -260,12 +271,13 @@ print(sys.version_info)
260271
261272projects = []
262273
263- for repo_path in find_git_repos (path ):
264- print (repo_path )
274+ for repo_path in tqdm .tqdm (find_git_repos (path )):
275+ base , worktrees = get_work_trees (repo_path )
276+ if str (repo_path ) != base ['worktree' ]:
277+ continue
265278 remotes = {}
266279 fix_git_protcol_to_https (repo_path )
267280 for k , v in get_git_remotes (repo_path ).items ():
268- print (f"\t { k } " )
269281 parsed = {direction : parse_git_name (url ) for direction , url in v .items ()}
270282 assert len (parsed ) == 2
271283 remotes [k ] = parsed ["fetch" ]
@@ -279,6 +291,7 @@ for repo_path in find_git_repos(path):
279291 primary_remote = next (iter (remotes .values ()))
280292 if primary_remote is None :
281293 continue
294+
282295 projects .append (
283296 Project (
284297 name = primary_remote .repo_name ,
@@ -290,10 +303,8 @@ for repo_path in find_git_repos(path):
290303
291304
292305for repo_path in find_hg_repos (path ):
293- print (repo_path )
294306 remotes = {}
295307 for k , url in get_hg_remotes (repo_path ).items ():
296- print (f"\t { k } " )
297308 remotes [k ] = parse_hg_name (url )
298309 if not len (remotes ):
299310 continue
0 commit comments