Skip to content

Commit

Permalink
feat: cleanup git repository before doing project backup
Browse files Browse the repository at this point in the history
This can considerably reduce backup sizes for repos using squashing and
rebasing.
  • Loading branch information
nijel committed Jan 30, 2025
1 parent 565464a commit 18ea371
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions weblate/trans/backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,11 @@ def backup_component(self, backupzip, component) -> None:
# Store VCS repo in case it is present
if component.is_repo_link:
return

# Compact the repository
component.repo.compact()

# Actually perform the backup
self.backup_dir(
backupzip,
component.full_path,
Expand Down
3 changes: 3 additions & 0 deletions weblate/vcs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,3 +562,6 @@ def get_remote_branch_name(self, branch: str | None = None) -> str:

def list_remote_branches(self):
return []

def compact(self) -> None:
return
3 changes: 3 additions & 0 deletions weblate/vcs/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,9 @@ def status(self):

return "\n".join(result)

def compact(self) -> None:
self.execute(["gc"])


class GitWithGerritRepository(GitRepository):
name = "Gerrit"
Expand Down

0 comments on commit 18ea371

Please sign in to comment.