Skip to content

Commit ecb60f1

Browse files
vladakVladimir Kotal
authored andcommitted
allow hook scipts to benefit from proxy environment
1 parent d49429b commit ecb60f1

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

tools/sync/hook.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import logging
2727

2828

29-
def run_hook(logger, script, path):
29+
def run_hook(logger, script, path, env):
3030
"""
3131
Change a working directory to specified path, run a command
3232
and change the working directory back to its original value.
@@ -37,7 +37,7 @@ def run_hook(logger, script, path):
3737
ret = 0
3838
logger.debug("Running hook '{}' in directory {}".
3939
format(script, path))
40-
cmd = Command([script], work_dir=path)
40+
cmd = Command([script], work_dir=path, env_vars=env)
4141
cmd.execute()
4242
if cmd.state is not "finished" or cmd.getretcode() != 0:
4343
logger.error("command failed: {} -> {}".format(cmd, cmd.getretcode()))

tools/sync/mirror.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,9 @@
243243
try:
244244
with lock.acquire(timeout=0):
245245
if prehook and run_hook(logger, prehook,
246-
os.path.join(source_root,
247-
args.project)) != 0:
246+
os.path.join(source_root, args.project),
247+
config['proxy'] if use_proxy else None
248+
) != 0:
248249
logger.error("pre hook failed")
249250
logging.shutdown()
250251
sys.exit(1)
@@ -286,8 +287,9 @@
286287
ret = 1
287288

288289
if posthook and run_hook(logger, posthook,
289-
os.path.join(source_root,
290-
args.project)) != 0:
290+
os.path.join(source_root, args.project),
291+
config['proxy'] if use_proxy else None
292+
) != 0:
291293
logger.error("post hook failed")
292294
logging.shutdown()
293295
sys.exit(1)

0 commit comments

Comments
 (0)