Commit 27420b89 authored by Pietro Albini's avatar Pietro Albini

Clone the source code of the branches during the build

This commit removes the shared git repository in the root directory:
instead, a 1-depth clone of the branch is done at the start of each
build, so the source code is guaranteed to be fresh.

This doesn't affect build times so much, because only the latest commit
is cloned, not the whole history.
parent c49b31b3
......@@ -75,7 +75,7 @@ def init_command(ctx, git_url):
error("root directory not empty")
for dir in ("git", "branches"):
for dir in ("branches",):
(root / dir).mkdir()
with (root / "version").open("w") as f:
......@@ -83,6 +83,7 @@ def init_command(ctx, git_url):
with (root / "config.json").open("w") as f:
content = {
"git-url": git_url,
"gitlab-url": "",
"gitlab-project": "ubuntu-it-web/www",
"gitlab-token": "abcdefghi",
......@@ -101,8 +102,6 @@ def init_command(ctx, git_url):
json.dump(content, f, indent=4)
f.write("\n")["git", "clone", git_url, str(root / "git"), "--bare"])
@click.option("-p", "--port", help="The port for the frontend application",
......@@ -206,7 +206,7 @@ class Branch:
git_dir = str(self.manager.root / "git")
git_url = self.manager.config["git-url"]
build_dir = branch / "build"
log_file = branch / "build.log"
......@@ -227,19 +227,16 @@ class Branch:
# Update the bare git repository and checkout the branch[
"git", "--git-dir", git_dir, "fetch", "origin"
],"a"), stderr=subprocess.STDOUT)[
"git", "--git-dir", git_dir, "--work-tree", str(build_dir),
"checkout", "-f",,
"git", "clone", "--depth", "1", "--branch",, git_url,
],"a"), stderr=subprocess.STDOUT)
# Get the commit of the branch
commit_file = branch / "commit"
["git", "--git-dir", git_dir, "rev-parse",],"w"),"a"),
"git", "--git-dir", str(build_dir / ".git"), "rev-parse",
# Copy and load the configuration file
if not (build_dir / "managetests.json").exists():
......@@ -17,7 +17,7 @@
import pathlib
def is_root_valid(path):
......@@ -27,7 +27,7 @@ def is_root_valid(path):
if not (path.exists() and path.is_dir()):
return False
required_dirs = ["git", "branches"]
required_dirs = ["branches"]
required_files = ["config.json", "details.json", "version"]
for dir in required_dirs:
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment