Browse Source

Add a __main__.py; fix GitPython remote fetch error message.

tags/v0.5
Ben Kurtovic 5 years ago
parent
commit
3eb6e16892
4 changed files with 24 additions and 3 deletions
  1. +2
    -0
      CHANGELOG
  2. +9
    -0
      gitup/__main__.py
  3. +3
    -1
      gitup/script.py
  4. +10
    -2
      gitup/update.py

+ 2
- 0
CHANGELOG View File

@@ -8,8 +8,10 @@ v0.5 (unreleased):
old behavior. old behavior.
- `--depth 3` will look three levels deep. This is the new default. - `--depth 3` will look three levels deep. This is the new default.
- `--depth -1` will recurse indefinitely. This is not recommended. - `--depth -1` will recurse indefinitely. This is not recommended.
- Allow gitup to be run directly as a Python module (python -m gitup).
- Fixed an error when updating branches if the upstream is completely unrelated - Fixed an error when updating branches if the upstream is completely unrelated
from the local branch (no common ancestor). from the local branch (no common ancestor).
- Fixed error message when fetching from a remote fails.


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




+ 9
- 0
gitup/__main__.py View File

@@ -0,0 +1,9 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2011-2018 Ben Kurtovic <ben.kurtovic@gmail.com>
# Released under the terms of the MIT License. See LICENSE for details.

from .script import run

if __name__ == "__main__":
run()

+ 3
- 1
gitup/script.py View File

@@ -7,6 +7,7 @@ from __future__ import print_function


import argparse import argparse
import os import os
import platform
import sys import sys


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


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


+ 10
- 2
gitup/update.py View File

@@ -7,6 +7,8 @@ from __future__ import print_function


from glob import glob from glob import glob
import os import os
import pipes
import re
import shlex import shlex


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


Loading…
Cancel
Save