Skip to content

Commit 410cf1e

Browse files
committed
The --progress flag will now automatically be used if possible when doing any push or fetch operation
1 parent fd5c46e commit 410cf1e

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

git/db/cmd/base.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,16 @@ def get_push_info(repo, remotename_or_url, proc, progress):
141141
finalize_process(proc)
142142
return output
143143

144+
def add_progress(kwargs, git):
145+
"""Add the --progress flag to the given kwargs dict if supported by the
146+
git command
147+
:return: possibly altered kwargs"""
148+
v = git.version_info
149+
if v[0] > 1 or v[1] > 7 or v[2] > 0 or v[3] > 3:
150+
kwargs['progress'] = True
151+
#END handle --progress
152+
return kwargs
153+
144154
#} END utilities
145155

146156
class CmdRemoteProgress(RemoteProgress):
@@ -517,7 +527,7 @@ def push(self, url, refspecs=None, progress=None, **kwargs):
517527
:param refspecs: single string, RefSpec instance or list of such or None.
518528
:param progress: RemoteProgress derived instance or None
519529
:param **kwargs: Additional arguments to be passed to the git-push process"""
520-
proc = self._git.push(url, refspecs, porcelain=True, as_process=True, **kwargs)
530+
proc = self._git.push(url, refspecs, porcelain=True, as_process=True, **add_progress(kwargs, self.git))
521531
return get_push_info(self, url, proc, CmdRemoteProgress(progress))
522532

523533
def pull(self, url, refspecs=None, progress=None, **kwargs):
@@ -527,15 +537,15 @@ def pull(self, url, refspecs=None, progress=None, **kwargs):
527537
:param url: may be a remote name or a url
528538
:param refspecs: see push()
529539
:param progress: see push()"""
530-
proc = self._git.pull(url, refspecs, with_extended_output=True, as_process=True, v=True, **kwargs)
540+
proc = self._git.pull(url, refspecs, with_extended_output=True, as_process=True, v=True, **add_progress(kwargs, self.git))
531541
return get_fetch_info_from_stderr(self, proc, CmdRemoteProgress(progress))
532542

533543
def fetch(self, url, refspecs=None, progress=None, **kwargs):
534544
"""Fetch the latest changes
535545
:param url: may be a remote name or a url
536546
:param refspecs: see push()
537547
:param progress: see push()"""
538-
proc = self._git.fetch(url, refspecs, with_extended_output=True, as_process=True, v=True, **kwargs)
548+
proc = self._git.fetch(url, refspecs, with_extended_output=True, as_process=True, v=True, **add_progress(kwargs, self.git))
539549
return get_fetch_info_from_stderr(self, proc, CmdRemoteProgress(progress))
540550

541551
#} end transport db interface
@@ -740,7 +750,7 @@ def _clone(cls, git, url, path, progress, **kwargs):
740750
# END windows handling
741751

742752
try:
743-
proc = git.clone(url, path, with_extended_output=True, as_process=True, v=True, **kwargs)
753+
proc = git.clone(url, path, with_extended_output=True, as_process=True, v=True, **add_progress(kwargs, git))
744754
if progress is not None:
745755
digest_process_messages(proc.stderr, progress)
746756
#END digest progress messages

0 commit comments

Comments
 (0)