mirror of
https://github.com/openSUSE/osc.git
synced 2024-11-10 06:46:15 +01:00
Move vc env exporting code into core.vc_export_env
This allows for reuse. In the future, these variables should also be exported when executing source services.
This commit is contained in:
parent
c534d7e990
commit
fefd7c1dea
@ -8850,37 +8850,6 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
else:
|
||||
apiurl = self.get_api_url()
|
||||
|
||||
# try to set the env variables for the user's realname and email
|
||||
# (the variables are used by the "vc" script)
|
||||
tag2envs = {'realname': ['VC_REALNAME'],
|
||||
'email': ['VC_MAILADDR', 'mailaddr']}
|
||||
tag2val = {}
|
||||
missing_tags = []
|
||||
|
||||
for (tag, envs) in tag2envs.items():
|
||||
env_present = [env for env in envs if env in os.environ]
|
||||
config_present = tag in conf.config['api_host_options'][apiurl]
|
||||
if not env_present and not config_present:
|
||||
missing_tags.append(tag)
|
||||
elif config_present:
|
||||
tag2val[tag] = conf.config['api_host_options'][apiurl][tag]
|
||||
|
||||
if missing_tags:
|
||||
user = conf.get_apiurl_usr(apiurl)
|
||||
data = get_user_data(apiurl, user, *missing_tags)
|
||||
if data is not None:
|
||||
for tag in missing_tags:
|
||||
val = data.pop(0)
|
||||
if val != '-':
|
||||
tag2val[tag] = val
|
||||
else:
|
||||
msg = 'Try env %s=...' % tag2envs[tag][0]
|
||||
print(msg, file=sys.stderr)
|
||||
|
||||
for (tag, val) in tag2val.items():
|
||||
for env in tag2envs[tag]:
|
||||
os.environ[env] = val
|
||||
|
||||
if meego_style:
|
||||
if opts.message or opts.just_edit:
|
||||
print('Warning: to edit MeeGo style changelog, opts will be ignored.', file=sys.stderr)
|
||||
@ -8899,6 +8868,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
|
||||
cmd_list.extend(args)
|
||||
|
||||
vc_export_env(apiurl)
|
||||
vc = Popen(cmd_list)
|
||||
vc.wait()
|
||||
sys.exit(vc.returncode)
|
||||
|
33
osc/core.py
33
osc/core.py
@ -7786,4 +7786,37 @@ def checkout_deleted_package(apiurl, proj, pkg, dst):
|
||||
f.write(data)
|
||||
print('done.')
|
||||
|
||||
def vc_export_env(apiurl, quiet=False):
|
||||
# try to set the env variables for the user's realname and email
|
||||
# (the variables are used by the "vc" script)
|
||||
tag2envs = {'realname': ['VC_REALNAME'],
|
||||
'email': ['VC_MAILADDR', 'mailaddr']}
|
||||
tag2val = {}
|
||||
missing_tags = []
|
||||
|
||||
for (tag, envs) in tag2envs.items():
|
||||
env_present = [env for env in envs if env in os.environ]
|
||||
config_present = tag in conf.config['api_host_options'][apiurl]
|
||||
if not env_present and not config_present:
|
||||
missing_tags.append(tag)
|
||||
elif config_present:
|
||||
tag2val[tag] = conf.config['api_host_options'][apiurl][tag]
|
||||
|
||||
if missing_tags:
|
||||
user = conf.get_apiurl_usr(apiurl)
|
||||
data = get_user_data(apiurl, user, *missing_tags)
|
||||
if data is not None:
|
||||
for tag in missing_tags:
|
||||
val = data.pop(0)
|
||||
if val != '-':
|
||||
tag2val[tag] = val
|
||||
elif not quiet:
|
||||
msg = 'Try env %s=...' % tag2envs[tag][0]
|
||||
print(msg, file=sys.stderr)
|
||||
|
||||
for (tag, val) in tag2val.items():
|
||||
for env in tag2envs[tag]:
|
||||
os.environ[env] = val
|
||||
|
||||
|
||||
# vim: sw=4 et
|
||||
|
Loading…
Reference in New Issue
Block a user