| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 27a283b commit e500466
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,6 +9,9 @@ | |||
| 9 | 9 | import re | |
| 10 | 10 | import shlex | |
| 11 | 11 | import warnings | |
| 12 | + | ||
| 13 | + from pathlib import Path | ||
| 14 | + | ||
| 12 | 15 | from gitdb.db.loose import LooseObjectDB | |
| 13 | 16 | ||
| 14 | 17 | from gitdb.exc import BadObject | |
@@ -268,7 +271,7 @@ def __init__( | |||
| 268 | 271 | pass | |
| 269 | 272 | ||
| 270 | 273 | 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() | ||
| 272 | 275 | self._common_dir = osp.join(self.git_dir, common_dir) | |
| 273 | 276 | except OSError: | |
| 274 | 277 | self._common_dir = "" | |
@@ -1385,4 +1388,6 @@ def currently_rebasing_on(self) -> Commit | None: | |||
| 1385 | 1388 | rebase_head_file = osp.join(self.git_dir, "REBASE_HEAD") | |
| 1386 | 1389 | if not osp.isfile(rebase_head_file): | |
| 1387 | 1390 | 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 | |
|---|---|---|---|
@@ -2,6 +2,7 @@ | |||
| 2 | 2 | from __future__ import annotations | |
| 3 | 3 | import os | |
| 4 | 4 | import stat | |
| 5 | + from pathlib import Path | ||
| 5 | 6 | from string import digits | |
| 6 | 7 | ||
| 7 | 8 | from git.exc import WorkTreeRepositoryUnsupported | |
@@ -83,7 +84,7 @@ def find_worktree_git_dir(dotgit: "PathLike") -> Optional[str]: | |||
| 83 | 84 | return None | |
| 84 | 85 | ||
| 85 | 86 | try: | |
| 86 | - lines = open(dotgit, "r").readlines() | ||
| 87 | + lines = Path(dotgit).read_text().splitlines() | ||
| 87 | 88 | for key, value in [line.strip().split(": ") for line in lines]: | |
| 88 | 89 | if key == "gitdir": | |
| 89 | 90 | return value | |
| Back | FazBrowse Home | New Git URL |
0 commit comments