-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-invalid.py
78 lines (61 loc) · 2.01 KB
/
make-invalid.py
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python
import click
import os
import subprocess
import sys
@click.command()
@click.option("--location", required=True, help="Location to create demo repository")
def main(location):
if not os.path.exists(location):
print("Repository not found")
sys.exit(1)
current_dir = os.getcwd()
keys_dir = os.path.join(current_dir, "keys")
os.chdir(location)
result = subprocess.run(["git", "config", "--local", "user.name", "Aditya Sirish"])
if result.returncode != 0:
print("Unable to set Git config")
sys.exit(1)
result = subprocess.run(
["git", "config", "--local", "user.email", "aditya@saky.in"]
)
if result.returncode != 0:
print("Unable to set Git config")
sys.exit(1)
result = subprocess.run(["git", "config", "--local", "gpg.format", "ssh"])
if result.returncode != 0:
print("Unable to set Git config")
sys.exit(1)
result = subprocess.run(
[
"git",
"config",
"--local",
"user.signingkey",
f"{os.path.join(keys_dir, 'ossna-1')}",
]
)
if result.returncode != 0:
print("Unable to set Git config")
sys.exit(1)
result = subprocess.run(["gittuf", "verify-ref", "main"])
if result.returncode != 0:
print("Repository is already in invalid state")
sys.exit(1)
result = subprocess.run(["git", "checkout", "main"])
if result.returncode != 0:
print("Unable to checkout main branch")
sys.exit(1)
with open("README.md", "w+") as fp:
fp.write("yolo")
subprocess.run(["git", "add", "README.md"])
result = subprocess.run(["git", "commit", "-S", "-m", "YOLO"])
if result.returncode != 0:
print("Unable to create bad commit")
sys.exit(1)
result = subprocess.run(["gittuf", "rsl", "record", "main"])
if result.returncode != 0:
print("Unable to create bad RSL entry")
sys.exit(1)
if __name__ == "__main__":
main()