[projects/git-slug: 44/170] List command
glen
glen at pld-linux.org
Mon Sep 21 21:42:30 CEST 2015
commit 1c184909987eeb8a4896d21ab6bcd5e35b6babe7
Author: Kacper Kornet <draenog at pld-linux.org>
Date: Fri Sep 23 13:38:27 2011 +0100
List command
It lists all available packages.
slug.py | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
---
diff --git a/slug.py b/slug.py
index c1c1511..351a970 100755
--- a/slug.py
+++ b/slug.py
@@ -148,6 +148,18 @@ def clone_packages(options):
except GitRepoError as e:
print('Problem with checking branch master in repo {}: {}'.format(repo.gdir, e), file=sys.stderr)
+def list_packages(options):
+ try:
+ refs = GitRemoteRefsData(options.remoterefs, options.branch, options.repopattern)
+ except GitRepoError as e:
+ print('Problem with repository {}: {}'.format(options.remoterefs,e), file=sys.stderr)
+ sys.exit(1)
+ except RemoteRefsError as e:
+ print('Problem with file {} in repository {}'.format(*e), file=sys.stderr)
+ sys.exit(1)
+ for package in sorted(refs.heads):
+ print(package)
+
common_options = argparse.ArgumentParser(add_help=False)
common_options.add_argument('-d', '--packagesdir', help='local directory with git repositories',
default=os.path.expanduser('~/PLD_clone/packages'))
@@ -189,6 +201,14 @@ fetch = subparsers.add_parser('fetch', help='fetch repositories', parents=[commo
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
fetch.set_defaults(func=clone_packages, branch='[*]', prune=False, depth=0, newpkgs=False, omitexisting=False)
+listpkgs = subparsers.add_parser('list', help='list repositories',
+ formatter_class=argparse.ArgumentDefaultsHelpFormatter)
+listpkgs.add_argument('-r', '--remoterefs', help='repository with list of all refs',
+ default=os.path.expanduser('~/PLD_clone/Refs.git'))
+listpkgs.add_argument('-b', '--branch', help='show packages with given branch', action=DelAppend, default=['*'])
+listpkgs.add_argument('repopattern', nargs='*', default = ['*'])
+listpkgs.set_defaults(func=list_packages)
+
parser.set_defaults(**readconfig(os.path.expanduser('~/.gitconfig')))
options = parser.parse_args()
options.func(options)
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/projects/git-slug.git/commitdiff/4ed64f73960519a2f4fd04c42950b2c96ae795c5
More information about the pld-cvs-commit
mailing list