Skip to content

Commit

Permalink
Fix crash in 'build' command when building with --local-package --alt…
Browse files Browse the repository at this point in the history
…ernative-project from a locally initialized .osc package
  • Loading branch information
dmach committed Oct 11, 2024
1 parent 1fc5813 commit 35e2c76
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion osc/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ def main(apiurl, store, opts, argv):
bc_file = None
bi_filename = '_buildinfo-%s-%s.xml' % (repo, arch)
bc_filename = '_buildconfig-%s-%s' % (repo, arch)
if store.is_package and os.access(core.store, os.W_OK):
if store is not None and store.is_package and os.access(core.store, os.W_OK):
bi_filename = os.path.join(os.getcwd(), core.store, bi_filename)
bc_filename = os.path.join(os.getcwd(), core.store, bc_filename)
elif not os.access('.', os.W_OK):
Expand Down
11 changes: 10 additions & 1 deletion osc/commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -7408,10 +7408,19 @@ def do_build(self, subcmd, opts, *args):
pass
else:
try:
store = osc_store.get_store(os.path.dirname(Path.cwd()), print_warnings=True)
store = osc_store.get_store(Path.cwd(), print_warnings=True)
except oscerr.NoWorkingCopy:
store = None

if store is None:
try:
# if opts.local_package is set, build.main() reads project from the store and sets package to "_project"
# that's why we're ok with store from the parent directory that holds information about the project
# FIXME: the parent directory may contain a git repo that doesn't contain a project; we have no way of recognizing that!
store = osc_store.get_store(os.path.dirname(Path.cwd()), print_warnings=True)
except oscerr.NoWorkingCopy:
store = None

# HACK: avoid calling some underlying store_*() functions from parse_repoarchdescr() method
# We'll fix parse_repoarchdescr() later because it requires a larger change
if not opts.alternative_project and isinstance(store, git_scm.GitStore):
Expand Down

0 comments on commit 35e2c76

Please sign in to comment.