-
Notifications
You must be signed in to change notification settings - Fork 0
/
depends_on_stage1
executable file
·45 lines (32 loc) · 1.13 KB
/
depends_on_stage1
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python3
"Stage1: extract the main change and call stage2."
import argparse
import os
import sys
from depends_on.common import extract_depends_on, init_sensitive_strings, log
def main(args):
"Main function."
init_sensitive_strings()
# parse the command line
# -e or --extra-dir to add a directory to the list of directories to scan
# -h or --help to display the help
# 1 argument: the url of the change
extra_dirs = []
argparser = argparse.ArgumentParser()
argparser.add_argument(
"-e", "--extra-dir", action="append", dest="extra_dirs", default=[]
)
argparser.add_argument("url", nargs=1)
parsed_args = argparser.parse_args(args[1:])
url = parsed_args.url[0]
extra_dirs = parsed_args.extra_dirs
_, data = extract_depends_on(url, False, extra_dirs)
top_dir = data["top_dir"]
log(f"+ chdir {top_dir}")
os.chdir(top_dir)
stage2 = os.path.join(os.path.dirname(__file__), "depends_on_stage2")
log(f"+ {stage2}")
os.execl(stage2, "depends_on_stage2", "false")
if __name__ == "__main__":
sys.exit(main(sys.argv))
# depends_on_stage1 ends here