MCPcopy
hub / github.com/timbrel/GitSavvy / git

Method git

core/git_command.py:229–397  ·  view source on GitHub ↗

Run the git command specified in `*args` and return the output of the git command as a string. If stdin is provided, it should be a string and will be piped to the git process. If `working_dir` is provided, set this as the current working directory for the

(
        self,
        git_cmd,
        *args,  # type: Optional[str]
        stdin=None,
        working_dir=None,
        show_panel=None,
        show_panel_on_error=True,
        throw_on_error=True,
        decode=True,
        stdin_encoding="utf-8",
        custom_environ=None,
        just_the_proc=False,
        timeout=NOT_SET
    )

Source from the content-addressed store, hash-verified

227 """
228
229 def git(
230 self,
231 git_cmd,
232 *args, # type: Optional[str]
233 stdin=None,
234 working_dir=None,
235 show_panel=None,
236 show_panel_on_error=True,
237 throw_on_error=True,
238 decode=True,
239 stdin_encoding="utf-8",
240 custom_environ=None,
241 just_the_proc=False,
242 timeout=NOT_SET
243 ):
244 """
245 Run the git command specified in `*args` and return the output
246 of the git command as a string.
247
248 If stdin is provided, it should be a string and will be piped to
249 the git process. If `working_dir` is provided, set this as the
250 current working directory for the git process; otherwise,
251 the `repo_path` value will be used.
252 """
253 if timeout == NOT_SET:
254 try:
255 timeout = auto_timeout.value
256 except AttributeError:
257 timeout = DEFAULT_TIMEOUT
258 window = self.some_window()
259 final_args = self._add_global_flags(git_cmd, list(args))
260 command = [self.git_binary_path] + list(filter_(final_args))
261 command_str = util.debug.pretty_git_command(command[1:])
262
263 if show_panel is None:
264 show_panel = git_cmd in self.savvy_settings.get("show_panel_for")
265
266 if show_panel:
267 panel = util.log.init_panel(window)
268 log = partial(util.log.append_to_panel, panel)
269 log("$ {}\n".format(command_str))
270
271 if not working_dir:
272 try:
273 working_dir = self.repo_path
274 except DetachedView as e:
275 # do not show panel when the window does not exist
276 GitSavvyError(str(e), show_panel=False, window=window) # just for logging
277 raise
278 except Exception as e:
279 raise GitSavvyError(str(e), show_panel=show_panel_on_error, window=window)
280
281 stdout, stderr = None, None
282 vars_for_replace = ChainMap(
283 custom_environ or {},
284 window.extract_variables(),
285 os.environ
286 )

Callers 15

git_throwing_silentlyMethod · 0.95
on_entered_nameMethod · 0.80
on_entered_messageMethod · 0.80
run_asyncMethod · 0.80
cherry_pickMethod · 0.80
revert_commitMethod · 0.80
copy_shaMethod · 0.80
do_actionMethod · 0.80
runMethod · 0.80
runMethod · 0.80
runMethod · 0.80
runMethod · 0.80

Calls 7

_add_global_flagsMethod · 0.95
strict_decodeMethod · 0.95
ensure_decodedMethod · 0.95
GitSavvyErrorClass · 0.85
communicate_and_logFunction · 0.85
some_windowMethod · 0.80
getMethod · 0.45

Tested by 15

test_fetch_allMethod · 0.64
test_fetch_remoteMethod · 0.64
test_fetch_branchMethod · 0.64
test_invalid_callsMethod · 0.64
test_local_branchMethod · 0.64
test_remote_branchMethod · 0.64
test_tracking_statusMethod · 0.64
init_repoMethod · 0.64