-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathdocker-run
More file actions
executable file
·30 lines (24 loc) · 859 Bytes
/
docker-run
File metadata and controls
executable file
·30 lines (24 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python3
from __future__ import annotations
import os
import subprocess
import sys
from typing import NoReturn
def main() -> NoReturn:
cfg = ('git', 'config')
name = subprocess.check_output((*cfg, 'user.name')).decode().strip()
email = subprocess.check_output((*cfg, 'user.email')).decode().strip()
interactive = '-ti' if sys.stdin.isatty() else '-i'
cmd = (
'docker', 'run', '--rm', interactive,
'--env', f'GIT_AUTHOR_NAME={name}',
'--env', f'GIT_AUTHOR_EMAIL={email}',
'--env', f'GIT_COMMITTER_NAME={name}',
'--env', f'GIT_COMMITTER_EMAIL={email}',
'--env', f'DEBFULLNAME={os.environ["DEBFULLNAME"]}',
'--env', f'DEBEMAIL={os.environ["DEBEMAIL"]}',
*sys.argv[1:],
)
os.execvp(cmd[0], cmd)
if __name__ == '__main__':
raise SystemExit(main())