[projects/git-slug: 112/170] Print error message when no matching package has been found

glen glen at pld-linux.org
Mon Sep 21 21:48:13 CEST 2015


commit 704ec65b3e0314964b499cb5c4c87aed9fef1140
Author: Kacper Kornet <draenog at pld-linux.org>
Date:   Fri Apr 13 11:46:14 2012 +0100

    Print error message when no matching package has been found

 git_slug/refsdata.py | 5 +++++
 slug.py              | 5 ++++-
 2 files changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/git_slug/refsdata.py b/git_slug/refsdata.py
index 258169a..4354ac4 100644
--- a/git_slug/refsdata.py
+++ b/git_slug/refsdata.py
@@ -11,6 +11,9 @@ from .gitrepo import GitRepo
 class RemoteRefsError(Exception):
     pass
 
+class NoMatchedRepos(Exception):
+    pass
+
 class RemoteRefsData:
     def __init__(self, stream, pattern, dirpattern=('*',)):
         self.heads = collections.defaultdict(lambda: collections.defaultdict(lambda: EMPTYSHA1))
@@ -22,6 +25,8 @@ class RemoteRefsData:
             (sha1, ref, repo) = line.split()
             if pats.match(ref) and dirpat.match(repo):
                 self.heads[repo][ref] = sha1
+        if not self.heads:
+            raise NoMatchedRepos
 
     def put(self, repo, data):
         for line in data:
diff --git a/slug.py b/slug.py
index 37df462..502ba26 100755
--- a/slug.py
+++ b/slug.py
@@ -16,7 +16,7 @@ import configparser
 
 from git_slug.gitconst import GITLOGIN, GITSERVER, GIT_REPO, GIT_REPO_PUSH, REMOTEREFS
 from git_slug.gitrepo import GitRepo, GitRepoError
-from git_slug.refsdata import GitArchiveRefsData, RemoteRefsError
+from git_slug.refsdata import GitArchiveRefsData, NoMatchedRepos, RemoteRefsError
 
 class DelAppend(argparse._AppendAction):
     def __call__(self, parser, namespace, values, option_string=None):
@@ -88,6 +88,9 @@ def getrefs(*args):
     except RemoteRefsError as e:
         print('Problem with file {} in repository {}'.format(*e.args), file=sys.stderr)
         sys.exit(1)
+    except NoMatchedRepos:
+        print('No matching package has been found', file=sys.stderr)
+        sys.exit(2)
     return refs
 
 def fetch_packages(options):
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/git-slug.git/commitdiff/4ed64f73960519a2f4fd04c42950b2c96ae795c5



More information about the pld-cvs-commit mailing list