Skip to content

Add more types #1202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 17, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixes from #1202
  • Loading branch information
Yobmod committed Mar 16, 2021
commit a728b0a4b107a2f8f1e68bc8c3a04099b64ee46c
28 changes: 16 additions & 12 deletions git/repo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,14 @@ def __hash__(self) -> int:

# Description property
def _get_description(self) -> str:
filename = osp.join(self.git_dir, 'description') if self.git_dir else ""
if self.git_dir:
filename = osp.join(self.git_dir, 'description')
with open(filename, 'rb') as fp:
return fp.read().rstrip().decode(defenc)

def _set_description(self, descr: str) -> None:

filename = osp.join(self.git_dir, 'description') if self.git_dir else ""
if self.git_dir:
filename = osp.join(self.git_dir, 'description')
with open(filename, 'wb') as fp:
fp.write((descr + '\n').encode(defenc))

Expand Down Expand Up @@ -460,12 +461,11 @@ def _get_config_path(self, config_level: Lit_config_levels) -> str:
elif config_level == "global":
return osp.normpath(osp.expanduser("~/.gitconfig"))
elif config_level == "repository":
if self._common_dir:
return osp.normpath(osp.join(self._common_dir, "config"))
elif self.git_dir:
return osp.normpath(osp.join(self.git_dir, "config"))
else:
repo_dir = self._common_dir or self.git_dir
if not repo_dir:
raise NotADirectoryError
else:
return osp.normpath(osp.join(repo_dir, "config"))

raise ValueError("Invalid configuration level: %r" % config_level)

Expand Down Expand Up @@ -611,11 +611,13 @@ def is_ancestor(self, ancestor_rev: 'Commit', rev: 'Commit') -> bool:
return True

def _get_daemon_export(self) -> bool:
filename = osp.join(self.git_dir, self.DAEMON_EXPORT_FILE) if self.git_dir else ""
if self.git_dir:
filename = osp.join(self.git_dir, self.DAEMON_EXPORT_FILE)
return osp.exists(filename)

def _set_daemon_export(self, value: object) -> None:
filename = osp.join(self.git_dir, self.DAEMON_EXPORT_FILE) if self.git_dir else ""
if self.git_dir:
filename = osp.join(self.git_dir, self.DAEMON_EXPORT_FILE)
fileexists = osp.exists(filename)
if value and not fileexists:
touch(filename)
Expand All @@ -631,7 +633,8 @@ def _get_alternates(self) -> List[str]:
"""The list of alternates for this repo from which objects can be retrieved

:return: list of strings being pathnames of alternates"""
alternates_path = osp.join(self.git_dir, 'objects', 'info', 'alternates') if self.git_dir else ""
if self.git_dir:
alternates_path = osp.join(self.git_dir, 'objects', 'info', 'alternates')

if osp.exists(alternates_path):
with open(alternates_path, 'rb') as f:
Expand Down Expand Up @@ -1134,7 +1137,8 @@ def currently_rebasing_on(self) -> Union['SymbolicReference', Commit, 'TagObject

None if we are not currently rebasing.
"""
rebase_head_file = osp.join(self.git_dir, "REBASE_HEAD") if self.git_dir else ""
if self.git_dir:
rebase_head_file = osp.join(self.git_dir, "REBASE_HEAD")
if not osp.isfile(rebase_head_file):
return None
return self.commit(open(rebase_head_file, "rt").readline().strip())