forked from fastai/course-v3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-after-git-clone
executable file
·34 lines (25 loc) · 1.01 KB
/
run-after-git-clone
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
#!/usr/bin/env python3
# if you're a fastai developer please make sure you do this:
#
# git clone https://github.com/fastai/fastai_docs
# cd fastai_docs
# tools/run-after-git-clone
#
import sys
if sys.hexversion < 0x03060000: sys.exit("!!! Please re-run this script with python-3.6 or higher")
import subprocess, os
from pathlib import Path
def run_script(script):
cmd = f"{sys.executable} {script}"
#print(f"Executing: {cmd}")
result = subprocess.run(cmd.split(), shell=False, check=False,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if result.returncode != 0: print(f"Failed to execute: {cmd}")
if result.stdout: print(f"{result.stdout.decode('utf-8')}")
if result.stderr: print(f"Error: {result.stderr.decode('utf-8')}")
# make sure we are under the root of the project
cur_dir = Path(".").resolve().name
if (cur_dir == "tools"): os.chdir("..")
path = Path("tools")
# facilitate trusting of the repo-wide .gitconfig
run_script(path/"trust-origin-git-config")