Skip to content

Commit

Permalink
base: Clone git repo if present instead of rsync
Browse files Browse the repository at this point in the history
I am guessing I may be one of the first people to try using tmt
with a Rust project. The default for the `cargo` toolchain
is to keep a *lot* of cached incremental data in `target/`.
In my case with bootc, it's currently 20G.

A plain rsync() of this is *incredibly* inefficient. rsync doesn't
even use reflinks if available, though that's a distinct bug.

Change the logic here to do a `git clone -s` which is *way*
more efficient; it properly honors my `.gitignore` which
includes `target/`.

Signed-off-by: Colin Walters <[email protected]>
  • Loading branch information
cgwalters committed Jun 21, 2024
1 parent 90bdfc6 commit cc59390
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tmt/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1796,7 +1796,12 @@ def _initialize_worktree(self) -> None:

# Sync metadata root to the worktree
self.debug(f"Sync the worktree to '{self.worktree}'.", level=2)
self.run(Command("rsync", "-ar", "--exclude", ".git", f"{tree_root}/", self.worktree))
# If we're in a git repository, we just clone it so that we correctly
# honor .gitignore, etc.
if os.path.isdir(f"{tree_root}/.git"):
self.run(Command("git", "clone", "-s", tree_root, self.worktree))
else:
self.run(Command("rsync", "-ar", "--exclude", ".git", f"{tree_root}/", self.worktree))

def _initialize_data_directory(self) -> None:
"""
Expand Down

0 comments on commit cc59390

Please sign in to comment.