| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d986a59 commit 94a85d1
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -273,23 +273,30 @@ def __setstate__(self, d: Dict[str, Any]) -> None: | |||
| 273 | 273 | ||
| 274 | 274 | # CONFIGURATION | |
| 275 | 275 | ||
| 276 | - git_exec_name = "git" # Default that should work on Linux and Windows. | ||
| 276 | + git_exec_name = "git" | ||
| 277 | + """Default git command that should work on Linux, Windows, and other systems.""" | ||
| 277 | 278 | ||
| 278 | - # Enables debugging of GitPython's git commands. | ||
| 279 | 279 | GIT_PYTHON_TRACE = os.environ.get("GIT_PYTHON_TRACE", False) | |
| 280 | + """Enables debugging of GitPython's git commands.""" | ||
| 280 | 281 | ||
| 281 | - # If True, a shell will be used when executing git commands. | ||
| 282 | - # This should only be desirable on Windows, see https://github.com/gitpython-developers/GitPython/pull/126 | ||
| 283 | - # and check `git/test_repo.py:TestRepo.test_untracked_files()` TC for an example where it is required. | ||
| 284 | - # Override this value using `Git.USE_SHELL = True`. | ||
| 285 | 282 | USE_SHELL = False | |
| 283 | + """If True, a shell will be used when executing git commands. | ||
| 284 | + | ||
| 285 | + This should only be desirable on Windows, see https://github.com/gitpython-developers/GitPython/pull/126 | ||
| 286 | + and check `git/test_repo.py:TestRepo.test_untracked_files()` TC for an example where it is required. | ||
| 287 | + | ||
| 288 | + Override this value using ``Git.USE_SHELL = True``. | ||
| 289 | + """ | ||
| 286 | 290 | ||
| 287 | - # Provide the full path to the git executable. Otherwise it assumes git is in the path. | ||
| 288 | 291 | _git_exec_env_var = "GIT_PYTHON_GIT_EXECUTABLE" | |
| 289 | 292 | _refresh_env_var = "GIT_PYTHON_REFRESH" | |
| 293 | + | ||
| 290 | 294 | GIT_PYTHON_GIT_EXECUTABLE = None | |
| 291 | - # Note that the git executable is actually found during the refresh step in | ||
| 292 | - # the top level __init__. | ||
| 295 | + """Provide the full path to the git executable. Otherwise it assumes git is in the path. | ||
| 296 | + | ||
| 297 | + Note that the git executable is actually found during the refresh step in | ||
| 298 | + the top level ``__init__``. | ||
| 299 | + """ | ||
| 293 | 300 | ||
| 294 | 301 | @classmethod | |
| 295 | 302 | def refresh(cls, path: Union[None, PathLike] = None) -> bool: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -65,12 +65,14 @@ | |||
| 65 | 65 | log.addHandler(logging.NullHandler()) | |
| 66 | 66 | ||
| 67 | 67 | ||
| 68 | - # The configuration level of a configuration file. | ||
| 69 | 68 | CONFIG_LEVELS: ConfigLevels_Tup = ("system", "user", "global", "repository") | |
| 69 | + """The configuration level of a configuration file.""" | ||
| 70 | 70 | ||
| 71 | - # Section pattern to detect conditional includes. | ||
| 72 | - # https://git-scm.com/docs/git-config#_conditional_includes | ||
| 73 | 71 | CONDITIONAL_INCLUDE_REGEXP = re.compile(r"(?<=includeIf )\"(gitdir|gitdir/i|onbranch):(.+)\"") | |
| 72 | + """Section pattern to detect conditional includes. | ||
| 73 | + | ||
| 74 | + See: https://git-scm.com/docs/git-config#_conditional_includes | ||
| 75 | + """ | ||
| 74 | 76 | ||
| 75 | 77 | ||
| 76 | 78 | class MetaParserBuilder(abc.ABCMeta): # noqa: B024 | |
@@ -283,12 +285,14 @@ class GitConfigParser(cp.RawConfigParser, metaclass=MetaParserBuilder): | |||
| 283 | 285 | """ | |
| 284 | 286 | ||
| 285 | 287 | # { Configuration | |
| 286 | - # The lock type determines the type of lock to use in new configuration readers. | ||
| 287 | - # They must be compatible to the LockFile interface. | ||
| 288 | - # A suitable alternative would be the BlockingLockFile | ||
| 289 | 288 | t_lock = LockFile | |
| 290 | - re_comment = re.compile(r"^\s*[#;]") | ||
| 289 | + """The lock type determines the type of lock to use in new configuration readers. | ||
| 291 | 290 | ||
| 291 | + They must be compatible to the LockFile interface. | ||
| 292 | + A suitable alternative would be the :class:`~git.util.BlockingLockFile`. | ||
| 293 | + """ | ||
| 294 | + | ||
| 295 | + re_comment = re.compile(r"^\s*[#;]") | ||
| 292 | 296 | # } END configuration | |
| 293 | 297 | ||
| 294 | 298 | optvalueonly_source = r"\s*(?P<option>[^:=\s][^:=]*)" | |
@@ -299,8 +303,8 @@ class GitConfigParser(cp.RawConfigParser, metaclass=MetaParserBuilder): | |||
| 299 | 303 | ||
| 300 | 304 | del optvalueonly_source | |
| 301 | 305 | ||
| 302 | - # list of RawConfigParser methods able to change the instance | ||
| 303 | 306 | _mutating_methods_ = ("add_section", "remove_section", "remove_option", "set") | |
| 307 | + """List of RawConfigParser methods able to change the instance.""" | ||
| 304 | 308 | ||
| 305 | 309 | def __init__( | |
| 306 | 310 | self, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -49,8 +49,8 @@ | |||
| 49 | 49 | ||
| 50 | 50 | __all__ = ("Diffable", "DiffIndex", "Diff", "NULL_TREE") | |
| 51 | 51 | ||
| 52 | - # Special object to compare against the empty tree in diffs. | ||
| 53 | 52 | NULL_TREE = object() | |
| 53 | + """Special object to compare against the empty tree in diffs.""" | ||
| 54 | 54 | ||
| 55 | 55 | _octal_byte_re = re.compile(rb"\\([0-9]{3})") | |
| 56 | 56 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -142,9 +142,11 @@ class IndexFile(LazyMixin, git_diff.Diffable, Serializable): | |||
| 142 | 142 | ||
| 143 | 143 | __slots__ = ("repo", "version", "entries", "_extension_data", "_file_path") | |
| 144 | 144 | ||
| 145 | - _VERSION = 2 # Latest version we support. | ||
| 145 | + _VERSION = 2 | ||
| 146 | + """The latest version we support.""" | ||
| 146 | 147 | ||
| 147 | - S_IFGITLINK = S_IFGITLINK # A submodule. | ||
| 148 | + S_IFGITLINK = S_IFGITLINK | ||
| 149 | + """Flags for a submodule.""" | ||
| 148 | 150 | ||
| 149 | 151 | def __init__(self, repo: "Repo", file_path: Union[PathLike, None] = None) -> None: | |
| 150 | 152 | """Initialize this Index instance, optionally from the given ``file_path``. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -49,7 +49,9 @@ | |||
| 49 | 49 | # ------------------------------------------------------------------------------------ | |
| 50 | 50 | ||
| 51 | 51 | ||
| 52 | - S_IFGITLINK = S_IFLNK | S_IFDIR # A submodule. | ||
| 52 | + S_IFGITLINK = S_IFLNK | S_IFDIR | ||
| 53 | + """Flags for a submodule.""" | ||
| 54 | + | ||
| 53 | 55 | CE_NAMEMASK_INV = ~CE_NAMEMASK | |
| 54 | 56 | ||
| 55 | 57 | __all__ = ( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -77,9 +77,9 @@ class UpdateProgress(RemoteProgress): | |||
| 77 | 77 | UPDWKTREE = UpdateProgress.UPDWKTREE | |
| 78 | 78 | ||
| 79 | 79 | ||
| 80 | - # IndexObject comes via util module, its a 'hacky' fix thanks to pythons import | ||
| 81 | - # mechanism which cause plenty of trouble of the only reason for packages and | ||
| 82 | - # modules is refactoring - subpackages shouldn't depend on parent packages | ||
| 80 | + # IndexObject comes via the util module. It's a 'hacky' fix thanks to Python's import | ||
| 81 | + # mechanism, which causes plenty of trouble if the only reason for packages and | ||
| 82 | + # modules is refactoring - subpackages shouldn't depend on parent packages. | ||
| 83 | 83 | class Submodule(IndexObject, TraversableIterableObj): | |
| 84 | 84 | """Implements access to a git submodule. They are special in that their sha | |
| 85 | 85 | represents a commit in the submodule's repository which is to be checked out | |
@@ -95,10 +95,11 @@ class Submodule(IndexObject, TraversableIterableObj): | |||
| 95 | 95 | k_modules_file = ".gitmodules" | |
| 96 | 96 | k_head_option = "branch" | |
| 97 | 97 | k_head_default = "master" | |
| 98 | - k_default_mode = stat.S_IFDIR | stat.S_IFLNK # Submodules are directories with link-status. | ||
| 98 | + k_default_mode = stat.S_IFDIR | stat.S_IFLNK | ||
| 99 | + """Submodule flags. Submodules are directories with link-status.""" | ||
| 99 | 100 | ||
| 100 | - # This is a bogus type for base class compatibility. | ||
| 101 | 101 | type: Literal["submodule"] = "submodule" # type: ignore | |
| 102 | + """This is a bogus type for base class compatibility.""" | ||
| 102 | 103 | ||
| 103 | 104 | __slots__ = ("_parent_commit", "_url", "_branch_path", "_name", "__weakref__") | |
| 104 | 105 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -114,17 +114,18 @@ class Repo: | |||
| 114 | 114 | 'working_tree_dir' is the working tree directory, but will return None | |
| 115 | 115 | if we are a bare repository. | |
| 116 | 116 | ||
| 117 | - 'git_dir' is the .git repository directory, which is always set.""" | ||
| 117 | + 'git_dir' is the .git repository directory, which is always set. | ||
| 118 | + """ | ||
| 118 | 119 | ||
| 119 | 120 | DAEMON_EXPORT_FILE = "git-daemon-export-ok" | |
| 120 | 121 | ||
| 121 | - git = cast("Git", None) # Must exist, or __del__ will fail in case we raise on `__init__()` | ||
| 122 | + git = cast("Git", None) # Must exist, or __del__ will fail in case we raise on `__init__()`. | ||
| 122 | 123 | working_dir: PathLike | |
| 123 | 124 | _working_tree_dir: Optional[PathLike] = None | |
| 124 | 125 | git_dir: PathLike | |
| 125 | 126 | _common_dir: PathLike = "" | |
| 126 | 127 | ||
| 127 | - # precompiled regex | ||
| 128 | + # Precompiled regex | ||
| 128 | 129 | re_whitespace = re.compile(r"\s+") | |
| 129 | 130 | re_hexsha_only = re.compile(r"^[0-9A-Fa-f]{40}$") | |
| 130 | 131 | re_hexsha_shortened = re.compile(r"^[0-9A-Fa-f]{4,40}$") | |
@@ -133,24 +134,32 @@ class Repo: | |||
| 133 | 134 | re_tab_full_line = re.compile(r"^\t(.*)$") | |
| 134 | 135 | ||
| 135 | 136 | unsafe_git_clone_options = [ | |
| 136 | - # This option allows users to execute arbitrary commands. | ||
| 137 | - # https://git-scm.com/docs/git-clone#Documentation/git-clone.txt---upload-packltupload-packgt | ||
| 137 | + # Executes arbitrary commands: | ||
| 138 | 138 | "--upload-pack", | |
| 139 | 139 | "-u", | |
| 140 | - # Users can override configuration variables | ||
| 141 | - # like `protocol.allow` or `core.gitProxy` to execute arbitrary commands. | ||
| 142 | - # https://git-scm.com/docs/git-clone#Documentation/git-clone.txt---configltkeygtltvaluegt | ||
| 140 | + # Can override configuration variables that execute arbitrary commands: | ||
| 143 | 141 | "--config", | |
| 144 | 142 | "-c", | |
| 145 | 143 | ] | |
| 144 | + """Options to ``git clone`` that allow arbitrary commands to be executed. | ||
| 146 | 145 | ||
| 147 | - # invariants | ||
| 148 | - # represents the configuration level of a configuration file | ||
| 146 | + The ``--upload-pack``/``-u`` option allows users to execute arbitrary commands | ||
| 147 | + directly: | ||
| 148 | + https://git-scm.com/docs/git-clone#Documentation/git-clone.txt---upload-packltupload-packgt | ||
| 149 | + | ||
| 150 | + The ``--config``/``-c`` option allows users to override configuration variables like | ||
| 151 | + ``protocol.allow`` and ``core.gitProxy`` to execute arbitrary commands: | ||
| 152 | + https://git-scm.com/docs/git-clone#Documentation/git-clone.txt---configltkeygtltvaluegt | ||
| 153 | + """ | ||
| 154 | + | ||
| 155 | + # Invariants | ||
| 149 | 156 | config_level: ConfigLevels_Tup = ("system", "user", "global", "repository") | |
| 157 | + """Represents the configuration level of a configuration file.""" | ||
| 150 | 158 | ||
| 151 | 159 | # Subclass configuration | |
| 152 | - # Subclasses may easily bring in their own custom types by placing a constructor or type here | ||
| 153 | 160 | GitCommandWrapperType = Git | |
| 161 | + """Subclasses may easily bring in their own custom types by placing a constructor or | ||
| 162 | + type here.""" | ||
| 154 | 163 | ||
| 155 | 164 | def __init__( | |
| 156 | 165 | self, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -557,8 +557,8 @@ class RemoteProgress: | |||
| 557 | 557 | "_cur_line", | |
| 558 | 558 | "_seen_ops", | |
| 559 | 559 | "error_lines", # Lines that started with 'error:' or 'fatal:'. | |
| 560 | - "other_lines", | ||
| 561 | - ) # Lines not denoting progress (i.e.g. push-infos). | ||
| 560 | + "other_lines", # Lines not denoting progress (i.e.g. push-infos). | ||
| 561 | + ) | ||
| 562 | 562 | re_op_absolute = re.compile(r"(remote: )?([\w\s]+):\s+()(\d+)()(.*)") | |
| 563 | 563 | re_op_relative = re.compile(r"(remote: )?([\w\s]+):\s+(\d+)% \((\d+)/(\d+)\)(.*)") | |
| 564 | 564 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments