Skip to content

Commit c127001

Browse files
authored
Recursive fork (#106)
* add recurse_fork script * remove kurono badges submodule * add devcontainer * add setup script * create run script * move config command to folder * fix relative paths and use python 3.12 * simplify forking * simplify script * Fix clone path * setup git * remove unnecessary escape * simplify * print before command
1 parent 937a60d commit c127001

16 files changed

+507
-29
lines changed

.devcontainer.json

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"customizations": {
3+
"vscode": {
4+
"extensions": [
5+
"visualstudioexptteam.vscodeintellicode",
6+
"github.vscode-pull-request-github",
7+
"redhat.vscode-yaml",
8+
"davidanson.vscode-markdownlint",
9+
"bierner.markdown-mermaid",
10+
"streetsidesoftware.code-spell-checker",
11+
"ms-python.python",
12+
"ms-python.debugpy",
13+
"ms-python.pylint",
14+
"ms-python.isort",
15+
"ms-python.vscode-pylance",
16+
"ms-python.mypy-type-checker",
17+
"ms-python.black-formatter",
18+
"njpwerner.autodocstring",
19+
"tamasfe.even-better-toml",
20+
]
21+
}
22+
},
23+
"dockerComposeFile": [
24+
"./docker-compose.yml"
25+
],
26+
"features": {
27+
"ghcr.io/devcontainers-contrib/features/pipenv:2": {
28+
"version": "2023.11.15"
29+
},
30+
"ghcr.io/devcontainers/features/python:1": {
31+
"installTools": false,
32+
"version": "3.12"
33+
},
34+
"ghcr.io/devcontainers/features/github-cli:1": {}
35+
},
36+
"name": "workspace",
37+
"postCreateCommand": ".submodules/recurse-fork/run",
38+
"remoteUser": "root",
39+
"service": "base-service",
40+
"shutdownAction": "none",
41+
"workspaceFolder": "/workspace"
42+
}

.gitmodules

-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
[submodule "codeforlife-portal-react"]
2323
path = codeforlife-portal-react
2424
url = https://github.com/ocadotechnology/codeforlife-portal-react.git
25-
[submodule "codeforlife-kurono-badges"]
26-
path = codeforlife-kurono-badges
27-
url = https://github.com/ocadotechnology/codeforlife-kurono-badges.git
2825
[submodule "codeforlife-sso"]
2926
path = codeforlife-sso
3027
url = https://github.com/ocadotechnology/codeforlife-sso.git
File renamed without changes.

.submodules/Pipfile .submodules/config/Pipfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ mypy = "==1.6.1"
1212
pylint = "==3.0.2"
1313

1414
[requires]
15-
python_version = "3.11"
15+
python_version = "3.12"

.submodules/Pipfile.lock .submodules/config/Pipfile.lock

+17-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.submodules/__main__.py .submodules/config/__main__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from configs import GlobalSubmoduleConfig, JsonDict, JsonValue, load_global_configs
2121
from helpers import (
22-
DOT_SUBMODULES_DIR,
22+
CONFIG_DIR,
2323
GIT_PUSH_CHANGES,
2424
git_commit_and_push,
2525
merge_json_dicts,
@@ -145,7 +145,7 @@ def main() -> None:
145145
# Merge inherited configs and config into submodule in order.
146146
for submodule in global_config.submodules:
147147
# Change directory to submodule's directory.
148-
os.chdir(f"{DOT_SUBMODULES_DIR}/../{submodule}")
148+
os.chdir(f"{CONFIG_DIR}/../../{submodule}")
149149

150150
for inheritance in inheritances[key]:
151151
merge_global_config(global_configs[inheritance])
@@ -154,7 +154,7 @@ def main() -> None:
154154

155155
if GIT_PUSH_CHANGES:
156156
git_commit_and_push(message="Configured submodule [skip ci]")
157-
os.chdir(f"{DOT_SUBMODULES_DIR}/..")
157+
os.chdir(f"{CONFIG_DIR}/../..")
158158
subprocess.run(["git", "add", submodule], check=True)
159159

160160
print("---")
File renamed without changes.

.submodules/configs.py .submodules/config/configs.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from collections import Counter
1111
from dataclasses import dataclass
1212

13-
from helpers import DOT_SUBMODULES_DIR, load_jsonc
13+
from helpers import CONFIG_DIR, load_jsonc
1414

1515
# JSON type hints.
1616
JsonList = t.List["JsonValue"]
@@ -61,7 +61,7 @@ class GlobalSubmoduleConfig:
6161

6262
def load_global_configs() -> t.Tuple[GlobalConfigDict, InheritanceDict]:
6363
# Change directory to .submodules.
64-
os.chdir(DOT_SUBMODULES_DIR)
64+
os.chdir(CONFIG_DIR)
6565

6666
# Load the configs file.
6767
with open("configs.jsonc", "r", encoding="utf-8") as configs_file:

.submodules/helpers.py .submodules/config/helpers.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111
import subprocess
1212
import typing as t
1313
from io import TextIOWrapper
14+
from pathlib import Path
1415

1516
if t.TYPE_CHECKING:
1617
from configs import AnyJsonValue, JsonDict, JsonList, JsonValue
1718

18-
# Path to the .submodules directory.
19-
DOT_SUBMODULES_DIR = os.path.dirname(os.path.realpath(__file__))
19+
# Path to the .submodules/config directory.
20+
CONFIG_DIR = Path(__file__).resolve().parent
2021
# Whether or not to git-push the changes.
2122
GIT_PUSH_CHANGES = bool(int(os.getenv("GIT_PUSH_CHANGES", "0")))
2223

.submodules/config/run

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
set -e
3+
4+
cd "${BASH_SOURCE%/*}"
5+
6+
pipenv install --dev
7+
8+
pipenv run python .

.submodules/recurse-fork/.venv/.gitkeep

Whitespace-only changes.

.submodules/recurse-fork/Pipfile

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[[source]]
2+
url = "https://pypi.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[packages]
7+
colorama = "==0.4.6"
8+
9+
[dev-packages]
10+
black = "==23.1.0"
11+
pytest = "==7.2.1"
12+
mypy = "==1.6.1"
13+
pylint = "==3.0.2"
14+
types-colorama = "==0.4.15.20240311"
15+
16+
[requires]
17+
python_version = "3.12"

0 commit comments

Comments
 (0)