Used repo.path to use top-level git dir as a working dir. Fixes #21
authorEd Bartosh <eduard.bartosh@intel.com>
Mon, 25 Jun 2012 13:40:57 +0000 (16:40 +0300)
committerEd Bartosh <eduard.bartosh@intel.com>
Mon, 25 Jun 2012 13:40:57 +0000 (16:40 +0300)
Change-Id: I42f78a37f18050c478e9bc9ddc150107d4a9e2ee

gitbuildsys/cmd_build.py
gitbuildsys/cmd_changelog.py
gitbuildsys/cmd_export.py
gitbuildsys/cmd_remotebuild.py

index fa7c0359c5a32ccd21a1460d38284e70d427d55b..669d4f8bf7c344ce3e9380f77af8118c97464fb9 100644 (file)
@@ -231,6 +231,13 @@ def do(opts, args):
     if len(args) == 1:
         workdir = os.path.abspath(args[0])
 
+    try:
+        repo = RpmGitRepository(workdir)
+    except GitRepositoryError:
+        msger.error("%s is not a git repository" % (os.path.curdir))
+
+    workdir = repo.path
+
     hostarch = get_hostarch()
     if opts.arch:
         buildarch = opts.arch
@@ -306,10 +313,6 @@ def do(opts, args):
     if not spec.name or not spec.version:
         msger.error('can\'t get correct name or version from spec file.')
 
-    try:
-        repo = RpmGitRepository(workdir)
-    except GitRepositoryError:
-        msger.error("%s is not a git repository" % (os.path.curdir))
 
     tarball = None
     if spec.orig_file:
@@ -323,7 +326,7 @@ def do(opts, args):
                 msger.error("Cannot create source tarball %s" % tarball)
         except GbpError, exc:
             msger.error(str(exc))
+
     if opts.incremental:
         cmd += ['--rsync-src=%s' % os.path.abspath(workdir)]
         cmd += ['--rsync-dest=/home/abuild/rpmbuild/BUILD/%s-%s' % \
index b0b9401d81fedd72d375b90c8c7ea98515b893fb..9cb83169e0f704524de7986dc7b587b2866cb80a 100644 (file)
@@ -92,13 +92,13 @@ def make_log_entries(commits, git_repo):
 
 def do(opts, _args):
 
-    project_root_dir = '.'
-
     try:
-        repo = RpmGitRepository(project_root_dir)
+        repo = RpmGitRepository('.')
     except GitRepositoryError:
         msger.error("No git repository found.")
 
+    project_root_dir = repo.path
+
     if not repo.is_clean():
         msger.error("Git tree is not clean")
 
index 025975f4c33b118ac1b6f2e67aa08a425d5312de..fc7019f869182bd05806c923b49d3d054bd263a8 100644 (file)
@@ -57,6 +57,13 @@ def do(opts, args):
     if len(args) == 1:
         workdir = os.path.abspath(args[0])
 
+    try:
+        repo = RpmGitRepository(workdir)
+    except GitRepositoryError:
+        msger.error("%s is not a git repository" % (workdir))
+
+    workdir = repo.path
+
     if not os.path.exists("%s/packaging" % workdir):
         msger.error('No packaging directory, so there is nothing to export.')
 
@@ -89,10 +96,6 @@ def do(opts, args):
     urlres = urlparse.urlparse(spec.orig_file)
     tarball = '%s/%s' % (outdir, os.path.basename(urlres.path))
     msger.info('generate tar ball: %s' % tarball)
-    try:
-        repo = RpmGitRepository(workdir)
-    except GitRepositoryError:
-        msger.error("%s is not a git repository" % (os.path.curdir))
 
     try:
         comp_type = guess_comp_type(spec)
index 5004317622dc625dc83c285ef3efc83cfabce429..664d44a8b656d9cc55b41bc03093ca26c55654db 100644 (file)
@@ -63,6 +63,8 @@ def do(opts, args):
     except repository.GitRepositoryError:
         msger.error('%s is not a git dir' % workdir)
 
+    workdir = repo.path
+
     tmpdir = '%s/%s' % (TMPDIR, USER)
     if not os.path.exists(tmpdir):
         os.makedirs(tmpdir)