-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-git.py
More file actions
53 lines (41 loc) · 1.61 KB
/
setup-git.py
File metadata and controls
53 lines (41 loc) · 1.61 KB
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
46
47
48
49
50
51
52
53
"""Script responsible for first time setup of the project's git repo.
Since this is a first time setup script, we intentionally only use builtin Python dependencies.
"""
import argparse
import subprocess
from pathlib import Path
from util import check_dependencies
from util import existing_dir
def main() -> None:
"""Parses command line input and passes it through to setup_git."""
parser: argparse.ArgumentParser = get_parser()
args: argparse.Namespace = parser.parse_args()
setup_git(path=args.path)
def setup_git(path: Path) -> None:
"""Set up the provided cookiecutter-robust-python project's git repo."""
commands: list[list[str]] = [
["git", "init"],
["git", "branch", "-m", "master", "main"],
["git", "add", "."],
["git", "commit", "-m", "feat: initial commit"],
["git", "checkout", "-b", "develop", "main"],
]
check_dependencies(path=path, dependencies=["git"])
for command in commands:
subprocess.run(command, cwd=path, stderr=subprocess.STDOUT)
def get_parser() -> argparse.ArgumentParser:
"""Creates the argument parser for setup-git."""
parser: argparse.ArgumentParser = argparse.ArgumentParser(
prog="setup-git",
usage="python ./scripts/setup-git.py . -u robust-python -n robust-python-demo",
description="Set up the provided cookiecutter-robust-python project's git repo.",
)
parser.add_argument(
"path",
type=existing_dir,
metavar="PATH",
help="Path to the repo's root directory (must already exist).",
)
return parser
if __name__ == "__main__":
main()