gitmap
Map git commits to new commits, preserving history.
Usage
- Install dependencies,
pip install -r requirements.txt. (python2 is currently unsupported.) - Inherit the class
gitmap.GitMap, and overrideblob_mapandcommit_map. Theblob_mapfunction maps a source path to a destination path, etc. Thecommit_mapfunction maps a commit message to a new message, etc. - Call
run(src_repo_path, dst_repo_path). All heads will be mapped. - Set
remove_empty_commitstoTrueif you want to remove empty commits. (A non-empty commit may be mapped to an empty commit, depending on your map function.) - Moreover, you can add blobs to each commit by overriding
commit_add, and print progress by overrideprogress. Thecommit_addreturns a list of blobs, each of which is in the same scheme asblob_map.progressis called after each commit is mapped.
Example
See example.py.
class MyGitMap(gitmap.GitMap):
def blob_map(self, data_stream, mode, path):
# keep README and LICENSE
if path in ['README.md', 'LICENSE.txt']:
return data_stream.read(), mode, path
# flatten python dir
if path.startswith('python/'):
return data_stream.read(), mode, path[len('python/'):]
# delete other files
else:
return None
def commit_add(self, old_commit):
# add .gitignore
return [
(b'__pycache__\njittor.egg-info\n', 0o100644, '.gitignore'),
]
def commit_map(self, old_commit, message, author, authored_date, author_tz_offset, committer, committed_date, committer_tz_offset):
# keep author, update committer
committer = git.Actor('Tailing Yuan', 'yuantailing@gmail.com')
committed_date = time.time()
return message, author, authored_date, author_tz_offset, committer, committed_date, committer_tz_offset
def progress(self, old_commit, new_commit):
# logging
print('committed', old_commit, '=>', new_commit)
remove_empty_commits = True
MyGitMap().run('../jittor', '../jittor-python-only')
Metadata
Release files for gitmap 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| gitmap-0.0.1.tar.gz | 3.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gitmap-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.6 kB
Release files / gitmap-0.0.1.tar.gz
| Download URL | gitmap-0.0.1.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
11e6037cce03ac102f1c1dfa5acd515fb7457f9ed28ecf661d16d9c620df9cae
|
|
BLAKE2b-256 checksum How to use checksums |
8cec7f7831bce19a7698d063a2afb9d8d37d0c68aa6062777924463d99b7218b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.2
|
Release files / gitmap-0.0.1-py3-none-any.whl
| Download URL | gitmap-0.0.1-py3-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fa278be73ff600e69742a33bf1d1e143fee02c884a413a3d34b4b3f6c2479ad2
|
|
BLAKE2b-256 checksum How to use checksums |
e52bb45593a2db929bacaa42757a5343c5fa4de6c72c8b9bd762b4d5f0b0a424
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.2
|
Security for gitmap 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.