Note
This project is a working prototype but will not see further development, as commonrepo v2 will be developed under https://github.com/common-repo.
When that project becomes public, this repository will be archived.
January 2024
CommonRepo is a powerful tool for managing multiple inheritance in repository templates. It allows you to create and maintain template repositories that can be inherited and customized by other repositories, similar to how classes work in object-oriented programming.
- In memory compositing: Virutal in-memory filesystem compositing for ultra-fast build times and caching efficiency.
- Multiple Inheritance: Inherit from multiple template repositories
- File Filtering: Include/exclude specific files and directories
- File Renaming: Transform file paths during inheritance
- Template Support: Process template files with variables
- Version Control: Support for specific git refs (tags, branches, commits)
- Deep Cloning: Configurable depth for upstream repository inheritance
go install github.com/shakefu/commonrepo@latest
- Create a
.commonrepo.yml
file in your repository:
# Source repository configuration
include:
- "**/*" # Include all files
- ".*" # Include hidden files
- ".*/**/*" # Include hidden directories
exclude:
- ".git/**/*" # Exclude git directory
- "**/*.md" # Exclude markdown files
template:
- "templates/**" # Process files in templates directory
rename:
- "templates/(.*)": "%[1]s" # Move templates to root
# Upstream repositories to inherit from
upstream:
- url: https://github.com/example/template
ref: v1.0.0
include: [".*"]
exclude: [".gitignore"]
rename: [{".*\\.md": "docs/%[1]s"}]
# Template variables
template-vars:
project: ${PROJECT_NAME:-myprojectname}
- Run CommonRepo in your repository:
commonrepo
The source repository defines which files should be imported into child repositories:
include
: List of glob patterns for files to includeexclude
: List of glob patterns for files to excludetemplate
: List of glob patterns for template filesrename
: List of rename rules for file pathsinstall
: List of tool installation specificationsinstall-from
: Optional override for installation pathinstall-with
: Optional override for preferred install manager order
Consumer repositories can define which sources they want to inherit from:
upstream
: List of source repositories to inherit fromurl
: Repository URLref
: Git reference (tag, branch, or commit)overwrite
: Whether to overwrite existing filesinclude
: Additional include patternsexclude
: Additional exclude patternsrename
: Additional rename rules
template-vars
: Template variables for all upstreams
See testdata/fixtures/schema.yml
for a complete example of the configuration schema.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.