Move gbp argument creation into one function
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Thu, 6 Sep 2012 10:43:37 +0000 (13:43 +0300)
committerZhang Qiang <qiang.z.zhang@intel.com>
Fri, 7 Sep 2012 02:13:25 +0000 (10:13 +0800)
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
gitbuildsys/cmd_build.py
gitbuildsys/cmd_export.py
gitbuildsys/cmd_remotebuild.py

index f721c1eb5d81bd6362a95a51476e8aaa877bd588..6434bea92fc5adad78dc81a284f615d1cdf08083 100644 (file)
@@ -31,6 +31,7 @@ import pwd
 from gitbuildsys import msger, utils, runner, errors
 from gitbuildsys.conf import configmgr
 from gitbuildsys.safe_url import SafeURL
+from gitbuildsys.cmd_export import create_gbp_export_args
 
 from gbp.scripts.buildpackage_rpm import main as gbp_build
 from gbp.rpm.git import GitRepositoryError, RpmGitRepository
@@ -359,15 +360,9 @@ def do(opts, args):
             commit = 'HEAD'
         relative_spec = specfile.replace('%s/' % workdir, '')
         msger.info('export tar ball and packaging files ... ')
+        gbp_args = create_gbp_export_args(commit, export_dir, relative_spec)
         try:
-            if gbp_build(["argv[0] placeholder", "--git-export-only",
-                          "--git-ignore-new", "--git-builder=osc",
-                          "--git-no-patch-export",
-                          "--git-upstream-tree=%s" % commit,
-                          "--git-export-dir=%s" % export_dir,
-                          "--git-packaging-dir=packaging",
-                          "--git-spec-file=%s" % relative_spec,
-                          "--git-export=%s" % commit]):
+            if gbp_build(gbp_args):
                 msger.error("Failed to get packaging info from git tree")
         except GitRepositoryError, excobj:
             msger.error("Repository error: %s" % excobj)
index 961f9b851b6a92d7ae16500835b4f03637daca88..b14050fb3fffda7a30f430a900a7f72d9e72101c 100644 (file)
@@ -44,6 +44,17 @@ def mkdir_p(path):
         else:
             raise
 
+def create_gbp_export_args(commit, export_dir, spec):
+    args = ["argv[0] placeholder", "--git-export-only",
+            "--git-ignore-new", "--git-builder=osc",
+            "--git-no-patch-export",
+            "--git-upstream-tree=%s" % commit,
+            "--git-export-dir=%s" % export_dir,
+            "--git-packaging-dir=packaging",
+            "--git-spec-file=%s" % spec,
+            "--git-export=%s" % commit]
+    return args
+
 def do(opts, args):
     """
     The main plugin call
@@ -92,15 +103,9 @@ def do(opts, args):
         else:
             commit = 'HEAD'
         relative_spec = specfile.replace('%s/' % workdir, '')
+        gbp_args = create_gbp_export_args(commit, export_dir, relative_spec)
         try:
-            if gbp_build(["argv[0] placeholder", "--git-export-only",
-                          "--git-ignore-new", "--git-builder=osc",
-                          "--git-no-patch-export",
-                          "--git-upstream-tree=%s" % commit,
-                          "--git-export-dir=%s" % export_dir,
-                          "--git-packaging-dir=packaging",
-                          "--git-spec-file=%s" % relative_spec,
-                          "--git-export=%s" % commit]):
+            if gbp_build(gbp_args):
                 msger.error("Failed to get packaging info from git tree")
         except GitRepositoryError, excobj:
             msger.error("Repository error: %s" % excobj)
index e733684fd7c7a955b3a8a0bd04828e23bf56f198..558fb64c420697c6c9449ad685f2bfb0adcd7673 100644 (file)
@@ -26,6 +26,7 @@ from gitbuildsys import msger, errors, utils
 
 from gitbuildsys.conf import configmgr
 from gitbuildsys.oscapi import OSC, OSCError
+from gitbuildsys.cmd_export import create_gbp_export_args
 
 import gbp.rpm
 from gbp.scripts.buildpackage_rpm import main as gbp_build
@@ -196,15 +197,9 @@ def do(opts, args):
         else:
             commit = 'HEAD'
         relative_spec = specfile.replace('%s/' % workdir, '')
+        gbp_args = create_gbp_export_args(commit, exportdir, relative_spec)
         try:
-            if gbp_build(["argv[0] placeholder", "--git-export-only",
-                          "--git-ignore-new", "--git-builder=osc",
-                          "--git-no-patch-export",
-                          "--git-upstream-tree=%s" % commit,
-                          "--git-export-dir=%s" % exportdir,
-                          "--git-packaging-dir=packaging",
-                          "--git-spec-file=%s" % relative_spec,
-                          "--git-export=%s" % commit]):
+            if gbp_build(gbp_args):
                 msger.error("Failed to get packaging info from git tree")
         except GitRepositoryError, excobj:
             msger.error("Repository error: %s" % excobj)