# Multi repo automation
## Configuration
To be able to apply your changes on multiple repository you should create a file with something like this:
```yaml
- dir: /home/user/src/my-repo
name: user/my-repo
types: ['javascript', 'python', 'docker']
master_branch: master
stabilization_branches: [1.0, 1.1]
folders_to_clean: []
```
The main configuration is a YAML file `~/.config/multi-repo-automation.yaml` with the following options:
`repos_filename`: the filename of the files with the repositories definitions create above, default is `repos.yaml`.
`browser`: the browser to use to open the pull requests, default is `xdg-open`.
`editor`: the editor to use to edit files, default is `xdg-open`.
## Migration script base
```python
#!/usr/bin/env python3
import multi_repo_automation as mra
def _do() -> None:
# Your actions
if __name__ == "__main__":
mra.main(
_do,
config={
# pull_request_on_stabilization_branches: To apply the action on all stabilization (including master) branches.
# pull_request_title: The pull request title.
# pull_request_body: The pull request body.
# branch: The created branch branch name.
# pull_request_branch_prefix: The created branch prefix (used when we run it on all the stabilization branches).
},
)
```
Use the `--help` option to see the available options.
## Utilities
```python
import multi_repo_automation as mra
# Test if a file exists
if mra.run(["git", "ls-files", "**/*.txt"], stdout=subprocess.PIPE).stdout.strip() != "":
print("Found")
# Get all YAML files:
mra.all_filenames_identify("yaml")
# Test if a file exists and contains a text
if mra.git_grep(file, r"\<text\>"]):
print("Found")
# Edit a files manually
mra.edit(["file"])
```
### Edit file programmatically
```python
with mra.Edit('my-file.txt') as edit:
edit.content = edit.content.replace('<from>', '<to>')
```
### Edit YAML file programmatically
```python
with mra.EditYAML('my-file.yaml') as edit:
edit.setdefault('dict', {})['prop'] = 'value'
```
### Edit TOML file programmatically
```python
with mra.EditTOML('my-file.toml') as edit:
edit.setdefault('dict', {})['prop'] = 'value'
```
### Edit Config file programmatically
```python
with mra.EditConfigL('my-file.ini') as edit:
edit.setdefault('dict', {})['prop'] = 'value'
```
## Contributing
Install the pre-commit hooks:
```bash
pip install pre-commit
pre-commit install --allow-missing-config
```
Raw data
{
"_id": null,
"home_page": "https://github.com/sbrunner/multi-repo-automation",
"name": "multi-repo-automation",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "pre-commit",
"author": "St\u00e9phane Brunner",
"author_email": "stephane.brunner@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/76/4a/9796aa1280d75737fb341f2b99f16cc653fa6b5466914d0538db280d5ff4/multi_repo_automation-1.4.2.tar.gz",
"platform": null,
"description": "# Multi repo automation\n\n## Configuration\n\nTo be able to apply your changes on multiple repository you should create a file with something like this:\n\n```yaml\n- dir: /home/user/src/my-repo\n name: user/my-repo\n types: ['javascript', 'python', 'docker']\n master_branch: master\n stabilization_branches: [1.0, 1.1]\n folders_to_clean: []\n```\n\nThe main configuration is a YAML file `~/.config/multi-repo-automation.yaml` with the following options:\n\n`repos_filename`: the filename of the files with the repositories definitions create above, default is `repos.yaml`.\n`browser`: the browser to use to open the pull requests, default is `xdg-open`.\n`editor`: the editor to use to edit files, default is `xdg-open`.\n\n## Migration script base\n\n```python\n#!/usr/bin/env python3\n\nimport multi_repo_automation as mra\n\ndef _do() -> None:\n # Your actions\n\nif __name__ == \"__main__\":\n mra.main(\n _do,\n config={\n # pull_request_on_stabilization_branches: To apply the action on all stabilization (including master) branches.\n # pull_request_title: The pull request title.\n # pull_request_body: The pull request body.\n # branch: The created branch branch name.\n # pull_request_branch_prefix: The created branch prefix (used when we run it on all the stabilization branches).\n },\n )\n```\n\nUse the `--help` option to see the available options.\n\n## Utilities\n\n```python\nimport multi_repo_automation as mra\n\n# Test if a file exists\nif mra.run([\"git\", \"ls-files\", \"**/*.txt\"], stdout=subprocess.PIPE).stdout.strip() != \"\":\n print(\"Found\")\n# Get all YAML files:\nmra.all_filenames_identify(\"yaml\")\n# Test if a file exists and contains a text\nif mra.git_grep(file, r\"\\<text\\>\"]):\n print(\"Found\")\n# Edit a files manually\nmra.edit([\"file\"])\n```\n\n### Edit file programmatically\n\n```python\n with mra.Edit('my-file.txt') as edit:\n edit.content = edit.content.replace('<from>', '<to>')\n```\n\n### Edit YAML file programmatically\n\n```python\n with mra.EditYAML('my-file.yaml') as edit:\n edit.setdefault('dict', {})['prop'] = 'value'\n```\n\n### Edit TOML file programmatically\n\n```python\n with mra.EditTOML('my-file.toml') as edit:\n edit.setdefault('dict', {})['prop'] = 'value'\n```\n\n### Edit Config file programmatically\n\n```python\n with mra.EditConfigL('my-file.ini') as edit:\n edit.setdefault('dict', {})['prop'] = 'value'\n```\n\n## Contributing\n\nInstall the pre-commit hooks:\n\n```bash\npip install pre-commit\npre-commit install --allow-missing-config\n```\n\n",
"bugtrack_url": null,
"license": "BSD-2-Clause",
"summary": "Library for automation updates on multiple repositories.",
"version": "1.4.2",
"project_urls": {
"Homepage": "https://github.com/sbrunner/multi-repo-automation",
"Repository": "https://github.com/sbrunner/multi-repo-automation"
},
"split_keywords": [
"pre-commit"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c978bf905d32c2a11621bc643c35b350dee798154655669dc4b6f068b1c1221a",
"md5": "d277191de4f7568c87454a8f393d1443",
"sha256": "6ca5aac915db9f031bbe2a252b13997ee75da76dc0defeb84f8278a6ce26401f"
},
"downloads": -1,
"filename": "multi_repo_automation-1.4.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d277191de4f7568c87454a8f393d1443",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 21258,
"upload_time": "2024-11-14T10:39:32",
"upload_time_iso_8601": "2024-11-14T10:39:32.402944Z",
"url": "https://files.pythonhosted.org/packages/c9/78/bf905d32c2a11621bc643c35b350dee798154655669dc4b6f068b1c1221a/multi_repo_automation-1.4.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "764a9796aa1280d75737fb341f2b99f16cc653fa6b5466914d0538db280d5ff4",
"md5": "1bdcfa4e2a400983aa4e01947c5219d8",
"sha256": "4d980fd7511b19f8b42d4ce2309dfb674c97a8e57d4a960933a8b74e71a32180"
},
"downloads": -1,
"filename": "multi_repo_automation-1.4.2.tar.gz",
"has_sig": false,
"md5_digest": "1bdcfa4e2a400983aa4e01947c5219d8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 20304,
"upload_time": "2024-11-14T10:39:34",
"upload_time_iso_8601": "2024-11-14T10:39:34.327572Z",
"url": "https://files.pythonhosted.org/packages/76/4a/9796aa1280d75737fb341f2b99f16cc653fa6b5466914d0538db280d5ff4/multi_repo_automation-1.4.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-14 10:39:34",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "sbrunner",
"github_project": "multi-repo-automation",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "multi-repo-automation"
}