-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost-sync.py
More file actions
33 lines (26 loc) · 1.05 KB
/
post-sync.py
File metadata and controls
33 lines (26 loc) · 1.05 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
"""
Post sync hook for repo to configure the devcontainer.
"""
from pathlib import Path
import shutil
import sys
MANIFEST_PATH = "manifest"
def main(repo_topdir=None, **kwargs):
"""Main function invoked directly by repo.
We must use the name "main" as that is what repo requires.
Args:
repo_topdir: The absolute path to the top-level directory of the repo workspace.
kwargs: Leave this here for forward-compatibility.
"""
repo = Path(repo_topdir)
devcontainer_path = repo / ".devcontainer"
devcontainer_path.mkdir(exist_ok=True)
configuration = repo / MANIFEST_PATH / "devcontainer.json"
if configuration.exists():
shutil.copy(configuration, devcontainer_path / "devcontainer.json")
print("Devcontainer configuration applied successfully.")
else:
print(f"Warning: No devcontainer.json found at {configuration}. Skipping devcontainer configuration.")
if __name__ == "__main__":
repo_path = Path(sys.argv[1]) if len(sys.argv) == 2 else Path(__file__).parent.parent
main(repo_path)