| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + github: byron | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,7 @@ The following is a short step-by-step rundown of what one typically would do to | |||
| 5 | 5 | * [fork this project](https://github.com/gitpython-developers/GitPython/fork) on GitHub. | |
| 6 | 6 | * For setting up the environment to run the self tests, please look at `.travis.yml`. | |
| 7 | 7 | * Please try to **write a test that fails unless the contribution is present.** | |
| 8 | - * Feel free to add yourself to AUTHORS file. | ||
| 8 | + * Try to avoid massive commits and prefer to take small steps, with one commit for each. | ||
| 9 | + * Feel free to add yourself to AUTHORS file. | ||
| 9 | 10 | * Create a pull request. | |
| 10 | 11 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,10 +1,11 @@ | |||
| 1 | - include VERSION | ||
| 2 | - include LICENSE | ||
| 3 | - include CHANGES | ||
| 4 | 1 | include AUTHORS | |
| 2 | + include CHANGES | ||
| 5 | 3 | include CONTRIBUTING.md | |
| 4 | + include LICENSE | ||
| 6 | 5 | include README.md | |
| 6 | + include VERSION | ||
| 7 | 7 | include requirements.txt | |
| 8 | + include test-requirements.txt | ||
| 8 | 9 | ||
| 9 | 10 | recursive-include doc * | |
| 10 | 11 | recursive-exclude test * | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,7 +15,7 @@ release: clean | |||
| 15 | 15 | make force_release | |
| 16 | 16 | ||
| 17 | 17 | force_release: clean | |
| 18 | - git push --tags origin master | ||
| 18 | + git push --tags origin main | ||
| 19 | 19 | python3 setup.py sdist bdist_wheel | |
| 20 | 20 | twine upload -s -i 27C50E7F590947D7273A741E85194C08421980C9 dist/* | |
| 21 | 21 | ||
@@ -24,7 +24,7 @@ docker-build: | |||
| 24 | 24 | ||
| 25 | 25 | test: docker-build | |
| 26 | 26 | # NOTE!!! | |
| 27 | - # NOTE!!! If you are not running from master or have local changes then tests will fail | ||
| 27 | + # NOTE!!! If you are not running from main or have local changes then tests will fail | ||
| 28 | 28 | # NOTE!!! | |
| 29 | 29 | docker run --rm -v ${CURDIR}:/src -w /src -t gitpython:xenial tox | |
| 30 | 30 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1 +1 @@ | |||
| 1 | - 3.1.13 | ||
| 1 | + 3.1.15 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,14 +2,25 @@ | |||
| 2 | 2 | Changelog | |
| 3 | 3 | ========= | |
| 4 | 4 | ||
| 5 | - 3.1.?? | ||
| 5 | + 3.1.15 | ||
| 6 | + ====== | ||
| 7 | + | ||
| 8 | + * add deprectation warning for python 3.5 | ||
| 9 | + | ||
| 10 | + See the following for details: | ||
| 11 | + https://github.com/gitpython-developers/gitpython/milestone/47?closed=1 | ||
| 12 | + | ||
| 13 | + 3.1.14 | ||
| 6 | 14 | ====== | |
| 7 | 15 | ||
| 8 | 16 | * git.Commit objects now have a ``replace`` method that will return a | |
| 9 | 17 | copy of the commit with modified attributes. | |
| 10 | 18 | * Add python 3.9 support | |
| 11 | 19 | * Drop python 3.4 support | |
| 12 | 20 | ||
| 21 | + See the following for details: | ||
| 22 | + https://github.com/gitpython-developers/gitpython/milestone/46?closed=1 | ||
| 23 | + | ||
| 13 | 24 | 3.1.13 | |
| 14 | 25 | ====== | |
| 15 | 26 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,7 @@ | |||
| 5 | 5 | # the BSD License: http://www.opensource.org/licenses/bsd-license.php | |
| 6 | 6 | # flake8: noqa | |
| 7 | 7 | #@PydevCodeAnalysisIgnore | |
| 8 | + from git.exc import * # @NoMove @IgnorePep8 | ||
| 8 | 9 | import inspect | |
| 9 | 10 | import os | |
| 10 | 11 | import sys | |
@@ -16,8 +17,6 @@ | |||
| 16 | 17 | __version__ = 'git' | |
| 17 | 18 | ||
| 18 | 19 | ||
| 19 | - | ||
| 20 | - | ||
| 21 | 20 | #{ Initialization | |
| 22 | 21 | def _init_externals() -> None: | |
| 23 | 22 | """Initialize external projects by putting them into the path""" | |
@@ -32,13 +31,13 @@ def _init_externals() -> None: | |||
| 32 | 31 | ||
| 33 | 32 | #} END initialization | |
| 34 | 33 | ||
| 34 | + | ||
| 35 | 35 | ################# | |
| 36 | 36 | _init_externals() | |
| 37 | 37 | ################# | |
| 38 | 38 | ||
| 39 | 39 | #{ Imports | |
| 40 | 40 | ||
| 41 | - from git.exc import * # @NoMove @IgnorePep8 | ||
| 42 | 41 | try: | |
| 43 | 42 | from git.config import GitConfigParser # @NoMove @IgnorePep8 | |
| 44 | 43 | from git.objects import * # @NoMove @IgnorePep8 | |
@@ -68,7 +67,8 @@ def _init_externals() -> None: | |||
| 68 | 67 | #{ Initialize git executable path | |
| 69 | 68 | GIT_OK = None | |
| 70 | 69 | ||
| 71 | - def refresh(path:Optional[PathLike]=None) -> None: | ||
| 70 | + | ||
| 71 | + def refresh(path: Optional[PathLike] = None) -> None: | ||
| 72 | 72 | """Convenience method for setting the git executable path.""" | |
| 73 | 73 | global GIT_OK | |
| 74 | 74 | GIT_OK = False | |
@@ -81,6 +81,7 @@ def refresh(path:Optional[PathLike]=None) -> None: | |||
| 81 | 81 | GIT_OK = True | |
| 82 | 82 | #} END initialize git executable path | |
| 83 | 83 | ||
| 84 | + | ||
| 84 | 85 | ################# | |
| 85 | 86 | try: | |
| 86 | 87 | refresh() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,7 +19,7 @@ | |||
| 19 | 19 | import threading | |
| 20 | 20 | from collections import OrderedDict | |
| 21 | 21 | from textwrap import dedent | |
| 22 | - from typing import Any, Dict, List, Optional | ||
| 22 | + import warnings | ||
| 23 | 23 | ||
| 24 | 24 | from git.compat import ( | |
| 25 | 25 | defenc, | |
@@ -29,7 +29,7 @@ | |||
| 29 | 29 | is_win, | |
| 30 | 30 | ) | |
| 31 | 31 | from git.exc import CommandError | |
| 32 | - from git.util import is_cygwin_git, cygpath, expand_path | ||
| 32 | + from git.util import is_cygwin_git, cygpath, expand_path, remove_password_if_present | ||
| 33 | 33 | ||
| 34 | 34 | from .exc import ( | |
| 35 | 35 | GitCommandError, | |
@@ -40,8 +40,6 @@ | |||
| 40 | 40 | stream_copy, | |
| 41 | 41 | ) | |
| 42 | 42 | ||
| 43 | - from .types import PathLike | ||
| 44 | - | ||
| 45 | 43 | execute_kwargs = {'istream', 'with_extended_output', | |
| 46 | 44 | 'with_exceptions', 'as_process', 'stdout_as_string', | |
| 47 | 45 | 'output_stream', 'with_stdout', 'kill_after_timeout', | |
@@ -85,8 +83,8 @@ def pump_stream(cmdline, name, stream, is_decode, handler): | |||
| 85 | 83 | line = line.decode(defenc) | |
| 86 | 84 | handler(line) | |
| 87 | 85 | except Exception as ex: | |
| 88 | - log.error("Pumping %r of cmd(%s) failed due to: %r", name, cmdline, ex) | ||
| 89 | - raise CommandError(['<%s-pump>' % name] + cmdline, ex) from ex | ||
| 86 | + log.error("Pumping %r of cmd(%s) failed due to: %r", name, remove_password_if_present(cmdline), ex) | ||
| 87 | + raise CommandError(['<%s-pump>' % name] + remove_password_if_present(cmdline), ex) from ex | ||
| 90 | 88 | finally: | |
| 91 | 89 | stream.close() | |
| 92 | 90 | ||
@@ -105,7 +103,7 @@ def pump_stream(cmdline, name, stream, is_decode, handler): | |||
| 105 | 103 | for name, stream, handler in pumps: | |
| 106 | 104 | t = threading.Thread(target=pump_stream, | |
| 107 | 105 | args=(cmdline, name, stream, decode_streams, handler)) | |
| 108 | - t.setDaemon(True) | ||
| 106 | + t.daemon = True | ||
| 109 | 107 | t.start() | |
| 110 | 108 | threads.append(t) | |
| 111 | 109 | ||
@@ -140,7 +138,7 @@ def dict_to_slots_and__excluded_are_none(self, d, excluded=()): | |||
| 140 | 138 | ||
| 141 | 139 | ## CREATE_NEW_PROCESS_GROUP is needed to allow killing it afterwards, | |
| 142 | 140 | # see https://docs.python.org/3/library/subprocess.html#subprocess.Popen.send_signal | |
| 143 | - PROC_CREATIONFLAGS = (CREATE_NO_WINDOW | subprocess.CREATE_NEW_PROCESS_GROUP | ||
| 141 | + PROC_CREATIONFLAGS = (CREATE_NO_WINDOW | subprocess.CREATE_NEW_PROCESS_GROUP # type: ignore[attr-defined] | ||
| 144 | 142 | if is_win else 0) | |
| 145 | 143 | ||
| 146 | 144 | ||
@@ -212,7 +210,7 @@ def refresh(cls, path=None): | |||
| 212 | 210 | # - a GitCommandNotFound error is spawned by ourselves | |
| 213 | 211 | # - a PermissionError is spawned if the git executable provided | |
| 214 | 212 | # cannot be executed for whatever reason | |
| 215 | - | ||
| 213 | + | ||
| 216 | 214 | has_git = False | |
| 217 | 215 | try: | |
| 218 | 216 | cls().version() | |
@@ -408,7 +406,7 @@ def read_all_from_possibly_closed_stream(stream): | |||
| 408 | 406 | if status != 0: | |
| 409 | 407 | errstr = read_all_from_possibly_closed_stream(self.proc.stderr) | |
| 410 | 408 | log.debug('AutoInterrupt wait stderr: %r' % (errstr,)) | |
| 411 | - raise GitCommandError(self.args, status, errstr) | ||
| 409 | + raise GitCommandError(remove_password_if_present(self.args), status, errstr) | ||
| 412 | 410 | # END status handling | |
| 413 | 411 | return status | |
| 414 | 412 | # END auto interrupt | |
@@ -500,7 +498,7 @@ def readlines(self, size=-1): | |||
| 500 | 498 | # skipcq: PYL-E0301 | |
| 501 | 499 | def __iter__(self): | |
| 502 | 500 | return self | |
| 503 | - | ||
| 501 | + | ||
| 504 | 502 | def __next__(self): | |
| 505 | 503 | return self.next() | |
| 506 | 504 | ||
@@ -519,7 +517,7 @@ def __del__(self): | |||
| 519 | 517 | self._stream.read(bytes_left + 1) | |
| 520 | 518 | # END handle incomplete read | |
| 521 | 519 | ||
| 522 | - def __init__(self, working_dir: Optional[PathLike]=None) -> None: | ||
| 520 | + def __init__(self, working_dir=None): | ||
| 523 | 521 | """Initialize this instance with: | |
| 524 | 522 | ||
| 525 | 523 | :param working_dir: | |
@@ -528,12 +526,12 @@ def __init__(self, working_dir: Optional[PathLike]=None) -> None: | |||
| 528 | 526 | It is meant to be the working tree directory if available, or the | |
| 529 | 527 | .git directory in case of bare repositories.""" | |
| 530 | 528 | super(Git, self).__init__() | |
| 531 | - self._working_dir = expand_path(working_dir) if working_dir is not None else None | ||
| 529 | + self._working_dir = expand_path(working_dir) | ||
| 532 | 530 | self._git_options = () | |
| 533 | - self._persistent_git_options = [] # type: List[str] | ||
| 531 | + self._persistent_git_options = [] | ||
| 534 | 532 | ||
| 535 | 533 | # Extra environment variables to pass to git commands | |
| 536 | - self._environment = {} # type: Dict[str, Any] | ||
| 534 | + self._environment = {} | ||
| 537 | 535 | ||
| 538 | 536 | # cached command slots | |
| 539 | 537 | self.cat_file_header = None | |
@@ -547,7 +545,7 @@ def __getattr__(self, name): | |||
| 547 | 545 | return LazyMixin.__getattr__(self, name) | |
| 548 | 546 | return lambda *args, **kwargs: self._call_process(name, *args, **kwargs) | |
| 549 | 547 | ||
| 550 | - def set_persistent_git_options(self, **kwargs) -> None: | ||
| 548 | + def set_persistent_git_options(self, **kwargs): | ||
| 551 | 549 | """Specify command line options to the git executable | |
| 552 | 550 | for subsequent subcommand calls | |
| 553 | 551 | ||
@@ -641,7 +639,7 @@ def execute(self, command, | |||
| 641 | 639 | ||
| 642 | 640 | :param env: | |
| 643 | 641 | A dictionary of environment variables to be passed to `subprocess.Popen`. | |
| 644 | - | ||
| 642 | + | ||
| 645 | 643 | :param max_chunk_size: | |
| 646 | 644 | Maximum number of bytes in one chunk of data passed to the output_stream in | |
| 647 | 645 | one invocation of write() method. If the given number is not positive then | |
@@ -685,8 +683,10 @@ def execute(self, command, | |||
| 685 | 683 | :note: | |
| 686 | 684 | If you add additional keyword arguments to the signature of this method, | |
| 687 | 685 | you must update the execute_kwargs tuple housed in this module.""" | |
| 686 | + # Remove password for the command if present | ||
| 687 | + redacted_command = remove_password_if_present(command) | ||
| 688 | 688 | if self.GIT_PYTHON_TRACE and (self.GIT_PYTHON_TRACE != 'full' or as_process): | |
| 689 | - log.info(' '.join(command)) | ||
| 689 | + log.info(' '.join(redacted_command)) | ||
| 690 | 690 | ||
| 691 | 691 | # Allow the user to have the command executed in their working dir. | |
| 692 | 692 | cwd = self._working_dir or os.getcwd() | |
@@ -707,7 +707,7 @@ def execute(self, command, | |||
| 707 | 707 | if is_win: | |
| 708 | 708 | cmd_not_found_exception = OSError | |
| 709 | 709 | if kill_after_timeout: | |
| 710 | - raise GitCommandError(command, '"kill_after_timeout" feature is not supported on Windows.') | ||
| 710 | + raise GitCommandError(redacted_command, '"kill_after_timeout" feature is not supported on Windows.') | ||
| 711 | 711 | else: | |
| 712 | 712 | if sys.version_info[0] > 2: | |
| 713 | 713 | cmd_not_found_exception = FileNotFoundError # NOQA # exists, flake8 unknown @UndefinedVariable | |
@@ -722,7 +722,7 @@ def execute(self, command, | |||
| 722 | 722 | if istream: | |
| 723 | 723 | istream_ok = "<valid stream>" | |
| 724 | 724 | log.debug("Popen(%s, cwd=%s, universal_newlines=%s, shell=%s, istream=%s)", | |
| 725 | - command, cwd, universal_newlines, shell, istream_ok) | ||
| 725 | + redacted_command, cwd, universal_newlines, shell, istream_ok) | ||
| 726 | 726 | try: | |
| 727 | 727 | proc = Popen(command, | |
| 728 | 728 | env=env, | |
@@ -738,7 +738,7 @@ def execute(self, command, | |||
| 738 | 738 | **subprocess_kwargs | |
| 739 | 739 | ) | |
| 740 | 740 | except cmd_not_found_exception as err: | |
| 741 | - raise GitCommandNotFound(command, err) from err | ||
| 741 | + raise GitCommandNotFound(redacted_command, err) from err | ||
| 742 | 742 | ||
| 743 | 743 | if as_process: | |
| 744 | 744 | return self.AutoInterrupt(proc, command) | |
@@ -788,7 +788,7 @@ def _kill_process(pid): | |||
| 788 | 788 | watchdog.cancel() | |
| 789 | 789 | if kill_check.isSet(): | |
| 790 | 790 | stderr_value = ('Timeout: the command "%s" did not complete in %d ' | |
| 791 | - 'secs.' % (" ".join(command), kill_after_timeout)) | ||
| 791 | + 'secs.' % (" ".join(redacted_command), kill_after_timeout)) | ||
| 792 | 792 | if not universal_newlines: | |
| 793 | 793 | stderr_value = stderr_value.encode(defenc) | |
| 794 | 794 | # strip trailing "\n" | |
@@ -812,7 +812,7 @@ def _kill_process(pid): | |||
| 812 | 812 | proc.stderr.close() | |
| 813 | 813 | ||
| 814 | 814 | if self.GIT_PYTHON_TRACE == 'full': | |
| 815 | - cmdstr = " ".join(command) | ||
| 815 | + cmdstr = " ".join(redacted_command) | ||
| 816 | 816 | ||
| 817 | 817 | def as_text(stdout_value): | |
| 818 | 818 | return not output_stream and safe_decode(stdout_value) or '<OUTPUT_STREAM>' | |
@@ -828,7 +828,7 @@ def as_text(stdout_value): | |||
| 828 | 828 | # END handle debug printing | |
| 829 | 829 | ||
| 830 | 830 | if with_exceptions and status != 0: | |
| 831 | - raise GitCommandError(command, status, stderr_value, stdout_value) | ||
| 831 | + raise GitCommandError(redacted_command, status, stderr_value, stdout_value) | ||
| 832 | 832 | ||
| 833 | 833 | if isinstance(stdout_value, bytes) and stdout_as_string: # could also be output_stream | |
| 834 | 834 | stdout_value = safe_decode(stdout_value) | |
@@ -905,8 +905,14 @@ def transform_kwarg(self, name, value, split_single_char_options): | |||
| 905 | 905 | ||
| 906 | 906 | def transform_kwargs(self, split_single_char_options=True, **kwargs): | |
| 907 | 907 | """Transforms Python style kwargs into git command line options.""" | |
| 908 | + # Python 3.6 preserves the order of kwargs and thus has a stable | ||
| 909 | + # order. For older versions sort the kwargs by the key to get a stable | ||
| 910 | + # order. | ||
| 911 | + if sys.version_info[:2] < (3, 6): | ||
| 912 | + kwargs = OrderedDict(sorted(kwargs.items(), key=lambda x: x[0])) | ||
| 913 | + warnings.warn("Python 3.5 support is deprecated and will be removed 2021-09-05.\n" + | ||
| 914 | + "It does not preserve the order for key-word arguments and enforce lexical sorting instead.") | ||
| 908 | 915 | args = [] | |
| 909 | - kwargs = OrderedDict(sorted(kwargs.items(), key=lambda x: x[0])) | ||
| 910 | 916 | for k, v in kwargs.items(): | |
| 911 | 917 | if isinstance(v, (list, tuple)): | |
| 912 | 918 | for value in v: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments