mirror of
https://github.com/rpm-software-management/tito.git
synced 2025-02-23 12:12:47 +00:00
Building in non-initialized project without explicit parameter
Fix #472
This commit is contained in:
parent
39943ba3fc
commit
68d8b219db
2 changed files with 33 additions and 14 deletions
|
@ -476,7 +476,7 @@ class Builder(ConfigObject, BuilderBase):
|
||||||
error_out(["Unable to lookup latest package info.",
|
error_out(["Unable to lookup latest package info.",
|
||||||
"Perhaps you need to tag first?"])
|
"Perhaps you need to tag first?"])
|
||||||
if not self.without_init:
|
if not self.without_init:
|
||||||
warn_out("unable to lookup latest package "
|
warn_out("Unable to lookup latest package "
|
||||||
"tag, building untagged test project")
|
"tag, building untagged test project")
|
||||||
build_version = get_spec_version_and_release(self.start_dir,
|
build_version = get_spec_version_and_release(self.start_dir,
|
||||||
find_spec_like_file(self.start_dir))
|
find_spec_like_file(self.start_dir))
|
||||||
|
|
|
@ -78,6 +78,14 @@ class ConfigLoader(object):
|
||||||
self._check_required_config(self.config)
|
self._check_required_config(self.config)
|
||||||
return self.config
|
return self.config
|
||||||
|
|
||||||
|
@property
|
||||||
|
def tito_props_path(self):
|
||||||
|
"""
|
||||||
|
Return absolute path to the `tito.props` file
|
||||||
|
"""
|
||||||
|
rel_eng_dir = os.path.join(find_git_root(), tito_config_dir())
|
||||||
|
return os.path.join(rel_eng_dir, TITO_PROPS)
|
||||||
|
|
||||||
def _read_config(self):
|
def _read_config(self):
|
||||||
"""
|
"""
|
||||||
Read global build.py configuration from the .tito dir of the git
|
Read global build.py configuration from the .tito dir of the git
|
||||||
|
@ -86,14 +94,6 @@ class ConfigLoader(object):
|
||||||
NOTE: We always load the latest config file, not tito.props as it
|
NOTE: We always load the latest config file, not tito.props as it
|
||||||
was for the tag being operated on.
|
was for the tag being operated on.
|
||||||
"""
|
"""
|
||||||
# List of filepaths to config files we'll be loading:
|
|
||||||
rel_eng_dir = os.path.join(find_git_root(), tito_config_dir())
|
|
||||||
filename = os.path.join(rel_eng_dir, TITO_PROPS)
|
|
||||||
if not os.path.exists(filename):
|
|
||||||
error_out("Unable to locate branch configuration: %s\n"
|
|
||||||
"Please run 'tito init' or use '--without-init' parameter"
|
|
||||||
% filename)
|
|
||||||
|
|
||||||
# Load the global config. Later, when we know what tag/package we're
|
# Load the global config. Later, when we know what tag/package we're
|
||||||
# building, we may also load that and potentially override some global
|
# building, we may also load that and potentially override some global
|
||||||
# settings.
|
# settings.
|
||||||
|
@ -282,11 +282,29 @@ class BaseCliModule(object):
|
||||||
})
|
})
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
def _check_config_and_load(self, loader):
|
||||||
|
path = loader.tito_props_path
|
||||||
|
if os.path.exists(path):
|
||||||
|
self.config = loader.load()
|
||||||
|
return
|
||||||
|
|
||||||
|
# When working in non-initialized project, only building is allowed
|
||||||
|
if not isinstance(self, BuildModule):
|
||||||
|
error_out("Unable to locate branch configuration: %s\n"
|
||||||
|
"Please run 'tito init'" % loader.tito_props_path)
|
||||||
|
|
||||||
|
if not self.options.without_init:
|
||||||
|
warn_out("Tito project wasn't initialized, "
|
||||||
|
"using the default configuration")
|
||||||
|
warn_out("Consider `tito init' or the `--without-init' "
|
||||||
|
"parameter to silent the warnings")
|
||||||
|
|
||||||
|
self.config = self.initial_config
|
||||||
|
|
||||||
|
|
||||||
def load_config(self, package_name, build_dir, tag):
|
def load_config(self, package_name, build_dir, tag):
|
||||||
if self.options.without_init:
|
loader = ConfigLoader(package_name, build_dir, tag)
|
||||||
self.config = self.initial_config
|
self._check_config_and_load(loader)
|
||||||
else:
|
|
||||||
self.config = ConfigLoader(package_name, build_dir, tag).load()
|
|
||||||
|
|
||||||
if self.config.has_option(BUILDCONFIG_SECTION,
|
if self.config.has_option(BUILDCONFIG_SECTION,
|
||||||
"offline"):
|
"offline"):
|
||||||
|
@ -349,7 +367,8 @@ class BuildModule(BaseCliModule):
|
||||||
self.parser.add_option("--test", dest="test", action="store_true",
|
self.parser.add_option("--test", dest="test", action="store_true",
|
||||||
help="use current branch HEAD instead of latest package tag")
|
help="use current branch HEAD instead of latest package tag")
|
||||||
self.parser.add_option("--without-init", action="store_true",
|
self.parser.add_option("--without-init", action="store_true",
|
||||||
help="Ignore missing .tito directory")
|
help=("Acknowledge working in non-initialized project "
|
||||||
|
"and silencing all related warnings"))
|
||||||
self.parser.add_option("--no-cleanup", dest="no_cleanup",
|
self.parser.add_option("--no-cleanup", dest="no_cleanup",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="do not clean up temporary tito build directories/files, and disable rpmbuild %clean")
|
help="do not clean up temporary tito build directories/files, and disable rpmbuild %clean")
|
||||||
|
|
Loading…
Add table
Reference in a new issue