aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido Guenther <agx@sigxcpu.org>2006-10-05 19:51:10 +0200
committerGuido Guenther <agx@bogon.sigxcpu.org>2006-10-05 19:51:10 +0200
commit29948a722e3a63668c29239e072381731070e017 (patch)
tree5db5f6d3bad80439a75ba733b425811e2bfeb62f
parent0608261f07f4bdd12944deed887f5eebbf5ce946 (diff)
check if we're at the top level of a git repository before starting the builddebian/0.2.6
-rw-r--r--debian/changelog6
-rwxr-xr-xgit-buildpackage6
-rwxr-xr-xgit-import-orig8
-rw-r--r--git_buildpackage/utils.py10
4 files changed, 22 insertions, 8 deletions
diff --git a/debian/changelog b/debian/changelog
index 1fe1e327..86237a94 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,9 +5,11 @@ git-buildpackage (0.2.6) git-buildpackage; urgency=low
* also filter out git metadata when building tarballs, not only when
building diffs (affects Debian native packages)
* git-import-dsc: allow for '+' in Debian as well as upstream version
- numbers
+ numbers
+ * check if we're at the top level of a git repository before starting the
+ build
- -- Guido Guenther <agx@sigxcpu.org> Thu, 5 Oct 2006 19:35:31 +0200
+ -- Guido Guenther <agx@sigxcpu.org> Thu, 5 Oct 2006 19:46:23 +0200
git-buildpackage (0.2.5) git-buildpackage; urgency=low
diff --git a/git-buildpackage b/git-buildpackage
index 5645b54d..f7360c4d 100755
--- a/git-buildpackage
+++ b/git-buildpackage
@@ -20,7 +20,7 @@
import sys,os,commands,re
import optparse
from git_buildpackage import GitTag, Command, CommandExecFailed
-from git_buildpackage.utils import is_repository_clean
+from git_buildpackage.utils import is_repository_clean, is_repository
build_cmd='debuild'
@@ -53,6 +53,10 @@ def main(argv):
if options.verbose:
Command.verbose = True
+ if not is_repository('.'):
+ print >>sys.stderr,"%s is not a git repository" % (os.path.abspath('.'))
+ return 1
+
try:
if not options.ignore_new:
Command(options.build_cmd,['clean'])()
diff --git a/git-import-orig b/git-import-orig
index fdf9d734..ca802996 100755
--- a/git-import-orig
+++ b/git-import-orig
@@ -24,7 +24,7 @@ import re
import glob
from optparse import OptionParser
from git_buildpackage import *
-from git_buildpackage.utils import is_repository_clean
+from git_buildpackage.utils import is_repository_clean, is_repository
def cleanupTmpTree(tree):
@@ -75,10 +75,8 @@ def main():
else:
tgz=args[0]
- try:
- os.stat('.git')
- except:
- print >>sys.stderr,"%s not a git repository" % (os.path.abspath('.'),)
+ if not is_repository('.'):
+ print >>sys.stderr,"%s is not a git repository" % (os.path.abspath('.'),)
return 1
if options.version:
diff --git a/git_buildpackage/utils.py b/git_buildpackage/utils.py
index 4708dd3f..e2455ff3 100644
--- a/git_buildpackage/utils.py
+++ b/git_buildpackage/utils.py
@@ -21,4 +21,14 @@ def is_repository_clean(path):
os.chdir(dir)
return (ret, "".join(out))
+def is_repository(path):
+ """Is there a git repository at path?"""
+ if not path:
+ return False
+ try:
+ os.stat(path+'/.git')
+ except:
+ return False
+ return True
+
# vim:et:ts=4:sw=4: