Skip to content

Commit 3eb6e16

Browse files
committed
Add a __main__.py; fix GitPython remote fetch error message.
1 parent cc0254d commit 3eb6e16

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ v0.5 (unreleased):
88
old behavior.
99
- `--depth 3` will look three levels deep. This is the new default.
1010
- `--depth -1` will recurse indefinitely. This is not recommended.
11+
- Allow gitup to be run directly as a Python module (python -m gitup).
1112
- Fixed an error when updating branches if the upstream is completely unrelated
1213
from the local branch (no common ancestor).
14+
- Fixed error message when fetching from a remote fails.
1315

1416
v0.4.1 (released December 13, 2017):
1517

gitup/__main__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Copyright (C) 2011-2018 Ben Kurtovic <[email protected]>
4+
# Released under the terms of the MIT License. See LICENSE for details.
5+
6+
from .script import run
7+
8+
if __name__ == "__main__":
9+
run()

gitup/script.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import argparse
99
import os
10+
import platform
1011
import sys
1112

1213
from colorama import init as color_init, Fore, Style
@@ -84,7 +85,8 @@ def main():
8485
'-h', '--help', action="help", help="show this help message and exit")
8586
group_m.add_argument(
8687
'-v', '--version', action="version",
87-
version="gitup " + __version__)
88+
version="gitup {0} (Python {1})".format(
89+
__version__, platform.python_version()))
8890

8991
# TODO: deprecated arguments, for removal in v1.0:
9092
parser.add_argument(

gitup/update.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
from glob import glob
99
import os
10+
import pipes
11+
import re
1012
import shlex
1113

1214
from colorama import Fore, Style
@@ -77,8 +79,14 @@ def _get_name(ref):
7779
try:
7880
results = remote.fetch(progress=_ProgressMonitor(), prune=prune)
7981
except exc.GitCommandError as err:
80-
msg = err.command[0].replace("Error when fetching: ", "")
81-
if not msg.endswith("."):
82+
# We should have to do this ourselves, but GitPython doesn't give
83+
# us a sensible way to get the raw stderr...
84+
msg = re.sub(r"\s+", " ", err.stderr).strip()
85+
msg = re.sub(r"^stderr: *'(fatal: *)?", "", msg).strip("'")
86+
if not msg:
87+
command = " ".join(pipes.quote(arg) for arg in err.command)
88+
msg = "{0} failed with status {1}.".format(command, err.status)
89+
elif not msg.endswith("."):
8290
msg += "."
8391
print(":", RED + "error:", msg)
8492
return

0 commit comments

Comments
 (0)