Fix references to code_dir
Committed a08422
--- a/webint_code/__init__.py
+++ b/webint_code/__init__.py
},
)
-code_dir = pathlib.Path("code")
-meta_dir = code_dir / "meta"
-# XXX working_dir = code_dir / "working"
-
-
-# XXX def update_system():
-# XXX print(
-# XXX subprocess.run(
-# XXX ["poetry", "update"],
-# XXX cwd=working_dir / "ragt.ag",
-# XXX capture_output=True,
-# XXX )
-# XXX )
+code_dir = pathlib.Path("code/meta")
def run_ci(project):
Execute tests.
"""
- project_dir = meta_dir / project
+ project_dir = code_dir / project
testing_dir = project_dir / "testing"
shutil.rmtree(testing_dir, ignore_errors=True)
gmpg.clone_repo(project_dir / "source.git", testing_dir)
".*/working",
query,
],
- cwd=meta_dir,
+ cwd=code_dir,
capture_output=True,
)
.stdout.decode()
def create_project(db, name):
"""Create a project."""
db.insert("projects", name=name, pypi=name, visibility="public")
- project_dir = meta_dir / name
+ project_dir = code_dir / name
bare_repo = project_dir / "source.git"
working_repo = project_dir / "working"
repo = gmpg.get_repo(bare_repo, init=True, bare=True)
subprocess.run(["chmod", "775", post_receive_hook])
subprocess.run(["chgrp", "www-data", bare_repo, working_repo, "-R"])
subprocess.run(["chmod", "g+w", bare_repo, working_repo, "-R"])
- if not (meta_dir / "gitpasswd").exists():
+ if not (code_dir / "gitpasswd").exists():
token = web.application("webint_auth").model.generate_local_token(
"/code", "webint_code", "git_owner"
)
- subprocess.run(["htpasswd", "-cb", meta_dir / "gitpasswd", "owner", token])
+ subprocess.run(["htpasswd", "-cb", code_dir / "gitpasswd", "owner", token])
# XXX subprocess.run(["sudo", "service", "nginx", "restart"])
# XXX gmpg.clone_repo(
).model.get_received_mentions_by_target(
f"{web.tx.origin}/{web.tx.request.uri.path}"
)
- project_dir = meta_dir / project
+ project_dir = code_dir / project
try:
with (project_dir / "working" / "README.md").open() as fp:
readme = fp.read()
def get(self, project, namespace):
"""Return the API's JSON."""
- return meta_dir / project / "testing" / f"deps.svg"
+ return code_dir / project / "testing" / "deps.svg"
@app.control("projects/{project}/api/{namespace}")
def get(self, project, namespace):
"""Return the API's namespace."""
- details = web.load(path=meta_dir / project / "testing" / "api_python.json")
+ details = web.load(path=code_dir / project / "testing" / "api_python.json")
return app.view.project.namespace(project, namespace, details)
def get(self, project):
"""Return the API's JSON."""
- return meta_dir / project / "testing" / "api_python.json"
+ return code_dir / project / "testing" / "api_python.json"
@app.control("projects/{project}/settings")
def get(self, project, filename=""):
"""Return a view of the repository's file."""
- project_dir = meta_dir / project
+ project_dir = code_dir / project
filepath = project_dir / "working" / filename
try:
with filepath.open() as fp:
def get(self, project, filename=""):
"""Return a view of the repository's file."""
- return meta_dir / project / "working" / filename
+ return code_dir / project / "working" / filename
@app.control("projects/{project}/commits")
def get(self, project):
"""Return a view of the repository's commit."""
- repo = gmpg.get_repo(meta_dir / project / "working")
+ repo = gmpg.get_repo(code_dir / project / "working")
return app.view.project.commit_log(project, repo)
def get(self, project, commit_id=None):
"""Return a view of the repository's commit."""
- repo = gmpg.get_repo(meta_dir / project / "working")
+ repo = gmpg.get_repo(code_dir / project / "working")
full_commit_id = repo.git("rev-parse", commit_id)[0]
if commit_id != full_commit_id:
raise web.SeeOther(f"/code/projects/{project}/commits/{full_commit_id}")
def get(self, project):
"""Return a view of the package file."""
return f"releases for {project}"
- # files = sorted((meta_dir / project / "releases" / release).iterdir())
+ # files = sorted((code_dir / project / "releases" / release).iterdir())
# return app.view.project.release(project, release, files)
"""Return a view of the package file."""
pypi_name = app.model.get_project_from_name(project)["pypi"]
files = sorted(
- (meta_dir / project / "releases" / f"{pypi_name}-{release}").iterdir()
+ (code_dir / project / "releases" / f"{pypi_name}-{release}").iterdir()
)
return app.view.project.release(project, release, files)
def get(self, project, release, filename=""):
"""Return a view of the release's file."""
pypi_name = app.model.get_project_from_name(project)["pypi"]
- filepath = meta_dir / project / "releases" / f"{pypi_name}-{release}" / filename
+ filepath = code_dir / project / "releases" / f"{pypi_name}-{release}" / filename
try:
with filepath.open() as fp:
content = fp.read()
f"{web.tx.origin}/{web.tx.request.uri.path}"
)
return [dict(r) for r in mentions]
- # files = sorted((meta_dir / project / "releases" / release).iterdir())
+ # files = sorted((code_dir / project / "releases" / release).iterdir())
# return app.view.project.release(project, release, files)
project = app.model.get_project_from_pypi_name(
release_name.replace("_", "-").replace(".", "-")
)
- releases_dir = meta_dir / project["name"] / "releases"
+ releases_dir = code_dir / project["name"] / "releases"
releases_dir.mkdir(exist_ok=True)
release_file = release_file.replace(
releases_dir / f"{release_name}-{release_remaining}"