{"id":20640117,"url":"https://github.com/maresb/migrate-code","last_synced_at":"2026-06-01T04:01:37.516Z","repository":{"id":107327206,"uuid":"541318811","full_name":"maresb/migrate-code","owner":"maresb","description":"Programmatically create and revert a sequence of commits","archived":false,"fork":false,"pushed_at":"2022-09-25T22:04:16.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-19T12:28:17.562Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maresb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-25T21:50:02.000Z","updated_at":"2022-09-25T21:58:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"1d04ca70-2adb-4b29-87c4-cbb8e96a1b83","html_url":"https://github.com/maresb/migrate-code","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"3b945d8c67cf566bf3bc566cf0d39852acee88bd"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/maresb/migrate-code","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maresb%2Fmigrate-code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maresb%2Fmigrate-code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maresb%2Fmigrate-code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maresb%2Fmigrate-code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maresb","download_url":"https://codeload.github.com/maresb/migrate-code/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maresb%2Fmigrate-code/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33759178,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-01T02:00:06.963Z","response_time":115,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T15:28:01.850Z","updated_at":"2026-06-01T04:01:37.499Z","avatar_url":"https://github.com/maresb.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# migrate-code\n\n[![PyPI - Version](https://img.shields.io/pypi/v/migrate-code.svg)](https://pypi.org/project/migrate-code)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/migrate-code.svg)](https://pypi.org/project/migrate-code)\n\n______________________________________________________________________\n\n**Table of Contents**\n\n- [migrate-code](#migrate-code)\n  - [Links](#links)\n  - [Installation](#installation)\n  - [Quickstart](#quickstart)\n  - [License](#license)\n\n## Links\n\n- [GitLab](https://gitlab.com/bmares/migrate-code)\n- [GitHub](https://github.com/maresb/migrate-code)\n\n## Installation\n\n```console\npip install migrate-code\n```\n\n## Quickstart\n\nMigration stages will be converted into commits when the upgrade is applied. The `migration.py` file should define a `Migration` variable either called `m` or `migration`.\n\n```file\n# migration.py\n\nfrom migrate_code import Migration, get_repo_root\n\nm = Migration(\"Demonstrate basic usage\")\n\n@m.add_stage(1, \"Create a new file\")\ndef stage_1():\n    (get_repo_root() / \"new_file.txt\").write_text(\"Hello world\")\n\n\n@m.add_stage(2, \"Create another file\")\ndef stage_2():\n    (get_repo_root() / \"another_file.txt\").write_text(\"Hello another world\")\n\n\n@m.add_stage(\"1.1\", \"Modify the first file\")\ndef stage_1_1():\n    (get_repo_root() / \"new_file.txt\").write_text(\"Hello world, again\")\n```\n\nNow it is easy to create and reset commits:\n\n```console\n$ git init\n$ git add migration.py\n$ git commit -m \"Add migration.py\"\n$ migrate-code log\n  ------- (2) Create another file\n  ------- (1.1) Modify the first file\n  ------- (1) Create a new file\n$ migrate-code current\nNone\n$ migrate-code upgrade\nRunning migration 1: Create a new file\nRunning migration 1.1: Modify the first file\nRunning migration 2: Create another file\n$ git log --oneline\n5041191 (HEAD -\u003e master) Create another file\n92012af Modify the first file\nd4d0611 Create a new file\n78438e2 Add migration.py\n$ migrate-code log\n* 5041191 (2) Create another file\n  92012af (1.1) Modify the first file\n  d4d0611 (1) Create a new file\n$ migrate-code current\n2\n$ migrate-code reset\nResetting migration 2: Create another file\nResetting migration 1.1: Modify the first file\nResetting migration 1: Create a new file\n$ git log --oneline\n78438e2 (HEAD -\u003e master) Add migration.py\n$ migrate-code log\n  ------- (2) Create another file\n  ------- (1.1) Modify the first file\n  ------- (1) Create a new file\n$ migrate-code upgrade --stage 1.1\nRunning migration 1: Create a new file\nRunning migration 1.1: Modify the first file\n$ git log --oneline\n7b65210 (HEAD -\u003e master) Modify the first file\na7c1027 Create a new file\n78438e2 Add migration.py\n$ migrate-code log\n  ------- (2) Create another file\n* 7b65210 (1.1) Modify the first file\n  a7c1027 (1) Create a new file\n```\n\n## License\n\n`migrate-code` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaresb%2Fmigrate-code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaresb%2Fmigrate-code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaresb%2Fmigrate-code/lists"}