https://github.com/juliaaplavin/gitfilterrepo.jl
Julia wrapper for git-filter-repo tool for advanced Git history rewriting and repository manipulation.
https://github.com/juliaaplavin/gitfilterrepo.jl
git history-rewriting repository-tools wrapper
Last synced: about 2 months ago
JSON representation
Julia wrapper for git-filter-repo tool for advanced Git history rewriting and repository manipulation.
- Host: GitHub
- URL: https://github.com/juliaaplavin/gitfilterrepo.jl
- Owner: JuliaAPlavin
- License: mit
- Created: 2024-02-18T17:57:27.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2025-03-16T12:17:18.000Z (over 1 year ago)
- Last Synced: 2025-12-30T22:45:24.610Z (6 months ago)
- Topics: git, history-rewriting, repository-tools, wrapper
- Language: Julia
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GitFilterRepo.jl
Julia wrapper around [git-filter-repo](https://github.com/newren/git-filter-repo), a tool for rewriting Git repository history. It's the recommended replacement for `git filter-branch`: fast, scriptable, and safe. Common use cases include removing large files from history, rewriting author information, renaming paths, and editing commit messages across an entire repository.
This package provides both the raw `git-filter-repo` Python API and convenience Julia wrappers on top of it. No additional setup is required after installation: the Python module gets automatically downloaded using the `Artifacts` system.
# API
The package exposes callback types for different kinds of history rewriting: `CommitCallback`, `BlobCallback`, `FilenameCallback`, `MessageCallback`, `EmailCallback`, `NameCallback`, `TagCallback`, and others. Each can be used with `RepoFilter` to process the repository. See the [upstream documentation](https://github.com/newren/git-filter-repo) for the full reference on the underlying Python API.
# Examples
```julia
import GitFilterRepo as GFR
```
Gather all commit messages (raw API):
```julia
options = GFR.FilteringOptions.default_options()
commits = []
rfilter = GFR.RepoFilter(options; commit_callback=(commit, meta) -> push!(commits, commit))
rfilter.run()
[c.message for c in commits]
```
Rename files across the entire history:
```julia
GFR.RepoFilter(GFR.FilenameCallback) do filename
replace(filename, "old/path" => "new/path")
end.run()
```
Truncate all commit dates to the year (date fields are automatically converted to/from Julia `DateTime`):
```julia
using Dates
GFR.RepoFilter(GFR.CommitCallback) do commit, meta
commit.author_date = trunc(commit.author_date, Year)
commit.committer_date = trunc(commit.committer_date, Year)
end.run()
```
Prefix all commit messages:
```julia
GFR.RepoFilter(GFR.MessageCallback) do message
"chore: " * message
end.run()
```
# Utilities
`clone_process_push` provides a complete clone → filter → push workflow. It clones a source repo into a temp directory, runs your filtering function, then pushes to a destination (with a dry-run confirmation step):
```julia
GFR.clone_process_push(; source="git@github.com:user/old-repo.git", destination="git@github.com:user/new-repo.git") do
GFR.RepoFilter(GFR.CommitCallback) do commit, meta
commit.author_email = "new@email.com"
end.run()
end
```