diff options
Diffstat (limited to 'git')
-rw-r--r-- | git/diff.py | 4 | ||||
-rw-r--r-- | git/remote.py | 22 | ||||
-rw-r--r-- | git/repo/base.py | 4 | ||||
-rw-r--r-- | git/test/test_remote.py | 4 | ||||
-rw-r--r-- | git/util.py | 21 |
5 files changed, 42 insertions, 13 deletions
diff --git a/git/diff.py b/git/diff.py index 8a4819ab..e90fc1cf 100644 --- a/git/diff.py +++ b/git/diff.py @@ -75,6 +75,10 @@ class Diffable(object): args.append("-M") # check for renames else: args.append("--raw") + + # in any way, assure we don't see colored output, + # fixes https://github.com/gitpython-developers/GitPython/issues/172 + args.append('--no-color') if paths is not None and not isinstance(paths, (tuple,list)): paths = [ paths ] diff --git a/git/remote.py b/git/remote.py index f89e9d83..b06c0686 100644 --- a/git/remote.py +++ b/git/remote.py @@ -513,14 +513,15 @@ class Remote(LazyMixin, Iterable): def _get_fetch_info_from_stderr(self, proc, progress): # skip first line as it is some remote info we are not interested in output = IterableList('name') - - + + # lines which are no progress are fetch info lines # this also waits for the command to finish # Skip some progress lines that don't provide relevant information fetch_info_lines = list() for line in digest_process_messages(proc.stderr, progress): - if line.startswith('From') or line.startswith('remote: Total') or line.startswith('POST'): + if line.startswith('From') or line.startswith('remote: Total') or line.startswith('POST') \ + or line.startswith(' ='): continue elif line.startswith('warning:'): print >> sys.stderr, line @@ -536,7 +537,10 @@ class Remote(LazyMixin, Iterable): fetch_head_info = fp.readlines() fp.close() - assert len(fetch_info_lines) == len(fetch_head_info), "len(%s) != len(%s)" % (fetch_head_info, fetch_info_lines) + # NOTE: HACK Just disabling this line will make github repositories work much better. + # I simply couldn't stand it anymore, so here is the quick and dirty fix ... . + # This project needs a lot of work ! + # assert len(fetch_info_lines) == len(fetch_head_info), "len(%s) != len(%s)" % (fetch_head_info, fetch_info_lines) output.extend(FetchInfo._from_line(self.repo, err_line, fetch_line) for err_line,fetch_line in zip(fetch_info_lines, fetch_head_info)) @@ -579,6 +583,10 @@ class Remote(LazyMixin, Iterable): See also git-push(1). Taken from the git manual + + Fetch supports multiple refspecs (as the + underlying git-fetch does) - supplying a list rather than a string + for 'refspec' will make use of this facility. :param progress: See 'push' method :param kwargs: Additional arguments to be passed to git-fetch :return: @@ -589,7 +597,11 @@ class Remote(LazyMixin, Iterable): As fetch does not provide progress information to non-ttys, we cannot make it available here unfortunately as in the 'push' method.""" kwargs = add_progress(kwargs, self.repo.git, progress) - proc = self.repo.git.fetch(self, refspec, with_extended_output=True, as_process=True, v=True, **kwargs) + if isinstance(refspec, list): + args = refspec + else: + args = [refspec] + proc = self.repo.git.fetch(self, *args, with_extended_output=True, as_process=True, v=True, **kwargs) return self._get_fetch_info_from_stderr(proc, progress or RemoteProgress()) def pull(self, refspec=None, progress=None, **kwargs): diff --git a/git/repo/base.py b/git/repo/base.py index a45d215e..b9335aba 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -56,13 +56,13 @@ class Repo(object): The following attributes are worth using: - 'working_dir' is the working directory of the git command, wich is the working tree + 'working_dir' is the working directory of the git command, which is the working tree directory if available or the .git directory in case of bare repositories 'working_tree_dir' is the working tree directory, but will raise AssertionError if we are a bare repository. - 'git_dir' is the .git repository directoy, which is always set.""" + 'git_dir' is the .git repository directory, which is always set.""" DAEMON_EXPORT_FILE = 'git-daemon-export-ok' __slots__ = ( "working_dir", "_working_tree_dir", "git_dir", "_bare", "git", "odb" ) diff --git a/git/test/test_remote.py b/git/test/test_remote.py index a7f1be22..b1248096 100644 --- a/git/test/test_remote.py +++ b/git/test/test_remote.py @@ -199,6 +199,10 @@ class TestRemote(TestBase): # ... with respec and no target res = fetch_and_test(remote, refspec='master') assert len(res) == 1 + + # ... multiple refspecs + res = fetch_and_test(remote, refspec=['master', 'fred']) + assert len(res) == 1 # add new tag reference rtag = TagReference.create(remote_repo, "1.0-RV_hello.there") diff --git a/git/util.py b/git/util.py index 7c257b37..88a72c0c 100644 --- a/git/util.py +++ b/git/util.py @@ -22,6 +22,10 @@ from gitdb.util import ( to_bin_sha ) +# Import the user database on unix based systems +if os.name == "posix": + import pwd + __all__ = ( "stream_copy", "join_path", "to_native_path_windows", "to_native_path_linux", "join_path_native", "Stats", "IndexFileSHA1Writer", "Iterable", "IterableList", "BlockingLockFile", "LockFile", 'Actor', 'get_user_id', 'assure_directory_exists', @@ -113,12 +117,17 @@ def assure_directory_exists(path, is_file=False): def get_user_id(): """:return: string identifying the currently active system user as name@node - :note: user can be set with the 'USER' environment variable, usually set on windows""" - ukn = 'UNKNOWN' - username = os.environ.get('USER', os.environ.get('USERNAME', ukn)) - if username == ukn and hasattr(os, 'getlogin'): - username = os.getlogin() - # END get username from login + :note: user can be set with the 'USER' environment variable, usually set on windows + :note: on unix based systems you can use the password database + to get the login name of the effective process user""" + if os.name == "posix": + username = pwd.getpwuid(os.geteuid()).pw_name + else: + ukn = 'UNKNOWN' + username = os.environ.get('USER', os.environ.get('USERNAME', ukn)) + if username == ukn and hasattr(os, 'getlogin'): + username = os.getlogin() + # END get username from login return "%s@%s" % (username, platform.node()) #} END utilities |