Skip to content

Commit d906370

Browse files
committed
Change 'osc build' to build from any git repo if '--alternative-project' is specified
1 parent 9568df1 commit d906370

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

osc/commandline.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7899,17 +7899,24 @@ def do_build(self, subcmd, opts, *args):
78997899
raise oscerr.WrongArgs('Too many arguments')
79007900

79017901
if not opts.local_package:
7902-
store = osc_store.get_store(Path.cwd(), print_warnings=True)
7902+
try:
7903+
store = osc_store.get_store(Path.cwd(), print_warnings=True)
7904+
store.assert_is_package()
7905+
except oscerr.NoWorkingCopy:
7906+
if opts.apiurl and opts.alternative_project:
7907+
# HACK: ignore invalid working copy and run the build anyway if --alternative-project is specified
7908+
store = git_scm.GitStore(Path.cwd(), check=False)
7909+
else:
7910+
raise
7911+
79037912
if isinstance(store, git_scm.store.GitStore):
79047913
opts.local_package = True
7905-
else:
7906-
store.assert_is_package()
79077914

79087915
try:
79097916
if opts.alternative_project and opts.alternative_project == store.project:
79107917
opts.alternative_project = None
7911-
except RuntimeError:
7912-
# ignore the following exception: Couldn't map git branch '<BRANCH>' to a project
7918+
except (RuntimeError, oscerr.NoWorkingCopy):
7919+
# ignore the following exception: Couldn't map git branch '<BRANCH>' to a project
79137920
pass
79147921
else:
79157922
try:

0 commit comments

Comments
 (0)