summaryrefslogtreecommitdiff
path: root/scripts/ghpr.py
blob: 6c9f7f9f60012ea29da0080912c1fced44671ef3 (plain)
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
import sys

from pathlib import Path
from subprocess import run

ROOT_PATH = Path(__file__).parents[1]

path = sys.argv[1]

with open(path, "r") as f:
    for line in f:
        l = line.strip().split(",")
        domain, handle, name = [x.strip() for x in l]
        handle = None if "@" in handle else handle

        fn = domain.replace(".", "")

        path = ROOT_PATH / "names" / f"{fn}.yml"
        if path.exists():
            print(f"{domain} already exists")
            continue

        with open(path, "w") as out:
            s = f"domain: {domain}\nname: {name}\n"
            if handle:
                s += f"github: {handle}\n"
            s += "candidate: true\n"
            out.write(s)

        # run(["git", "checkout", "-b", domain])
        # run(["git", "add", f"names/{fn}.yml"])
        # run(["git", "commit", "-m", f"Add {domain}"])
        # run(["git", "push", "-u", "origin", domain])
        # run(["gh", "pr", "create", "-t", f"Add {domain}", "-b", f"Hey @{handle}, would you like to merge this PR adding you to https://namehack.club?"])
        # run(["git", "checkout", "main"])