mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-24 22:06:14 +01:00
Add limited support of Git SCM to the 'build' command
This commit is contained in:
parent
4138a40e02
commit
7943b55a6e
@ -30,6 +30,7 @@ from . import build as osc_build
|
||||
from . import cmdln
|
||||
from . import commands as osc_commands
|
||||
from . import conf
|
||||
from . import git_scm
|
||||
from . import oscerr
|
||||
from . import store as osc_store
|
||||
from .core import *
|
||||
@ -7197,12 +7198,17 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
if len(args) > 3:
|
||||
raise oscerr.WrongArgs('Too many arguments')
|
||||
|
||||
store = osc_store.Store(Path.cwd())
|
||||
store = osc_store.get_store(Path.cwd(), print_warnings=True)
|
||||
store.assert_is_package()
|
||||
|
||||
if opts.alternative_project == store.project:
|
||||
opts.alternative_project = 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):
|
||||
opts.alternative_project = store.project
|
||||
|
||||
if len(args) == 0 and store.is_package and store.last_buildroot:
|
||||
# build env not specified, just read from last build attempt
|
||||
args = [store.last_buildroot[0], store.last_buildroot[1]]
|
||||
|
10
osc/core.py
10
osc/core.py
@ -49,6 +49,7 @@ from . import _private
|
||||
from . import conf
|
||||
from . import meter
|
||||
from . import oscerr
|
||||
from . import store as osc_store
|
||||
from .connection import http_request, http_GET, http_POST, http_PUT, http_DELETE
|
||||
from .store import Store
|
||||
from .util.helper import decode_list, decode_it, raw_input, _html_escape
|
||||
@ -1238,7 +1239,8 @@ class Package:
|
||||
|
||||
self.dir = workingdir or "."
|
||||
self.absdir = os.path.abspath(self.dir)
|
||||
self.store = Store(self.dir)
|
||||
self.store = osc_store.get_store(self.dir)
|
||||
self.store.assert_is_package()
|
||||
self.storedir = os.path.join(self.absdir, store)
|
||||
self.progress_obj = progress_obj
|
||||
self.size_limit = size_limit
|
||||
@ -1246,10 +1248,8 @@ class Package:
|
||||
if size_limit and size_limit == 0:
|
||||
self.size_limit = None
|
||||
|
||||
check_store_version(self.dir)
|
||||
|
||||
self.prjname = store_read_project(self.dir)
|
||||
self.name = store_read_package(self.dir)
|
||||
self.prjname = self.store.project
|
||||
self.name = self.store.package
|
||||
self.apiurl = self.store.apiurl
|
||||
|
||||
self.update_datastructs()
|
||||
|
21
osc/store.py
21
osc/store.py
@ -10,7 +10,7 @@ from xml.etree import ElementTree as ET
|
||||
|
||||
from . import oscerr
|
||||
from ._private import api
|
||||
|
||||
from . import git_scm
|
||||
|
||||
class Store:
|
||||
STORE_DIR = ".osc"
|
||||
@ -309,3 +309,22 @@ class Store:
|
||||
else:
|
||||
root = self.read_xml_node("_meta", "project").getroot()
|
||||
return root
|
||||
|
||||
|
||||
def get_store(path, check=True, print_warnings=False):
|
||||
"""
|
||||
Return a store object that wraps SCM in given `path`:
|
||||
- Store for OBS SCM
|
||||
- GitStore for Git SCM
|
||||
"""
|
||||
try:
|
||||
store = Store(path, check)
|
||||
except oscerr.NoWorkingCopy as ex:
|
||||
try:
|
||||
store = git_scm.GitStore(path, check)
|
||||
if print_warnings:
|
||||
git_scm.warn_experimental()
|
||||
except oscerr.NoWorkingCopy as ex_git:
|
||||
# raise the original exception, do not inform that we've tried git working copy
|
||||
raise ex from None
|
||||
return store
|
||||
|
Loading…
Reference in New Issue
Block a user