{"id":15358402,"url":"https://github.com/astrofrog/batchpr","last_synced_at":"2025-07-17T16:03:47.934Z","repository":{"id":136158288,"uuid":"101750214","full_name":"astrofrog/batchpr","owner":"astrofrog","description":"Package in need of a better name to automate opening pull requests :robot:","archived":false,"fork":false,"pushed_at":"2024-03-14T18:42:21.000Z","size":42,"stargazers_count":3,"open_issues_count":11,"forks_count":5,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-15T07:24:10.750Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/astrofrog.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2017-08-29T10:42:05.000Z","updated_at":"2023-06-08T16:23:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"3c084e18-5b52-4e03-9f5f-b99e62c1760e","html_url":"https://github.com/astrofrog/batchpr","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/astrofrog/batchpr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astrofrog%2Fbatchpr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astrofrog%2Fbatchpr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astrofrog%2Fbatchpr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astrofrog%2Fbatchpr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/astrofrog","download_url":"https://codeload.github.com/astrofrog/batchpr/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astrofrog%2Fbatchpr/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265625570,"owners_count":23800624,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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-10-01T12:41:06.239Z","updated_at":"2025-07-17T16:03:47.928Z","avatar_url":"https://github.com/astrofrog.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"About\n=====\n\nThe aim of this package is to provide an easy way to do automated issues or pull requests\nto a selection of repositories and make specific changes to them.\nThis is currently functional but could be significantly improved, so contributions are welcome!\n\nInstallation\n============\n\nTo install the latest development version with ``pip``::\n\n    pip install git+https://github.com/astrofrog/batchpr.git@master\n\nTo install from source::\n\n    git clone https://github.com/astrofrog/batchpr.git\n    cd batchpr\n    pip install .\n\nAutomated Pull Requests\n=======================\n\n``batchpr`` requires the following packages:\n\n * ``git``\n * ``pygithub``\n * ``requests``\n * ``termcolor``\n\nTo use this, you should write a Python script in which you import and subclass\nthe ``Updater`` class, and define the following methods and properties:\n\n.. code:: python\n\n    from batchpr import Updater\n\n    class MyUpdater(Updater):\n\n        def process_repo(self):\n            # This method should contain any code that you want to run inside\n            # the repository to make the changes/updates. You can assume that\n            # the current working directory is the repository being processed.\n            # This method should return False if it was not able to make the\n            # changes, and True if it was. This method should call self.add\n            # to git add any files that have changed, but should not commit.\n\n        @property\n        def commit_message(self):\n            # The commit message to use when making the changes\n\n        @property\n        def pull_request_title(self):\n            # The title of the pull request\n\n        @property\n        def pull_request_body(self)\n            # The main body/description of the pull request\n\n        @property\n        def branch_name(self):\n            # The name of the branch to use\n\nOnce you have defined your updater class, you can run it with:\n\n.. code:: python\n\n    helper = MyUpdater(token=GITHUB_TOKEN)\n    helper.run('username/repo')\n\nWhere GITHUB_TOKEN is a personal access token for GitHub. If you want to\ncustomize the author of the commit, you can do this with:\n\n.. code:: python\n\n    helper = MyUpdater(token=GITHUB_TOKEN, author_name='Foo', author_email='foo@bar.bar')\n    helper.run('username/repo')\n\nThe ``run`` method can take a single repository or a list of repositories.\nIf ``dry_run=True`` option is passed in to the ``Updater`` subclass,\npull requests will not be opened but other prior steps\n(i.e., forking, branching, and committing the changes) are executed.\nIf ``verbose=True`` option is passed into the ``Updater`` subclass,\nyou will always see output of the commands, not just when a command fails.\n\nWhen in the ``Updater`` class, the following methods are available:\n\n* ``self.run_command(command)``: should be used for running shell commands\n  (e.g., ``git``)\n\n* ``self.warn(message)``: should be used for warning messages\n\n* ``self.error(message)``: should be used for error messages\n\n* ``self.add(filename)``: should be used to add files that have changed or are new\n\n* ``self.copy(filename1, filename2)``: can be used to copy files\n\nFull Example\n------------\n\nThe following shows an example of an updater that adds a few sentences from the\nzen of Python to the README file if present:\n\n.. code:: python\n\n    import os\n    from batchpr import Updater\n\n    DESCRIPTION = \"\"\"\n    This is an automated update made by the ``batchpr`` tool :robot: - feel free to\n    close if it doesn't look good! You can report issues to @astrofrog.\n    \"\"\"\n\n    ADDITION = \"\"\"\n    Beautiful is better than ugly.\n    Explicit is better than implicit.\n    Simple is better than complex.\n    Complex is better than complicated.\n    \"\"\"\n\n    class ExampleUpdater(Updater):\n\n        def process_repo(self):\n\n            if os.path.exists('README.md'):\n                with open('README.md', 'a') as f:\n                    f.write(os.linesep + ADDITION)\n                self.add('README.md')\n                return True\n            else:\n                return False\n\n        @property\n        def commit_message(self):\n            return \"MNT: Add important text to README.rst\"\n\n        @property\n        def branch_name(self):\n            return 'readme-zen'\n\n        @property\n        def pull_request_title(self):\n            return self.commit_message\n\n        @property\n        def pull_request_body(self):\n            return DESCRIPTION.strip()\n\n    helper = ExampleUpdater(token=GITHUB_TOKEN)\n    helper.run('username/repo')\n\nAutomated Issues\n================\n\nOpening automated issues is simpler than pull requests as you do not need\nto create forks or modify any files. You use the same GitHub token as above.\n\nFull Example\n------------\n\nThe following shows an example of opening a simple issue.\n\n.. code:: python\n\n    from batchpr import IssueUpdater\n\n    ISSUE_TITLE = 'Please fix this and that'\n\n    ISSUE_BODY = \"\"\"\n    I found this and that with the package. Please fix them.\n\n    *This is an automated issue. If this is opened in error, please let me know!*\n    \"\"\"\n\n    helper = IssueUpdater(GITHUB_TOKEN, ISSUE_TITLE, ISSUE_BODY)\n    helper.run('username/repo')\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastrofrog%2Fbatchpr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fastrofrog%2Fbatchpr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastrofrog%2Fbatchpr/lists"}