diff options
Diffstat (limited to 'git/refs')
-rw-r--r-- | git/refs/head.py | 22 | ||||
-rw-r--r-- | git/refs/log.py | 28 | ||||
-rw-r--r-- | git/refs/reference.py | 10 | ||||
-rw-r--r-- | git/refs/remote.py | 6 | ||||
-rw-r--r-- | git/refs/symbolic.py | 66 | ||||
-rw-r--r-- | git/refs/tag.py | 14 |
6 files changed, 73 insertions, 73 deletions
diff --git a/git/refs/head.py b/git/refs/head.py index 958f83fa..2ef7c23e 100644 --- a/git/refs/head.py +++ b/git/refs/head.py @@ -12,7 +12,7 @@ __all__ = ["HEAD", "Head"] class HEAD(SymbolicReference): - """Special case of a Symbolic Reference as it represents the repository's + """Special case of a Symbolic Reference as it represents the repository's HEAD reference.""" _HEAD_NAME = 'HEAD' _ORIG_HEAD_NAME = 'ORIG_HEAD' @@ -25,18 +25,18 @@ class HEAD(SymbolicReference): def orig_head(self): """ - :return: SymbolicReference pointing at the ORIG_HEAD, which is maintained + :return: SymbolicReference pointing at the ORIG_HEAD, which is maintained to contain the previous value of HEAD""" return SymbolicReference(self.repo, self._ORIG_HEAD_NAME) - def reset(self, commit='HEAD', index=True, working_tree=False, + def reset(self, commit='HEAD', index=True, working_tree=False, paths=None, **kwargs): - """Reset our HEAD to the given commit optionally synchronizing - the index and working tree. The reference we refer to will be set to + """Reset our HEAD to the given commit optionally synchronizing + the index and working tree. The reference we refer to will be set to commit as well. :param commit: - Commit object, Reference Object or string identifying a revision we + Commit object, Reference Object or string identifying a revision we should reset HEAD to. :param index: @@ -53,7 +53,7 @@ class HEAD(SymbolicReference): that are to be reset. This allows to partially reset individual files. :param kwargs: - Additional arguments passed to git-reset. + Additional arguments passed to git-reset. :return: self""" mode = "--soft" @@ -131,7 +131,7 @@ class Head(Reference): Configure this branch to track the given remote reference. This will alter this branch's configuration accordingly. - :param remote_reference: The remote reference to track or None to untrack + :param remote_reference: The remote reference to track or None to untrack any references :return: self""" if remote_reference is not None and not isinstance(remote_reference, RemoteReference): @@ -154,7 +154,7 @@ class Head(Reference): def tracking_branch(self): """ - :return: The remote_reference we are tracking, or None if we are + :return: The remote_reference we are tracking, or None if we are not a tracking branch""" reader = self.config_reader() if reader.has_option(self.k_config_remote) and reader.has_option(self.k_config_remote_ref): @@ -189,7 +189,7 @@ class Head(Reference): def checkout(self, force=False, **kwargs): """Checkout this head by setting the HEAD to this reference, by updating the index - to reflect the tree we point to and by updating the working tree to reflect + to reflect the tree we point to and by updating the working tree to reflect the latest index. The command will fail if changed working tree files would be overwritten. @@ -231,7 +231,7 @@ class Head(Reference): def config_reader(self): """ - :return: A configuration parser instance constrained to only read + :return: A configuration parser instance constrained to only read this instance's values""" return self._config_parser(read_only=True) diff --git a/git/refs/log.py b/git/refs/log.py index c075e7a0..7249aec5 100644 --- a/git/refs/log.py +++ b/git/refs/log.py @@ -15,7 +15,7 @@ from gitdb.util import ( from git.objects.util import ( parse_date, - Serializable, + Serializable, utctz_to_altz, altz_to_utctz_str, ) @@ -38,12 +38,12 @@ class RefLogEntry(tuple): """Representation of ourselves in git reflog format""" act = self.actor time = self.time - return self._fmt % (self.oldhexsha, self.newhexsha, act.name, act.email, + return self._fmt % (self.oldhexsha, self.newhexsha, act.name, act.email, time[0], altz_to_utctz_str(time[1]), self.message) @property def oldhexsha(self): - """The hexsha to the commit the ref pointed to before the change""" + """The hexsha to the commit the ref pointed to before the change""" return self[0] @property @@ -74,7 +74,7 @@ class RefLogEntry(tuple): """:return: New instance of a RefLogEntry""" if not isinstance(actor, Actor): raise ValueError("Need actor instance, got %s" % actor) - # END check types + # END check types return RefLogEntry((oldhexsha, newhexsha, actor, (time, tz_offset), message)) @classmethod @@ -109,7 +109,7 @@ class RefLogEntry(tuple): class RefLog(list, Serializable): """A reflog contains reflog entries, each of which defines a certain state - of the head in question. Custom query methods allow to retrieve log entries + of the head in question. Custom query methods allow to retrieve log entries by date or by other criteria. Reflog entries are orded, the first added entry is first in the list, the last @@ -123,7 +123,7 @@ class RefLog(list, Serializable): def __init__(self, filepath=None): """Initialize this instance with an optional filepath, from which we will - initialize our data. The path is also used to write changes back using + initialize our data. The path is also used to write changes back using the write() method""" self._path = filepath if filepath is not None: @@ -149,17 +149,17 @@ class RefLog(list, Serializable): @classmethod def from_file(cls, filepath): """ - :return: a new RefLog instance containing all entries from the reflog + :return: a new RefLog instance containing all entries from the reflog at the given filepath - :param filepath: path to reflog + :param filepath: path to reflog :raise ValueError: If the file could not be read or was corrupted in some way""" return cls(filepath) @classmethod def path(cls, ref): """ - :return: string to absolute path at which the reflog of the given ref - instance would be found. The path is not guaranteed to point to a valid + :return: string to absolute path at which the reflog of the given ref + instance would be found. The path is not guaranteed to point to a valid file though. :param ref: SymbolicReference instance""" return join(ref.repo.git_dir, "logs", to_native_path(ref.path)) @@ -167,7 +167,7 @@ class RefLog(list, Serializable): @classmethod def iter_entries(cls, stream): """ - :return: Iterator yielding RefLogEntry instances, one for each line read + :return: Iterator yielding RefLogEntry instances, one for each line read sfrom the given stream. :param stream: file-like object containing the revlog in its native format or basestring instance pointing to a file to read""" @@ -186,13 +186,13 @@ class RefLog(list, Serializable): def entry_at(cls, filepath, index): """:return: RefLogEntry at the given index :param filepath: full path to the index file from which to read the entry - :param index: python list compatible index, i.e. it may be negative to + :param index: python list compatible index, i.e. it may be negative to specifiy an entry counted from the end of the list :raise IndexError: If the entry didn't exist .. note:: This method is faster as it only parses the entry at index, skipping - all other lines. Nonetheless, the whole file has to be read if + all other lines. Nonetheless, the whole file has to be read if the index is negative """ fp = open(filepath, 'rb') @@ -243,7 +243,7 @@ class RefLog(list, Serializable): :param write: If True, the changes will be written right away. Otherwise the change will not be written :return: RefLogEntry objects which was appended to the log - :note: As we are append-only, concurrent access is not a problem as we + :note: As we are append-only, concurrent access is not a problem as we do not interfere with readers.""" if len(oldbinsha) != 20 or len(newbinsha) != 20: raise ValueError("Shas need to be given in binary format") diff --git a/git/refs/reference.py b/git/refs/reference.py index dc745cce..0745b721 100644 --- a/git/refs/reference.py +++ b/git/refs/reference.py @@ -1,7 +1,7 @@ from symbolic import SymbolicReference from git.util import ( - LazyMixin, - Iterable, + LazyMixin, + Iterable, ) from gitdb.util import ( @@ -29,7 +29,7 @@ def require_remote_ref_path(func): class Reference(SymbolicReference, LazyMixin, Iterable): - """Represents a named reference to any object. Subclasses may apply restrictions though, + """Represents a named reference to any object. Subclasses may apply restrictions though, i.e. Heads can only point to commits.""" __slots__ = tuple() _points_to_commits_only = False @@ -43,7 +43,7 @@ class Reference(SymbolicReference, LazyMixin, Iterable): :param path: Path relative to the .git/ directory pointing to the ref in question, i.e. refs/heads/master - :param check_path: if False, you can provide any path. Otherwise the path must start with the + :param check_path: if False, you can provide any path. Otherwise the path must start with the default path prefix of this type.""" if check_path and not path.startswith(self._common_path_default + '/'): raise ValueError("Cannot instantiate %r from path %s" % (self.__class__.__name__, path)) @@ -87,7 +87,7 @@ class Reference(SymbolicReference, LazyMixin, Iterable): @property def name(self): """:return: (shortest) Name of this reference - it may contain path components""" - # first two path tokens are can be removed as they are + # first two path tokens are can be removed as they are # refs/heads or refs/tags or refs/remotes tokens = self.path.split('/') if len(tokens) < 3: diff --git a/git/refs/remote.py b/git/refs/remote.py index 394ad9e5..e3827ad9 100644 --- a/git/refs/remote.py +++ b/git/refs/remote.py @@ -26,11 +26,11 @@ class RemoteReference(Head): def delete(cls, repo, *refs, **kwargs): """Delete the given remote references. :note: - kwargs are given for compatability with the base class method as we + kwargs are given for compatability with the base class method as we should not narrow the signature.""" repo.git.branch("-d", "-r", *refs) - # the official deletion method will ignore remote symbolic refs - these - # are generally ignored in the refs/ folder. We don't though + # the official deletion method will ignore remote symbolic refs - these + # are generally ignored in the refs/ folder. We don't though # and delete remainders manually for ref in refs: try: diff --git a/git/refs/symbolic.py b/git/refs/symbolic.py index 4082e74a..9f9eb9f5 100644 --- a/git/refs/symbolic.py +++ b/git/refs/symbolic.py @@ -1,15 +1,15 @@ import os from git.objects import Object, Commit from git.util import ( - join_path, - join_path_native, + join_path, + join_path_native, to_native_path_linux, assure_directory_exists ) from gitdb.exc import BadObject from gitdb.util import ( - join, + join, dirname, isdir, exists, @@ -27,7 +27,7 @@ __all__ = ["SymbolicReference"] class SymbolicReference(object): """Represents a special case of a reference such that this reference is symbolic. - It does not point to a specific commit, but to another Head, which itself + It does not point to a specific commit, but to another Head, which itself specifies a commit. A typical example for a symbolic reference is HEAD.""" @@ -63,7 +63,7 @@ class SymbolicReference(object): def name(self): """ :return: - In case of symbolic references, the shortest assumable name + In case of symbolic references, the shortest assumable name is the path itself.""" return self.path @@ -101,10 +101,10 @@ class SymbolicReference(object): # END for each line except (OSError, IOError): raise StopIteration - # END no packed-refs file handling - # NOTE: Had try-finally block around here to close the fp, + # END no packed-refs file handling + # NOTE: Had try-finally block around here to close the fp, # but some python version woudn't allow yields within that. - # I believe files are closing themselves on destruction, so it is + # I believe files are closing themselves on destruction, so it is # alright. @classmethod @@ -121,8 +121,8 @@ class SymbolicReference(object): @classmethod def _get_ref_info(cls, repo, ref_path): - """Return: (sha, target_ref_path) if available, the sha the file at - rela_path points to, or None. target_ref_path is the reference we + """Return: (sha, target_ref_path) if available, the sha the file at + rela_path points to, or None. target_ref_path is the reference we point to, or None""" tokens = None try: @@ -156,7 +156,7 @@ class SymbolicReference(object): def _get_object(self): """ :return: - The object our ref currently refers to. Refs can be cached, they will + The object our ref currently refers to. Refs can be cached, they will always point to the actual object as it gets re-created on each query""" # have to be dynamic here as we may be a tag which can point to anything # Our path will be resolved to the hexsha which will be used accordingly @@ -165,7 +165,7 @@ class SymbolicReference(object): def _get_commit(self): """ :return: - Commit object we point to, works for detached and non-detached + Commit object we point to, works for detached and non-detached SymbolicReferences. The symbolic reference will be dereferenced recursively.""" obj = self._get_object() if obj.type == 'tag': @@ -180,7 +180,7 @@ class SymbolicReference(object): def set_commit(self, commit, logmsg=None): """As set_object, but restricts the type of object to be a Commit - :raise ValueError: If commit is not a Commit object or doesn't point to + :raise ValueError: If commit is not a Commit object or doesn't point to a commit :return: self""" # check the type - assume the best if it is a base-string @@ -212,7 +212,7 @@ class SymbolicReference(object): :param object: a refspec, a SymbolicReference or an Object instance. SymbolicReferences will be dereferenced beforehand to obtain the object they point to - :param logmsg: If not None, the message will be used in the reflog entry to be + :param logmsg: If not None, the message will be used in the reflog entry to be written. Otherwise the reflog is not altered :note: plain SymbolicReferences may not actually point to objects by convention :return: self""" @@ -247,8 +247,8 @@ class SymbolicReference(object): def set_reference(self, ref, logmsg=None): """Set ourselves to the given ref. It will stay a symbol if the ref is a Reference. - Otherwise an Object, given as Object instance or refspec, is assumed and if valid, - will be set which effectively detaches the refererence if it was a purely + Otherwise an Object, given as Object instance or refspec, is assumed and if valid, + will be set which effectively detaches the refererence if it was a purely symbolic one. :param ref: SymbolicReference instance, Object instance or refspec string @@ -261,7 +261,7 @@ class SymbolicReference(object): See also: log_append() :return: self - :note: This symbolic reference will not be dereferenced. For that, see + :note: This symbolic reference will not be dereferenced. For that, see ``set_object(...)``""" write_value = None obj = None @@ -317,7 +317,7 @@ class SymbolicReference(object): def is_valid(self): """ :return: - True if the reference is valid, hence it can be read and points to + True if the reference is valid, hence it can be read and points to a valid object or reference.""" try: self.object @@ -355,15 +355,15 @@ class SymbolicReference(object): :param newbinsha: The sha the ref points to now. If None, our current commit sha will be used :return: added RefLogEntry instance""" - return RefLog.append_entry(self.repo.config_reader(), RefLog.path(self), oldbinsha, - (newbinsha is None and self.commit.binsha) or newbinsha, - message) + return RefLog.append_entry(self.repo.config_reader(), RefLog.path(self), oldbinsha, + (newbinsha is None and self.commit.binsha) or newbinsha, + message) def log_entry(self, index): """:return: RefLogEntry at the given index :param index: python list compatible positive or negative index - .. note:: This method must read part of the reflog during execution, hence + .. note:: This method must read part of the reflog during execution, hence it should be used sparringly, or only if you need just one index. In that case, it will be faster than the ``log()`` method""" return RefLog.entry_at(RefLog.path(self), index) @@ -371,7 +371,7 @@ class SymbolicReference(object): @classmethod def to_full_path(cls, path): """ - :return: string with a full repository-relative path which can be used to initialize + :return: string with a full repository-relative path which can be used to initialize a Reference instance, for instance by using ``Reference.from_path``""" if isinstance(path, SymbolicReference): path = path.path @@ -409,9 +409,9 @@ class SymbolicReference(object): made_change = False dropped_last_line = False for line in reader: - # keep line if it is a comment or if the ref to delete is not + # keep line if it is a comment or if the ref to delete is not # in the line - # If we deleted the last line and this one is a tag-reference object, + # If we deleted the last line and this one is a tag-reference object, # we drop it as well if ( line.startswith('#') or full_ref_path not in line ) and \ (not dropped_last_line or dropped_last_line and not line.startswith('^')): @@ -444,8 +444,8 @@ class SymbolicReference(object): @classmethod def _create(cls, repo, path, resolve, reference, force, logmsg=None): """internal method used to create a new symbolic reference. - If resolve is False, the reference will be taken as is, creating - a proper symbolic reference. Otherwise it will be resolved to the + If resolve is False, the reference will be taken as is, creating + a proper symbolic reference. Otherwise it will be resolved to the corresponding object and a detached symbolic reference will be created instead""" full_ref_path = cls.to_full_path(path) @@ -462,7 +462,7 @@ class SymbolicReference(object): target_data = target.path if not resolve: target_data = "ref: " + target_data - existing_data = open(abs_ref_path, 'rb').read().strip() + existing_data = open(abs_ref_path, 'rb').read().strip() if existing_data != target_data: raise OSError("Reference at %r does already exist, pointing to %r, requested was %r" % (full_ref_path, existing_data, target_data)) # END no force handling @@ -476,10 +476,10 @@ class SymbolicReference(object): """Create a new symbolic reference, hence a reference pointing to another reference. :param repo: - Repository to create the reference in + Repository to create the reference in :param path: - full path at which the new symbolic reference is supposed to be + full path at which the new symbolic reference is supposed to be created at, i.e. "NEW_HEAD" or "symrefs/my_new_symref" :param reference: @@ -528,7 +528,7 @@ class SymbolicReference(object): # if they point to the same file, its not an error if open(new_abs_path, 'rb').read().strip() != open(cur_abs_path, 'rb').read().strip(): raise OSError("File at path %r already exists" % new_abs_path) - # else: we could remove ourselves and use the otherone, but + # else: we could remove ourselves and use the otherone, but # but clarity we just continue as usual # END not force handling os.remove(new_abs_path) @@ -551,7 +551,7 @@ class SymbolicReference(object): rela_paths = set() # walk loose refs - # Currently we do not follow links + # Currently we do not follow links for root, dirs, files in os.walk(join_path_native(repo.git_dir, common_path)): if 'refs/' not in root: # skip non-refs subfolders refs_id = [d for d in dirs if d == 'refs'] @@ -589,7 +589,7 @@ class SymbolicReference(object): :param common_path: Optional keyword argument to the path which is to be shared by all returned Ref objects. - Defaults to class specific portion if None assuring that only + Defaults to class specific portion if None assuring that only refs suitable for the actual class are returned. :return: diff --git a/git/refs/tag.py b/git/refs/tag.py index ff32224a..50d2b2af 100644 --- a/git/refs/tag.py +++ b/git/refs/tag.py @@ -5,8 +5,8 @@ __all__ = ["TagReference", "Tag"] class TagReference(Reference): - """Class representing a lightweight tag reference which either points to a commit - ,a tag object or any other object. In the latter case additional information, + """Class representing a lightweight tag reference which either points to a commit + ,a tag object or any other object. In the latter case additional information, like the signature or the tag-creator, is available. This tag object will always point to a commit object, but may carray additional @@ -30,12 +30,12 @@ class TagReference(Reference): # it is a tag object which carries the commit as an object - we can point to anything return obj.object else: - raise ValueError("Tag %s points to a Blob or Tree - have never seen that before" % self) + raise ValueError("Tag %s points to a Blob or Tree - have never seen that before" % self) @property def tag(self): """ - :return: Tag object this tag ref points to or None in case + :return: Tag object this tag ref points to or None in case we are a light weight tag""" obj = self.object if obj.type == "tag": @@ -51,15 +51,15 @@ class TagReference(Reference): """Create a new tag reference. :param path: - The name of the tag, i.e. 1.0 or releases/1.0. + The name of the tag, i.e. 1.0 or releases/1.0. The prefix refs/tags is implied :param ref: - A reference to the object you want to tag. It can be a commit, tree or + A reference to the object you want to tag. It can be a commit, tree or blob. :param message: - If not None, the message will be used in your tag object. This will also + If not None, the message will be used in your tag object. This will also create an additional tag object that allows to obtain that information, i.e.:: tagref.tag.message |