Skip to content

Commit

Permalink
Move running obs_scm_bridge into run_obs_scm_bridge() function
Browse files Browse the repository at this point in the history
  • Loading branch information
dmach committed Nov 29, 2024
1 parent cf7e24a commit ae7ccdb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
7 changes: 2 additions & 5 deletions osc/commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -5387,7 +5387,7 @@ def do_checkout(self, subcmd, opts, *args):
from .core import parseRevisionOption
from .core import print_request_list
from .core import revision_is_empty
from .core import run_external
from .core import run_obs_scm_bridge
from .core import show_files_meta
from .core import show_project_meta
from .core import show_scmsync
Expand Down Expand Up @@ -5506,10 +5506,7 @@ def do_checkout(self, subcmd, opts, *args):

scm_url = show_scmsync(apiurl, project)
if scm_url is not None and not opts.native_obs_package:
if not os.path.isfile('/usr/lib/obs/service/obs_scm_bridge'):
raise oscerr.OscIOError(None, 'Install the obs-scm-bridge package to work on packages managed in scm (git)!')
os.putenv("OSC_VERSION", get_osc_version())
run_external(['/usr/lib/obs/service/obs_scm_bridge', '--outdir', str(prj_dir), '--url', scm_url])
run_obs_scm_bridge(url=scm_url, target_dir=str(prj_dir))

Project.init_project(apiurl, prj_dir, project, conf.config['do_package_tracking'], scm_url=scm_url)
print(statfrmt('A', prj_dir))
Expand Down
12 changes: 12 additions & 0 deletions osc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,18 @@ def apiurl_aliases(self):
ini_key="download-assets-cmd",
) # type: ignore[assignment]

obs_scm_bridge_cmd: str = Field(
default=
shutil.which("obs_scm_bridge", path="/usr/lib/obs/service")
or "/usr/lib/obs/service/obs_scm_bridge",
description=textwrap.dedent(
"""
Path to the 'obs_scm_bridge' tool used for cloning scmsync projects and packages.
"""
),
ini_key="obs-scm-bridge-cmd",
) # type: ignore[assignment]

vc_cmd: str = Field(
default=shutil.which("vc", path="/usr/lib/build:/usr/lib/obs-build") or "/usr/lib/build/vc",
description=textwrap.dedent(
Expand Down
15 changes: 10 additions & 5 deletions osc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3080,6 +3080,14 @@ def make_dir(
return pkg_path


def run_obs_scm_bridge(url: str, target_dir: str):
if not os.path.isfile(conf.config.obs_scm_bridge_cmd):
raise oscerr.OscIOError(None, "Install the obs-scm-bridge package to work on packages managed in scm (git)!")
env = os.environ.copy()
env["OSC_VERSION"] = get_osc_version()
run_external([conf.config.obs_scm_bridge_cmd, "--outdir", target_dir, "--url", url], env=env)


def checkout_package(
apiurl: str,
project: str,
Expand Down Expand Up @@ -3153,9 +3161,6 @@ def checkout_package(
root = ET.fromstring(meta_data)
scmsync_element = root.find("scmsync")
if not native_obs_package and scmsync_element is not None and scmsync_element.text is not None:
if not os.path.isfile('/usr/lib/obs/service/obs_scm_bridge'):
raise oscerr.OscIOError(None, 'Install the obs-scm-bridge package to work on packages managed in scm (git)!')
scm_url = scmsync_element.text
directory = make_dir(apiurl, project, package, pathname, prj_dir, conf.config['do_package_tracking'], outdir)

if revision is not None:
Expand All @@ -3165,8 +3170,8 @@ def checkout_package(
scmsync_obsinfo = ScmsyncObsinfo.from_api(apiurl, project, package, rev=revision)
scm_url = f"{scmsync_obsinfo.url}#{scmsync_obsinfo.revision}"

os.putenv("OSC_VERSION", get_osc_version())
run_external(['/usr/lib/obs/service/obs_scm_bridge', '--outdir', directory, '--url', scm_url])
scm_url = scmsync_element.text
run_obs_scm_bridge(url=scm_url, target_dir=directory)

Package.init_package(apiurl, project, package, directory, size_limit, meta, progress_obj, scm_url)

Expand Down

0 comments on commit ae7ccdb

Please sign in to comment.