File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99import re
1010import shlex
1111import warnings
12+
13+ from pathlib import Path
14+
1215from gitdb .db .loose import LooseObjectDB
1316
1417from gitdb .exc import BadObject
@@ -268,7 +271,7 @@ def __init__(
268271 pass
269272
270273 try :
271- common_dir = open ( osp . join (self .git_dir , "commondir" ), "rt" ). readlines ()[0 ].strip ()
274+ common_dir = ( Path (self .git_dir ) / "commondir" ). read_text (). splitlines ()[0 ].strip ()
272275 self ._common_dir = osp .join (self .git_dir , common_dir )
273276 except OSError :
274277 self ._common_dir = ""
@@ -1385,4 +1388,6 @@ def currently_rebasing_on(self) -> Commit | None:
13851388 rebase_head_file = osp .join (self .git_dir , "REBASE_HEAD" )
13861389 if not osp .isfile (rebase_head_file ):
13871390 return None
1388- return self .commit (open (rebase_head_file , "rt" ).readline ().strip ())
1391+ with open (rebase_head_file , "rt" ) as f :
1392+ content = f .readline ().strip ()
1393+ return self .commit (content )
Original file line number Diff line number Diff line change 22from __future__ import annotations
33import os
44import stat
5+ from pathlib import Path
56from string import digits
67
78from git .exc import WorkTreeRepositoryUnsupported
@@ -83,7 +84,7 @@ def find_worktree_git_dir(dotgit: "PathLike") -> Optional[str]:
8384 return None
8485
8586 try :
86- lines = open (dotgit , "r" ). readlines ()
87+ lines = Path (dotgit ). read_text (). splitlines ()
8788 for key , value in [line .strip ().split (": " ) for line in lines ]:
8889 if key == "gitdir" :
8990 return value
You can’t perform that action at this time.
0 commit comments