| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -81,8 +81,7 @@ | |||
| 81 | 81 | "strip_newline_in_stdout", | |
| 82 | 82 | } | |
| 83 | 83 | ||
| 84 | - log = logging.getLogger(__name__) | ||
| 85 | - log.addHandler(logging.NullHandler()) | ||
| 84 | + _logger = logging.getLogger(__name__) | ||
| 86 | 85 | ||
| 87 | 86 | __all__ = ("Git",) | |
| 88 | 87 | ||
@@ -146,7 +145,7 @@ def pump_stream( | |||
| 146 | 145 | handler(line) | |
| 147 | 146 | ||
| 148 | 147 | except Exception as ex: | |
| 149 | - log.error(f"Pumping {name!r} of cmd({remove_password_if_present(cmdline)}) failed due to: {ex!r}") | ||
| 148 | + _logger.error(f"Pumping {name!r} of cmd({remove_password_if_present(cmdline)}) failed due to: {ex!r}") | ||
| 150 | 149 | if "I/O operation on closed file" not in str(ex): | |
| 151 | 150 | # Only reraise if the error was not due to the stream closing | |
| 152 | 151 | raise CommandError([f"<{name}-pump>"] + remove_password_if_present(cmdline), ex) from ex | |
@@ -600,7 +599,7 @@ def _terminate(self) -> None: | |||
| 600 | 599 | self.status = self._status_code_if_terminate or proc.poll() | |
| 601 | 600 | return | |
| 602 | 601 | except OSError as ex: | |
| 603 | - log.info("Ignored error after process had died: %r", ex) | ||
| 602 | + _logger.info("Ignored error after process had died: %r", ex) | ||
| 604 | 603 | ||
| 605 | 604 | # It can be that nothing really exists anymore... | |
| 606 | 605 | if os is None or getattr(os, "kill", None) is None: | |
@@ -613,7 +612,7 @@ def _terminate(self) -> None: | |||
| 613 | 612 | ||
| 614 | 613 | self.status = self._status_code_if_terminate or status | |
| 615 | 614 | except OSError as ex: | |
| 616 | - log.info("Ignored error after process had died: %r", ex) | ||
| 615 | + _logger.info("Ignored error after process had died: %r", ex) | ||
| 617 | 616 | # END exception handling | |
| 618 | 617 | ||
| 619 | 618 | def __del__(self) -> None: | |
@@ -654,7 +653,7 @@ def read_all_from_possibly_closed_stream(stream: Union[IO[bytes], None]) -> byte | |||
| 654 | 653 | ||
| 655 | 654 | if status != 0: | |
| 656 | 655 | errstr = read_all_from_possibly_closed_stream(p_stderr) | |
| 657 | - log.debug("AutoInterrupt wait stderr: %r" % (errstr,)) | ||
| 656 | + _logger.debug("AutoInterrupt wait stderr: %r" % (errstr,)) | ||
| 658 | 657 | raise GitCommandError(remove_password_if_present(self.args), status, errstr) | |
| 659 | 658 | return status | |
| 660 | 659 | ||
@@ -1018,7 +1017,7 @@ def execute( | |||
| 1018 | 1017 | # Remove password for the command if present. | |
| 1019 | 1018 | redacted_command = remove_password_if_present(command) | |
| 1020 | 1019 | if self.GIT_PYTHON_TRACE and (self.GIT_PYTHON_TRACE != "full" or as_process): | |
| 1021 | - log.info(" ".join(redacted_command)) | ||
| 1020 | + _logger.info(" ".join(redacted_command)) | ||
| 1022 | 1021 | ||
| 1023 | 1022 | # Allow the user to have the command executed in their working dir. | |
| 1024 | 1023 | try: | |
@@ -1055,7 +1054,7 @@ def execute( | |||
| 1055 | 1054 | stdout_sink = PIPE if with_stdout else getattr(subprocess, "DEVNULL", None) or open(os.devnull, "wb") | |
| 1056 | 1055 | if shell is None: | |
| 1057 | 1056 | shell = self.USE_SHELL | |
| 1058 | - log.debug( | ||
| 1057 | + _logger.debug( | ||
| 1059 | 1058 | "Popen(%s, cwd=%s, stdin=%s, shell=%s, universal_newlines=%s)", | |
| 1060 | 1059 | redacted_command, | |
| 1061 | 1060 | cwd, | |
@@ -1167,17 +1166,17 @@ def as_text(stdout_value: Union[bytes, str]) -> str: | |||
| 1167 | 1166 | # END as_text | |
| 1168 | 1167 | ||
| 1169 | 1168 | if stderr_value: | |
| 1170 | - log.info( | ||
| 1169 | + _logger.info( | ||
| 1171 | 1170 | "%s -> %d; stdout: '%s'; stderr: '%s'", | |
| 1172 | 1171 | cmdstr, | |
| 1173 | 1172 | status, | |
| 1174 | 1173 | as_text(stdout_value), | |
| 1175 | 1174 | safe_decode(stderr_value), | |
| 1176 | 1175 | ) | |
| 1177 | 1176 | elif stdout_value: | |
| 1178 | - log.info("%s -> %d; stdout: '%s'", cmdstr, status, as_text(stdout_value)) | ||
| 1177 | + _logger.info("%s -> %d; stdout: '%s'", cmdstr, status, as_text(stdout_value)) | ||
| 1179 | 1178 | else: | |
| 1180 | - log.info("%s -> %d", cmdstr, status) | ||
| 1179 | + _logger.info("%s -> %d", cmdstr, status) | ||
| 1181 | 1180 | # END handle debug printing | |
| 1182 | 1181 | ||
| 1183 | 1182 | if with_exceptions and status != 0: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -60,10 +60,7 @@ | |||
| 60 | 60 | ||
| 61 | 61 | __all__ = ("GitConfigParser", "SectionConstraint") | |
| 62 | 62 | ||
| 63 | - | ||
| 64 | - log = logging.getLogger("git.config") | ||
| 65 | - log.addHandler(logging.NullHandler()) | ||
| 66 | - | ||
| 63 | + _logger = logging.getLogger(__name__) | ||
| 67 | 64 | ||
| 68 | 65 | CONFIG_LEVELS: ConfigLevels_Tup = ("system", "user", "global", "repository") | |
| 69 | 66 | """The configuration level of a configuration file.""" | |
@@ -412,7 +409,7 @@ def release(self) -> None: | |||
| 412 | 409 | try: | |
| 413 | 410 | self.write() | |
| 414 | 411 | except IOError: | |
| 415 | - log.error("Exception during destruction of GitConfigParser", exc_info=True) | ||
| 412 | + _logger.error("Exception during destruction of GitConfigParser", exc_info=True) | ||
| 416 | 413 | except ReferenceError: | |
| 417 | 414 | # This happens in Python 3... and usually means that some state cannot be | |
| 418 | 415 | # written as the sections dict cannot be iterated. This usually happens when | |
@@ -712,7 +709,7 @@ def write(self) -> None: | |||
| 712 | 709 | # END assert multiple files | |
| 713 | 710 | ||
| 714 | 711 | if self._has_includes(): | |
| 715 | - log.debug( | ||
| 712 | + _logger.debug( | ||
| 716 | 713 | "Skipping write-back of configuration file as include files were merged in." | |
| 717 | 714 | + "Set merge_includes=False to prevent this." | |
| 718 | 715 | ) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -52,8 +52,7 @@ | |||
| 52 | 52 | ||
| 53 | 53 | # ------------------------------------------------------------------------ | |
| 54 | 54 | ||
| 55 | - log = logging.getLogger("git.objects.commit") | ||
| 56 | - log.addHandler(logging.NullHandler()) | ||
| 55 | + _logger = logging.getLogger(__name__) | ||
| 57 | 56 | ||
| 58 | 57 | __all__ = ("Commit",) | |
| 59 | 58 | ||
@@ -767,7 +766,7 @@ def _deserialize(self, stream: BytesIO) -> "Commit": | |||
| 767 | 766 | self.author_tz_offset, | |
| 768 | 767 | ) = parse_actor_and_date(author_line.decode(self.encoding, "replace")) | |
| 769 | 768 | except UnicodeDecodeError: | |
| 770 | - log.error( | ||
| 769 | + _logger.error( | ||
| 771 | 770 | "Failed to decode author line '%s' using encoding %s", | |
| 772 | 771 | author_line, | |
| 773 | 772 | self.encoding, | |
@@ -781,7 +780,7 @@ def _deserialize(self, stream: BytesIO) -> "Commit": | |||
| 781 | 780 | self.committer_tz_offset, | |
| 782 | 781 | ) = parse_actor_and_date(committer_line.decode(self.encoding, "replace")) | |
| 783 | 782 | except UnicodeDecodeError: | |
| 784 | - log.error( | ||
| 783 | + _logger.error( | ||
| 785 | 784 | "Failed to decode committer line '%s' using encoding %s", | |
| 786 | 785 | committer_line, | |
| 787 | 786 | self.encoding, | |
@@ -795,7 +794,7 @@ def _deserialize(self, stream: BytesIO) -> "Commit": | |||
| 795 | 794 | try: | |
| 796 | 795 | self.message = self.message.decode(self.encoding, "replace") | |
| 797 | 796 | except UnicodeDecodeError: | |
| 798 | - log.error( | ||
| 797 | + _logger.error( | ||
| 799 | 798 | "Failed to decode message '%s' using encoding %s", | |
| 800 | 799 | self.message, | |
| 801 | 800 | self.encoding, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -40,6 +40,7 @@ | |||
| 40 | 40 | ||
| 41 | 41 | ||
| 42 | 42 | # typing ---------------------------------------------------------------------- | |
| 43 | + | ||
| 43 | 44 | from typing import Callable, Dict, Mapping, Sequence, TYPE_CHECKING, cast | |
| 44 | 45 | from typing import Any, Iterator, Union | |
| 45 | 46 | ||
@@ -50,14 +51,11 @@ | |||
| 50 | 51 | from git.repo import Repo | |
| 51 | 52 | from git.refs import Head | |
| 52 | 53 | ||
| 53 | - | ||
| 54 | 54 | # ----------------------------------------------------------------------------- | |
| 55 | 55 | ||
| 56 | 56 | __all__ = ["Submodule", "UpdateProgress"] | |
| 57 | 57 | ||
| 58 | - | ||
| 59 | - log = logging.getLogger("git.objects.submodule.base") | ||
| 60 | - log.addHandler(logging.NullHandler()) | ||
| 58 | + _logger = logging.getLogger(__name__) | ||
| 61 | 59 | ||
| 62 | 60 | ||
| 63 | 61 | class UpdateProgress(RemoteProgress): | |
@@ -731,7 +729,7 @@ def update( | |||
| 731 | 729 | ) | |
| 732 | 730 | mrepo.head.reference.set_tracking_branch(remote_branch) | |
| 733 | 731 | except (IndexError, InvalidGitRepositoryError): | |
| 734 | - log.warning("Failed to checkout tracking branch %s", self.branch_path) | ||
| 732 | + _logger.warning("Failed to checkout tracking branch %s", self.branch_path) | ||
| 735 | 733 | # END handle tracking branch | |
| 736 | 734 | ||
| 737 | 735 | # NOTE: Have to write the repo config file as well, otherwise the | |
@@ -761,14 +759,14 @@ def update( | |||
| 761 | 759 | binsha = rcommit.binsha | |
| 762 | 760 | hexsha = rcommit.hexsha | |
| 763 | 761 | else: | |
| 764 | - log.error( | ||
| 762 | + _logger.error( | ||
| 765 | 763 | "%s a tracking branch was not set for local branch '%s'", | |
| 766 | 764 | msg_base, | |
| 767 | 765 | mrepo.head.reference, | |
| 768 | 766 | ) | |
| 769 | 767 | # END handle remote ref | |
| 770 | 768 | else: | |
| 771 | - log.error("%s there was no local tracking branch", msg_base) | ||
| 769 | + _logger.error("%s there was no local tracking branch", msg_base) | ||
| 772 | 770 | # END handle detached head | |
| 773 | 771 | # END handle to_latest_revision option | |
| 774 | 772 | ||
@@ -786,15 +784,15 @@ def update( | |||
| 786 | 784 | if force: | |
| 787 | 785 | msg = "Will force checkout or reset on local branch that is possibly in the future of" | |
| 788 | 786 | msg += " the commit it will be checked out to, effectively 'forgetting' new commits" | |
| 789 | - log.debug(msg) | ||
| 787 | + _logger.debug(msg) | ||
| 790 | 788 | else: | |
| 791 | 789 | msg = "Skipping %s on branch '%s' of submodule repo '%s' as it contains un-pushed commits" | |
| 792 | 790 | msg %= ( | |
| 793 | 791 | is_detached and "checkout" or "reset", | |
| 794 | 792 | mrepo.head, | |
| 795 | 793 | mrepo, | |
| 796 | 794 | ) | |
| 797 | - log.info(msg) | ||
| 795 | + _logger.info(msg) | ||
| 798 | 796 | may_reset = False | |
| 799 | 797 | # END handle force | |
| 800 | 798 | # END handle if we are in the future | |
@@ -834,7 +832,7 @@ def update( | |||
| 834 | 832 | except Exception as err: | |
| 835 | 833 | if not keep_going: | |
| 836 | 834 | raise | |
| 837 | - log.error(str(err)) | ||
| 835 | + _logger.error(str(err)) | ||
| 838 | 836 | # END handle keep_going | |
| 839 | 837 | ||
| 840 | 838 | # HANDLE RECURSION | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,8 +22,7 @@ | |||
| 22 | 22 | ||
| 23 | 23 | __all__ = ["RootModule", "RootUpdateProgress"] | |
| 24 | 24 | ||
| 25 | - log = logging.getLogger("git.objects.submodule.root") | ||
| 26 | - log.addHandler(logging.NullHandler()) | ||
| 25 | + _logger = logging.getLogger(__name__) | ||
| 27 | 26 | ||
| 28 | 27 | ||
| 29 | 28 | class RootUpdateProgress(UpdateProgress): | |
@@ -321,7 +320,7 @@ def update( | |||
| 321 | 320 | # this way, it will be checked out in the next step. | |
| 322 | 321 | # This will change the submodule relative to us, so | |
| 323 | 322 | # the user will be able to commit the change easily. | |
| 324 | - log.warning( | ||
| 323 | + _logger.warning( | ||
| 325 | 324 | "Current sha %s was not contained in the tracking\ | |
| 326 | 325 | branch at the new remote, setting it the the remote's tracking branch", | |
| 327 | 326 | sm.hexsha, | |
@@ -393,7 +392,7 @@ def update( | |||
| 393 | 392 | except Exception as err: | |
| 394 | 393 | if not keep_going: | |
| 395 | 394 | raise | |
| 396 | - log.error(str(err)) | ||
| 395 | + _logger.error(str(err)) | ||
| 397 | 396 | # END handle keep_going | |
| 398 | 397 | ||
| 399 | 398 | # FINALLY UPDATE ALL ACTUAL SUBMODULES | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -58,10 +58,7 @@ | |||
| 58 | 58 | ||
| 59 | 59 | # ------------------------------------------------------------- | |
| 60 | 60 | ||
| 61 | - | ||
| 62 | - log = logging.getLogger("git.remote") | ||
| 63 | - log.addHandler(logging.NullHandler()) | ||
| 64 | - | ||
| 61 | + _logger = logging.getLogger(__name__) | ||
| 65 | 62 | ||
| 66 | 63 | __all__ = ("RemoteProgress", "PushInfo", "FetchInfo", "Remote") | |
| 67 | 64 | ||
@@ -846,7 +843,7 @@ def _get_fetch_info_from_stderr( | |||
| 846 | 843 | stderr_text = progress.error_lines and "\n".join(progress.error_lines) or "" | |
| 847 | 844 | proc.wait(stderr=stderr_text) | |
| 848 | 845 | if stderr_text: | |
| 849 | - log.warning("Error lines received while fetching: %s", stderr_text) | ||
| 846 | + _logger.warning("Error lines received while fetching: %s", stderr_text) | ||
| 850 | 847 | ||
| 851 | 848 | for line in progress.other_lines: | |
| 852 | 849 | line = force_text(line) | |
@@ -867,9 +864,9 @@ def _get_fetch_info_from_stderr( | |||
| 867 | 864 | msg += "length of progress lines %i should be equal to lines in FETCH_HEAD file %i\n" | |
| 868 | 865 | msg += "Will ignore extra progress lines or fetch head lines." | |
| 869 | 866 | msg %= (l_fil, l_fhi) | |
| 870 | - log.debug(msg) | ||
| 871 | - log.debug(b"info lines: " + str(fetch_info_lines).encode("UTF-8")) | ||
| 872 | - log.debug(b"head info: " + str(fetch_head_info).encode("UTF-8")) | ||
| 867 | + _logger.debug(msg) | ||
| 868 | + _logger.debug(b"info lines: " + str(fetch_info_lines).encode("UTF-8")) | ||
| 869 | + _logger.debug(b"head info: " + str(fetch_head_info).encode("UTF-8")) | ||
| 873 | 870 | if l_fil < l_fhi: | |
| 874 | 871 | fetch_head_info = fetch_head_info[:l_fil] | |
| 875 | 872 | else: | |
@@ -881,8 +878,8 @@ def _get_fetch_info_from_stderr( | |||
| 881 | 878 | try: | |
| 882 | 879 | output.append(FetchInfo._from_line(self.repo, err_line, fetch_line)) | |
| 883 | 880 | except ValueError as exc: | |
| 884 | - log.debug("Caught error while parsing line: %s", exc) | ||
| 885 | - log.warning("Git informed while fetching: %s", err_line.strip()) | ||
| 881 | + _logger.debug("Caught error while parsing line: %s", exc) | ||
| 882 | + _logger.warning("Git informed while fetching: %s", err_line.strip()) | ||
| 886 | 883 | return output | |
| 887 | 884 | ||
| 888 | 885 | def _get_push_info( | |
@@ -924,7 +921,7 @@ def stdout_handler(line: str) -> None: | |||
| 924 | 921 | if not output: | |
| 925 | 922 | raise | |
| 926 | 923 | elif stderr_text: | |
| 927 | - log.warning("Error lines received while fetching: %s", stderr_text) | ||
| 924 | + _logger.warning("Error lines received while fetching: %s", stderr_text) | ||
| 928 | 925 | output.error = e | |
| 929 | 926 | ||
| 930 | 927 | return output | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -89,7 +89,7 @@ | |||
| 89 | 89 | ||
| 90 | 90 | # ----------------------------------------------------------- | |
| 91 | 91 | ||
| 92 | - log = logging.getLogger(__name__) | ||
| 92 | + _logger = logging.getLogger(__name__) | ||
| 93 | 93 | ||
| 94 | 94 | __all__ = ("Repo",) | |
| 95 | 95 | ||
@@ -772,7 +772,7 @@ def is_valid_object(self, sha: str, object_type: Union[str, None] = None) -> boo | |||
| 772 | 772 | if object_info.type == object_type.encode(): | |
| 773 | 773 | return True | |
| 774 | 774 | else: | |
| 775 | - log.debug( | ||
| 775 | + _logger.debug( | ||
| 776 | 776 | "Commit hash points to an object of type '%s'. Requested were objects of type '%s'", | |
| 777 | 777 | object_info.type.decode(), | |
| 778 | 778 | object_type, | |
@@ -781,7 +781,7 @@ def is_valid_object(self, sha: str, object_type: Union[str, None] = None) -> boo | |||
| 781 | 781 | else: | |
| 782 | 782 | return True | |
| 783 | 783 | except BadObject: | |
| 784 | - log.debug("Commit hash is invalid.") | ||
| 784 | + _logger.debug("Commit hash is invalid.") | ||
| 785 | 785 | return False | |
| 786 | 786 | ||
| 787 | 787 | def _get_daemon_export(self) -> bool: | |
@@ -1298,7 +1298,7 @@ def _clone( | |||
| 1298 | 1298 | cmdline = getattr(proc, "args", "") | |
| 1299 | 1299 | cmdline = remove_password_if_present(cmdline) | |
| 1300 | 1300 | ||
| 1301 | - log.debug("Cmd(%s)'s unused stdout: %s", cmdline, stdout) | ||
| 1301 | + _logger.debug("Cmd(%s)'s unused stdout: %s", cmdline, stdout) | ||
| 1302 | 1302 | finalize_process(proc, stderr=stderr) | |
| 1303 | 1303 | ||
| 1304 | 1304 | # Our git command could have a different working dir than our actual | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -104,7 +104,7 @@ | |||
| 104 | 104 | "HIDE_WINDOWS_KNOWN_ERRORS", | |
| 105 | 105 | ] | |
| 106 | 106 | ||
| 107 | - log = logging.getLogger(__name__) | ||
| 107 | + _logger = logging.getLogger(__name__) | ||
| 108 | 108 | ||
| 109 | 109 | ||
| 110 | 110 | def _read_win_env_flag(name: str, default: bool) -> bool: | |
@@ -124,7 +124,7 @@ def _read_win_env_flag(name: str, default: bool) -> bool: | |||
| 124 | 124 | except KeyError: | |
| 125 | 125 | return default | |
| 126 | 126 | ||
| 127 | - log.warning( | ||
| 127 | + _logger.warning( | ||
| 128 | 128 | "The %s environment variable is deprecated. Its effect has never been documented and changes without warning.", | |
| 129 | 129 | name, | |
| 130 | 130 | ) | |
@@ -135,7 +135,7 @@ def _read_win_env_flag(name: str, default: bool) -> bool: | |||
| 135 | 135 | return False | |
| 136 | 136 | if adjusted_value in {"1", "true", "yes"}: | |
| 137 | 137 | return True | |
| 138 | - log.warning("%s has unrecognized value %r, treating as %r.", name, value, default) | ||
| 138 | + _logger.warning("%s has unrecognized value %r, treating as %r.", name, value, default) | ||
| 139 | 139 | return default | |
| 140 | 140 | ||
| 141 | 141 | ||
@@ -466,7 +466,7 @@ def is_cygwin_git(git_executable: Union[None, PathLike]) -> bool: | |||
| 466 | 466 | # retcode = process.poll() | |
| 467 | 467 | is_cygwin = "CYGWIN" in uname_out | |
| 468 | 468 | except Exception as ex: | |
| 469 | - log.debug("Failed checking if running in CYGWIN due to: %r", ex) | ||
| 469 | + _logger.debug("Failed checking if running in CYGWIN due to: %r", ex) | ||
| 470 | 470 | _is_cygwin_cache[git_executable] = is_cygwin | |
| 471 | 471 | ||
| 472 | 472 | return is_cygwin | |
| Back | FazBrowse Home | New Git URL |
0 commit comments