| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,6 +8,9 @@ | |||
| 8 | 8 | # Enables debugging of GitPython's git commands | |
| 9 | 9 | GIT_PYTHON_TRACE = os.environ.get("GIT_PYTHON_TRACE", False) | |
| 10 | 10 | ||
| 11 | + execute_kwargs = ('istream', 'with_keep_cwd', 'with_extended_output', | ||
| 12 | + 'with_exceptions', 'with_raw_output') | ||
| 13 | + | ||
| 11 | 14 | class Git(MethodMissingMixin): | |
| 12 | 15 | """ | |
| 13 | 16 | The Git class manages communication with the Git binary | |
@@ -77,9 +80,8 @@ def get_dir(self): | |||
| 77 | 80 | ||
| 78 | 81 | def execute(self, command, | |
| 79 | 82 | istream=None, | |
| 80 | - keep_cwd=False, | ||
| 81 | - extended_output=False, | ||
| 82 | - with_stderr=False, | ||
| 83 | + with_keep_cwd=False, | ||
| 84 | + with_extended_output=False, | ||
| 83 | 85 | with_exceptions=True, | |
| 84 | 86 | with_raw_output=False, | |
| 85 | 87 | ): | |
@@ -93,12 +95,12 @@ def execute(self, command, | |||
| 93 | 95 | ``istream`` | |
| 94 | 96 | Standard input filehandle passed to subprocess.Popen. | |
| 95 | 97 | ||
| 96 | - ``keep_cwd`` | ||
| 98 | + ``with_keep_cwd`` | ||
| 97 | 99 | Whether to use the current working directory from os.getcwd(). | |
| 98 | 100 | GitPython uses get_work_tree() as its working directory by | |
| 99 | 101 | default and get_git_dir() for bare repositories. | |
| 100 | 102 | ||
| 101 | - ``extended_output`` | ||
| 103 | + ``with_extended_output`` | ||
| 102 | 104 | Whether to return a (status, stdout, stderr) tuple. | |
| 103 | 105 | ||
| 104 | 106 | ``with_exceptions`` | |
@@ -116,7 +118,7 @@ def execute(self, command, | |||
| 116 | 118 | print ' '.join(command) | |
| 117 | 119 | ||
| 118 | 120 | # Allow the user to have the command executed in their working dir. | |
| 119 | - if keep_cwd: | ||
| 121 | + if with_keep_cwd: | ||
| 120 | 122 | cwd = os.getcwd() | |
| 121 | 123 | else: | |
| 122 | 124 | cwd=self._cwd | |
@@ -143,10 +145,7 @@ def execute(self, command, | |||
| 143 | 145 | stdout_value = stdout_value.rstrip() | |
| 144 | 146 | stderr_value = stderr_value.rstrip() | |
| 145 | 147 | ||
| 146 | - print command, status | ||
| 147 | - | ||
| 148 | 148 | if with_exceptions and status != 0: | |
| 149 | - print 19 | ||
| 150 | 149 | raise GitCommandError(command, status, stderr_value) | |
| 151 | 150 | ||
| 152 | 151 | if GIT_PYTHON_TRACE == 'full': | |
@@ -158,7 +157,7 @@ def execute(self, command, | |||
| 158 | 157 | print "%s -> %d" % (command, status) | |
| 159 | 158 | ||
| 160 | 159 | # Allow access to the command's status code | |
| 161 | - if extended_output: | ||
| 160 | + if with_extended_output: | ||
| 162 | 161 | return (status, stdout_value, stderr_value) | |
| 163 | 162 | else: | |
| 164 | 163 | return stdout_value | |
@@ -206,12 +205,12 @@ def method_missing(self, method, *args, **kwargs): | |||
| 206 | 205 | ||
| 207 | 206 | # Handle optional arguments prior to calling transform_kwargs | |
| 208 | 207 | # otherwise these'll end up in args, which is bad. | |
| 209 | - istream = kwargs.pop("istream", None) | ||
| 210 | - keep_cwd = kwargs.pop("keep_cwd", None) | ||
| 211 | - extended_output = kwargs.pop("extended_output", None) | ||
| 212 | - with_stderr = kwargs.pop("with_stderr", None) | ||
| 213 | - with_exceptions = kwargs.pop("with_exceptions", True) | ||
| 214 | - with_raw_output = kwargs.pop("with_raw_output", None) | ||
| 208 | + _kwargs = {} | ||
| 209 | + for kwarg in execute_kwargs: | ||
| 210 | + try: | ||
| 211 | + _kwargs[kwarg] = kwargs.pop(kwarg) | ||
| 212 | + except KeyError: | ||
| 213 | + pass | ||
| 215 | 214 | ||
| 216 | 215 | # Prepare the argument list | |
| 217 | 216 | opt_args = self.transform_kwargs(**kwargs) | |
@@ -221,11 +220,4 @@ def method_missing(self, method, *args, **kwargs): | |||
| 221 | 220 | call = ["git", dashify(method)] | |
| 222 | 221 | call.extend(args) | |
| 223 | 222 | ||
| 224 | - return self.execute(call, | ||
| 225 | - istream = istream, | ||
| 226 | - keep_cwd = keep_cwd, | ||
| 227 | - extended_output = extended_output, | ||
| 228 | - with_stderr = with_stderr, | ||
| 229 | - with_exceptions = with_exceptions, | ||
| 230 | - with_raw_output = with_raw_output, | ||
| 231 | - ) | ||
| 223 | + return self.execute(call, **_kwargs) | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments