◐ Shell
reader mode source ↗
Skip to content
Merged
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
41 changes: 24 additions & 17 deletions git/refs/symbolic.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
if TYPE_CHECKING:
from git.config import GitConfigParser
from git.objects.commit import Actor
from git.refs import Head, TagReference, RemoteReference, Reference
from git.refs.log import RefLogEntry
from git.repo import Repo

Expand Down Expand Up @@ -387,17 +386,23 @@ def set_object(
# set the commit on our reference
return self._get_reference().set_object(object, logmsg)

commit = property(
_get_commit,
set_commit, # type: ignore[arg-type]
doc="Query or set commits directly",
)

object = property(
_get_object,
set_object, # type: ignore[arg-type]
doc="Return the object our ref currently refers to",
)

def _get_reference(self) -> "SymbolicReference":
"""
Expand Down Expand Up @@ -496,12 +501,14 @@ def set_reference(
return self

# Aliased reference
reference: Union["Head", "TagReference", "RemoteReference", "Reference"]
reference = property( # type: ignore[assignment]
_get_reference,
set_reference, # type: ignore[arg-type]
doc="Returns the Reference we point to",
)
ref = reference

def is_valid(self) -> bool:
Expand Down
40 changes: 21 additions & 19 deletions git/repo/base.py
Original file line number Diff line number Diff line change
@@ -354,21 +354,19 @@ def __ne__(self, rhs: object) -> bool:
def __hash__(self) -> int:
return hash(self.git_dir)

# Description property
def _get_description(self) -> str:
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")
with open(filename, "wb") as fp:
fp.write((descr + "\n").encode(defenc))

description = property(_get_description, _set_description, doc="the project's description")
del _get_description
del _set_description

@property
def working_tree_dir(self) -> Optional[PathLike]:
"""
Expand Down Expand Up @@ -885,13 +883,14 @@ def _set_daemon_export(self, value: object) -> None:
elif not value and fileexists:
os.unlink(filename)

daemon_export = property(
_get_daemon_export,
_set_daemon_export,
doc="If True, git-daemon may export this repository",
)
del _get_daemon_export
del _set_daemon_export

def _get_alternates(self) -> List[str]:
"""The list of alternates for this repo from which objects can be retrieved.
Expand Down Expand Up @@ -929,11 +928,14 @@ def _set_alternates(self, alts: List[str]) -> None:
with open(alternates_path, "wb") as f:
f.write("\n".join(alts).encode(defenc))

alternates = property(
_get_alternates,
_set_alternates,
doc="Retrieve a list of alternates paths or set a list paths to be used as alternates",
)

def is_dirty(
self,
Expand Down
Toggle all file notes Toggle all file annotations