Skip to content

Commit

Permalink
Add --remote option.
Browse files Browse the repository at this point in the history
Adds a --remote option to specify the server to target local development
servers and testing servers.
  • Loading branch information
grafikrobot committed Sep 25, 2022
1 parent 2cb714e commit c0a8845
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from setuptools import setup, find_namespace_packages
import os

VERSION = '0.2.2'
VERSION = '0.3.0'

print("TEST_VERSION:", os.getenv('TEST_VERSION'))
if os.getenv('GHA_TEST_VERSION'):
Expand Down
26 changes: 22 additions & 4 deletions src/barbarians/barbarian.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ def __init__(self, reason):
class Barbarian(object):
def __init__(self):
ap = ArgumentParser("barbarian")

# General options..
ap.add_argument(
"--remote",
help="The remote Barbarian repo to use specified as `<URL>@<NAME>."
+ " Defaults to `https://barbarian.bfgroup.xyz/github@barbarian-github`.",
default="https://barbarian.bfgroup.xyz/github@barbarian-github"
)

# Sub-commands..
ap_sub = ap.add_subparsers(dest="command")

# Export command..
Expand Down Expand Up @@ -89,6 +99,10 @@ def __init__(self):

self.args = ap.parse_args()

# Synthesize some info from general arguments..
self.args.remote_url = self.args.remote.split('@')[0]
self.args.remote_name = self.args.remote.split('@')[1]

if self.args.command:
if hasattr(self, "command_"+self.args.command):
try:
Expand Down Expand Up @@ -321,8 +335,8 @@ def conan_api(self):
os.path.join(hooks_dir_dst, name))
# Add the Barbarian remote so we can find dependencies.
self.conan_api.remote_add(
"barbarian-github",
"https://barbarian.bfgroup.xyz/github",
self.args.remote_name,
self.args.remote_url,
force=True)
return self._conan_api

Expand Down Expand Up @@ -392,6 +406,10 @@ def render_template(self, template, path):
"<<<VERSION>>>", self._recipe_name_and_version[1])
text = text.replace(
"<<<BPT_PACKAGE>>>", self.bpt_package_reference)
text = text.replace(
"<<<REMOTE_URL>>>", self.args.remote_url)
text = text.replace(
"<<<REMOTE_NAME>>>", self.args.remote_name)
with open(path, "w") as file:
file.write(text)

Expand Down Expand Up @@ -507,7 +525,7 @@ def command_upload(self, args):
conan_export_tgz = self.conan_api.get_path(
recipe_ref,
path="conan_export.tgz",
remote_name="barbarian-github")
remote_name=self.args.remote_name)
finally:
# Clean up the upload tree.
chdir(cwd)
Expand Down Expand Up @@ -597,7 +615,7 @@ def command_new(self, args):

ga_conan_workflow_template = '''\
env:
CONAN_REMOTES: "https://barbarian.bfgroup.xyz/github@True@barbarian-github"
CONAN_REMOTES: "<<<REMOTE_URL>>>@True@<<<REMOTE_URL>>>"
CONAN_BUILD_POLICY: "missing"
BPT_NO_UPLOAD: yes
BPT_CONFIG_FILE_VERSION: "11"
Expand Down

0 comments on commit c0a8845

Please sign in to comment.