[projects/git-slug: 3/170] Extract initialization of a new repo to a separate function
glen
glen at pld-linux.org
Mon Sep 21 21:39:03 CEST 2015
commit 7c4d4d8887f1dcba3a536403649e0738048ae926
Author: Kacper Kornet <draenog at pld-linux.org>
Date: Fri Sep 9 16:46:02 2011 +0100
Extract initialization of a new repo to a separate function
slug.py | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/slug.py b/slug.py
index f2045a9..d61be1d 100755
--- a/slug.py
+++ b/slug.py
@@ -38,6 +38,15 @@ def get_user():
email = email.partition('@')[0]
return email
+def initpackage(name, options):
+ repo = GitRepo(os.path.join(options.packagesdir, name))
+ if options.user:
+ remotepush = 'ssh://' + os.path.join(options.user+GIT_REPO_PUSH ,name)
+ else:
+ remotepush = None
+ repo.init(os.path.join(GIT_REPO,name), remotepush)
+ return repo
+
parser = argparse.ArgumentParser(description='PLD tool for interaction with git repos',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('-b', '--branch', help='branch to fetch', default = 'master')
@@ -69,19 +78,17 @@ except RemoteRefsError as e:
print >> sys.stderr, 'Problem with file {} in repository {}'.format(*e)
sys.exit()
+
print 'Read remotes data'
for dir in sorted(refs.heads):
gitdir = os.path.join(options.packagesdir, dir, '.git')
- gitrepo = GitRepo(os.path.join(options.packagesdir, dir))
if not os.path.isdir(gitdir):
if options.newpkgs:
- if options.user:
- remotepush = 'ssh://' + os.path.join(options.user+GIT_REPO_PUSH ,dir)
- else:
- remotepush = None
- gitrepo.init(os.path.join(GIT_REPO,dir), remotepush)
+ gitrepo = initpackage(dir, options)
else:
continue
+ else:
+ gitrepo = GitRepo(os.path.join(options.packagesdir, dir))
ref2fetch = []
for ref in refs.heads[dir]:
if gitrepo.check_remote(ref) != refs.heads[dir][ref]:
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/projects/git-slug.git/commitdiff/4ed64f73960519a2f4fd04c42950b2c96ae795c5
More information about the pld-cvs-commit
mailing list