Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ macOS builds now default to Homebrew's `openssl@3` instead of the removed `opens
If `openssl@3` is not installed, run `brew install openssl@3` on existing macOS
runners before you update `bench_runner`.

#### Reuse checkouts at the requested commit

When a repository is already checked out at the requested full commit hash,
reuse it instead of deleting and cloning it again.

#### Use PGO on weekly builds

Since 2.0.0, PGO was not being used on weekly builds. This is now fixed.
Expand Down
2 changes: 1 addition & 1 deletion bench_runner/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def clone(

dirname = Path(dirname)
if dirname.is_dir():
if is_hash and (dirname / ".git").is_dir() and get_git_hash(dirname) == branch:
if is_hash and (dirname / ".git").is_dir() and get_log("%H", dirname) == branch:
# This is a git repo, and the hash matches
return
util.smart_rmtree(dirname)
Expand Down
41 changes: 41 additions & 0 deletions tests/test_git.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import subprocess


import pytest


from bench_runner import git


@pytest.mark.parametrize("reuse", [True, False])
def test_clone_existing_checkout(tmp_path, reuse):
repo = tmp_path / "repo"
subprocess.check_call(["git", "init", "--object-format=sha1", repo])
commit = [
"git",
"-c",
"user.name=Test",
"-c",
"user.email=test@example.com",
"commit",
"--no-gpg-sign",
"--allow-empty",
"-m",
"Test commit",
]
subprocess.check_call(commit, cwd=repo)
commit_hash = git.get_log("%H", repo)
checkout = tmp_path / "checkout"
git.clone(checkout, str(repo), branch=commit_hash)
subprocess.check_call(["git", "config", "core.abbrev", "7"], cwd=checkout)
build_output = checkout / "build-output"
build_output.touch()

if not reuse:
subprocess.check_call(commit, cwd=repo)
commit_hash = git.get_log("%H", repo)

git.clone(checkout, str(repo), branch=commit_hash)

assert build_output.exists() == reuse
assert git.get_log("%H", checkout) == commit_hash
Loading