Retrocookie
Project description
Retrocookie imports commits from a Cookiecutter instance into the template.
When developing Cookiecutter templates, you often need to work in a generated project rather than the template itself. Reasons for this include the following:
You need to run the Continuous Integration suite for the generated project
Your development tools choke when running on the templated project
Any changes you make in the generated project need to be backported into the template, carefully replacing expanded variables from cookiecutter.json by templating tags, and escaping any use of {{ and }} or other tokens with special meaning in Jinja.
Retrocookie helps you in this situation.
It is designed to fetch commits from the repository of a generated project, and import them into your Cookiecutter repository, rewriting them on the fly to insert templating tags, escape Jinja-special constructs, and place files in the template directory.
Under the hood, Retrocookie clones the generated project to a temporary directory and rewrites the clone using git-filter-repo. It then fetches and cherry-picks the rewritten commits into the template using pygit2.
Maybe you’re thinking, how can this possibly work? One cannot reconstruct a Jinja template from its rendered output. However, simple replacements of template variables work well in practice when you’re only importing a handful of commits at a time.
Requirements
Python 3.7+
git >= 2.22.0
Installation
You can install Retrocookie via pip from PyPI:
$ pip install retrocookie
Usage
The basic form:
$ retrocookie <repository> [<commits>...]
$ retrocookie <repository> -b <branch> [--create]
The <repository> is a filesystem path to the source repository. For <commits>, see gitrevisions(7).
Import HEAD from <repository>:
$ retrocookie <repository>
Import the last two commits:
$ retrocookie <repository> HEAD~2..
Import by commit hash:
$ retrocookie <repository> 53268f7 6a3368a c0b4c6c
Import commits from branch topic:
$ retrocookie <repository> --branch=topic
Equivalently:
$ retrocookie <repository> master..topic
Import commits from topic into a branch with the same name:
$ retrocookie <repository> --branch=topic --create
Equivalently, using short options:
$ retrocookie <repository> -cb topic
Import commits from branch topic, which was branched off 1.0:
$ retrocookie <repository> --branch=topic --upstream=1.0
Equivalently:
$ retrocookie <repository> 1.0..topic
Import HEAD into a new branch topic:
$ retrocookie <repository> --create-branch=topic
Contributing
Contributions are very welcome. To learn more, see the Contributor Guide.
License
Distributed under the terms of the MIT license, Retrocookie is free and open source software.
Issues
If you encounter any problems, please file an issue along with a detailed description.
Credits
This project was generated from @cjolowicz’s Hypermodern Python Cookiecutter template.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for retrocookie-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ae81f79dfe1c6d71c8b900ff0dfe36f0c76ad4321931e5c921c2443d0b6f5c6 |
|
MD5 | d40c568ca1a63ff73155ecd8c89b8346 |
|
BLAKE2b-256 | 2734fc6806f30a2c698c8188026c4458b6800afdbde3cc8c082e441c1fc0a263 |