comparison treepkg/git.py @ 519:0365b2c7ac00

don't checkout master branch by default for local branch. local would point to the local master and not to origin/master. add sanity check before git clone
author Bjoern Ricks <bricks@intevation.de>
date Wed, 10 Nov 2010 14:53:40 +0000
parents c4288095887f
children 5802cec2b071
comparison
equal deleted inserted replaced
518:452c5670ec6b 519:0365b2c7ac00
19 19
20 class GitError(Exception): 20 class GitError(Exception):
21 21
22 """Base class for Git specific errors raised by TreePKG""" 22 """Base class for Git specific errors raised by TreePKG"""
23 23
24 def checkout(url, localdir, branch="master"): 24 def checkout(url, localdir, branch=None):
25 """Clones the repository at url into the localdir""" 25 """Clones the repository at url into the localdir"""
26 run.call(cmdexpand("git clone -q $url $localdir", **locals())) 26 run.call(cmdexpand("git clone -q $url $localdir", **locals()))
27 if branch: 27 if branch:
28 run.call(cmdexpand("git checkout -q --track -b local $branch", 28 run.call(cmdexpand("git checkout -q --track -b local $branch",
29 **locals()), cwd=localdir) 29 **locals()), cwd=localdir)
106 gitdir = os.path.join(self.localdir, ".git") 106 gitdir = os.path.join(self.localdir, ".git")
107 if os.path.exists(gitdir): 107 if os.path.exists(gitdir):
108 self.log_info("Updating the working copy in %r", self.localdir) 108 self.log_info("Updating the working copy in %r", self.localdir)
109 update(self.localdir, self.repository.branch) 109 update(self.localdir, self.repository.branch)
110 else: 110 else:
111 # TODO: better check if localdir contains files
112 if os.path.exist(self.localdir):
113 raise GitError("Working copy dir %s already exists. " \
114 " files. Can't checkout from %s" % (self.localdir,
115 self.repository.url))
111 self.log_info("The working copy in %r doesn't exist yet." 116 self.log_info("The working copy in %r doesn't exist yet."
112 " Checking out from %r", 117 " Checking out from %r",
113 self.localdir, self.repository.url) 118 self.localdir, self.repository.url)
114 self.repository.checkout(self.localdir) 119 self.repository.checkout(self.localdir)
115 120
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)