-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgit_ops.py
More file actions
28 lines (23 loc) · 987 Bytes
/
git_ops.py
File metadata and controls
28 lines (23 loc) · 987 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
"""Git helpers for the entropy experiment. All ops scoped to the workspace dir."""
import subprocess
def init_repo(workspace: str) -> None:
"""Initialize a git repo in the workspace with local-only config."""
subprocess.run(["git", "init"], cwd=workspace, check=True, capture_output=True)
subprocess.run(
["git", "config", "user.email", "entropy@experiment.local"],
cwd=workspace, check=True, capture_output=True,
)
subprocess.run(
["git", "config", "user.name", "Entropy Experiment"],
cwd=workspace, check=True, capture_output=True,
)
def commit_all(workspace: str, message: str) -> None:
"""Stage all files and commit with the given message. Allows empty commits."""
subprocess.run(
["git", "add", "-A"],
cwd=workspace, check=True, capture_output=True,
)
subprocess.run(
["git", "commit", "-m", message, "--allow-empty"],
cwd=workspace, check=True, capture_output=True,
)