Refactored reading local .gbs.conf
authorEd Bartosh <eduard.bartosh@intel.com>
Wed, 9 Oct 2013 07:23:15 +0000 (10:23 +0300)
committerEd Bartosh <eduard.bartosh@intel.com>
Wed, 9 Oct 2013 07:23:15 +0000 (10:23 +0300)
If gbs is called as an API local .gbs.conf is not read if it's not in
the current directory. This change fixes this.

Change-Id: I642591bea4f2dd958cd13d11b365b6f4ef00e6c4
Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
gitbuildsys/cmd_build.py
gitbuildsys/cmd_export.py
gitbuildsys/cmd_remotebuild.py
gitbuildsys/utils.py

index 606c282..d6bd6de 100644 (file)
@@ -25,7 +25,7 @@ import pwd
 import re
 import urlparse
 
-from gitbuildsys.utils import Temp, RepoParser
+from gitbuildsys.utils import Temp, RepoParser, read_localconf
 from gitbuildsys.errors import GbsError, Usage
 from gitbuildsys.conf import configmgr
 from gitbuildsys.safe_url import SafeURL
@@ -241,6 +241,8 @@ def main(args):
             raise GbsError("git project can't be found for --spec, "
                            "give it in argument or cd into it")
 
+    read_localconf(workdir)
+
     hostarch = os.uname()[4]
     if args.arch:
         buildarch = args.arch
index c3836c6..b88990b 100644 (file)
@@ -219,6 +219,7 @@ def main(args):
     except GitRepositoryError, err:
         raise GbsError(str(err))
 
+    utils.read_localconf(repo.path)
     utils.git_status_checker(repo, args)
     workdir = repo.path
 
index 8821cda..d21d414 100644 (file)
@@ -81,6 +81,8 @@ def main(args):
 
     workdir = repo.path
 
+    utils.read_localconf(workdir)
+
     if not (args.buildlog or args.status):
         utils.git_status_checker(repo, args)
 
index 94c84f3..e85af25 100644 (file)
@@ -490,14 +490,21 @@ class RepoParser(object):
 
         return filter_valid_repo(repos)
 
+
+def read_localconf(workdir):
+    """Read local configuration file from project directory."""
+    from gitbuildsys.conf import configmgr
+    prj_conf = os.path.join(workdir, '.gbs.conf')
+    if os.path.exists(prj_conf) and workdir != os.getcwd():
+        configmgr.add_conf(prj_conf)
+
+
 class SearchConfAction(argparse.Action):
     """
     Action for gitdir position argument to find project special
     gbs.conf
     """
     def __call__(self, parser, namespace, value, option_string=None):
-        from gitbuildsys.conf import configmgr
-
         workdir = value
         try:
             repo = RpmGitRepository(value)
@@ -505,9 +512,7 @@ class SearchConfAction(argparse.Action):
         except GitRepositoryError, err:
             pass
 
-        prj_conf = os.path.join(workdir, '.gbs.conf')
-        if os.path.exists(prj_conf) and workdir != os.getcwd():
-            configmgr.add_conf(prj_conf)
+        read_localconf(workdir)
         setattr(namespace, self.dest, value)
 
 def git_status_checker(git, opts):