{"id":24577723,"url":"https://github.com/nik-rev/patchy","last_synced_at":"2025-04-05T04:08:22.107Z","repository":{"id":269975179,"uuid":"906633423","full_name":"nik-rev/patchy","owner":"nik-rev","description":"A tool which makes it easy to declaratively manage personal forks by automatically merging pull requests","archived":false,"fork":false,"pushed_at":"2025-03-19T12:20:40.000Z","size":474,"stargazers_count":100,"open_issues_count":4,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T03:02:13.892Z","etag":null,"topics":["forks","git","github","rust"],"latest_commit_sha":null,"homepage":"https://patchy.nikrev.com/","language":"Rust","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/nik-rev.png","metadata":{"files":{"readme":"docs/README.md","changelog":"CHANGELOG.md","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}},"created_at":"2024-12-21T13:05:34.000Z","updated_at":"2025-03-27T19:32:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"fa910434-ec35-4990-bead-2cc99c141899","html_url":"https://github.com/nik-rev/patchy","commit_stats":null,"previous_names":["nikitarevenco/patchy","nik-rev/patchy"],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nik-rev%2Fpatchy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nik-rev%2Fpatchy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nik-rev%2Fpatchy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nik-rev%2Fpatchy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nik-rev","download_url":"https://codeload.github.com/nik-rev/patchy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247284941,"owners_count":20913704,"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":["forks","git","github","rust"],"created_at":"2025-01-23T23:01:50.615Z","updated_at":"2025-04-05T04:08:22.068Z","avatar_url":"https://github.com/nik-rev.png","language":"Rust","readme":"# patchy\n\n![image](https://github.com/user-attachments/assets/95546bae-5f61-4a14-b849-c4805bbe27af)\n\n`patchy` makes it easy to maintain personal forks in which you merge some pull requests of your liking to have more features than other people.\n\n- [Why should I use it?](#why-should-i-use-it)\n- [Usage](#usage)\n  - [Config](#config)\n  - [Patches](#patches)\n  - [Versioning](#versioning)\n- [Installation](#installation)\n  - [Binary](#binary)\n  - [Homebrew](#homebrew)\n  - [Cargo](#cargo)\n  - [PowerShell](#powershell)\n  - [Nix](#nix)\n- [Merge conflicts](#merge-conflicts)\n\n## Why should I use it?\n\n- Merge multiple pull requests and commits into a single repo effortlessly\n- Sync those pull requests and the main branch with a single command\n- Add new pull requests and update existing ones easily\n\n## Usage\n\nGo to a git repo, and initialize the config file:\n\n```bash\npatchy init\n```\n\nInvoke `patchy` by running the following command:\n\n```bash\npatchy run\n```\n\n### Config\n\nI'm using the [Helix Editor](https://github.com/helix-editor/helix) but there are some pull requests which add awesome features.\n\nI found myself very frequently doing the same tasks in order to sync the 4 pull requests I like to use and keep them up to date. With patchy, I just run one command and it handles the rest.\n\nHere's my config:\n\n```toml\n# main repository to fetch from\nrepo = \"helix-editor/helix\"\n\n# the repository's branch\nremote-branch = \"master\"\n\n# This is the branch where you will see all result from patchy's work. Set it to any branch you want.\n# WARNING: Make sure you do not store any important work on this branch. It will be erased.\nlocal-branch = \"patchy\"\n\n# List of pull requests which you would like to merge\n# TIP: Add comments above pull requests to help yourself understand which PRs do what\npull-requests = [\n  # syntax highlighting for nginx files\n  \"12309\",\n  # adds file explorer\n  \"11285\",\n  # global status line\n  \"8908\",\n  # command expansions\n  \"11164\",\n]\n\n# An optional list of patches to apply, more on them later\npatches = [\"remove-tab\"]\n```\n\nRunning `patchy run` outputs:\n\n![patchy output](https://github.com/user-attachments/assets/c0076588-6e57-4a80-9d05-955a4dff2580)\n\nWith this, all I will need to do is run `patchy run` and it will automatically update all of the pull requests and sync the master branch to the latest changes.\n\n### Patches\n\nYou might want to apply some changes to your repo, but it's not a pull request. No worries! `patchy` is built for this.\n\nCreate a patch from a commit:\n\n```bash\n# obtain commit hashes e.g. from `git log`\npatchy gen-patch \u003chash-of-commit\u003e\n```\n\nFor example, I'm running:\n\n```bash\npatchy gen-patch 7bb8ec5a77769d88855d41dd5fecfaece54cf471\n```\n\nIt generated a file, `.patchy/feat-swap-light-and-dark-colors.patch`:\n\n```patch\ndiff --git a/README.md m/README.md\nindex 11a909b2..4eae6a8d 100644\n--- a/README.md\n+++ m/README.md\n@@ -2,8 +2,8 @@\n\n \u003ch1\u003e\n \u003cpicture\u003e\n-  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"logo_dark.svg\"\u003e\n   \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"logo_light.svg\"\u003e\n+  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"logo_dark.svg\"\u003e\n   \u003cimg alt=\"Helix\" height=\"128\" src=\"logo_light.svg\"\u003e\n \u003c/picture\u003e\n \u003c/h1\u003e\n```\n\nTo use your new `.patch`, edit your `.patchy/config.toml` like so:\n\n```diff\n--- patches = []\n+++ patches = [ \"feat-swap-light-and-dark-colors\" ]\n```\n\n### Versioning\n\nEach pull request's branch contains commits. By default, we will always use the latest commit. However you can pin a commit to a specific version with the following syntax:\n\n```toml\nremote-branch = \"main @ cfd225baedbb5fb9cbc9742f91244fa50882b580\"\n\npull-requests = [\n   \"145 @ fccc58957eece10d0818dfa000bf5123e26ee32f\",\n   \"88 @ a556aeef3736a3b6b79bb9507d26224f5c0c3449\"\n]\n```\n\nWhere the hashes represent each `sha1` hash of every commit.\n\nThis is handy if you don't want things to randomly break when some of the pull requests push a new change.\n\n## Installation\n\nPatchy can be installed on Linux, Windows and macOS.\n\n### Binary\n\nInstall the binary directly into your system, available for macOS and Linux.\n\nRecommended for Linux users.\n\n```bash\ncurl --proto '=https' --tlsv1.2 -LsSf https://github.com/nik-rev/patchy/releases/latest/download/patchy-bin-installer.sh | sh\n```\n\n### Homebrew\n\nRecommended for macOS users.\n\n```bash\nbrew install nik-rev/tap/patchy-bin\n```\n\n### Cargo\n\n```bash\ncargo install patchy-bin\n```\n\n### PowerShell\n\nRecommended for Windows users.\n\n```powershell\npowershell -ExecutionPolicy ByPass -c \"irm https://github.com/nik-rev/patchy/releases/latest/download/patchy-installer.ps1 | iex\"\n```\n\n### Nix\n\n```bash\nnix profile install github:nik-rev/patchy/main\n```\n\n\u003cdetails\u003e\n\n\u003csummary\u003e\nExample usage with flakes\n\u003c/summary\u003e\n\nIf the software you are using has a `flake.nix` which automatically builds this software, then using patchy with it is straightforward.\n\n1. Use patchy to create your own remote fork.\n\n   Let's say you fork the [`helix-editor/helix`](https://github.com/helix-editor/helix) and your fork is located at `your-username/helix`, the patchy branch is called `patchy`\n\n1. Add your fork's input in your `flake.nix` as follows:\n\n   ```nix\n   inputs.helix.url = \"github:your-username/helix/patchy\";\n   ```\n\n1. Use the input in your home-manager:\n\n   ```nix\n   programs.helix.package = inputs.helix.packages.${pkgs.system}.helix;\n   ```\n\nThis is easier when the target repository has a `flake.nix` which fully builds the software. Which, the [`helix-editor/helix`](https://github.com/helix-editor/helix) does have for example.\n\n\u003c/details\u003e\n\n## Merge conflicts\n\nIf you merge a lot of PRs, it's likely some of them will clash with eachother and there will be conflicts.\n\nSay you merge 10 pull requests, 3 of which couldn't be merged due to merge conflicts. The other 7 will be merged, while branches for those 3 will exist and you will be able to merge them yourself.\n\n```\n  ✗ Could not merge branch 11164/command-expansion into the current branch for pull request #11164 Command expansion v2 since the merge is non-trivial.\nYou will need to merge it yourself:\n  git merge --squash 11164/command-expansion\nNote: To learn how to merge only once and re-use for subsequent invocations of patchy, see Merge conflicts (github)\n```\n\n\u003cdetails\u003e\n\n\u003csummary\u003e\n\nFixing merge conflicts and retaining the fixes, declaratively\n\n\u003c/summary\u003e\n\nOkay, now merge the branch:\n\n```bash\ngit merge --squash 11164/command-expansion\n```\n\nWe need `--squash` since `patchy gen-patch` does not work on Merge commits. But using `--squash` makes it into a non-merge commit.\n\nNow fix the merge conflicts.\n\nThen, commit your changes:\n\n```\ngit commit -m \"merge branch 11164/command-expansion\"\n```\n\nThis creates the following commit:\n\n```\n2fb6c3c7 (HEAD -\u003e patchy) Merge branch '11164/command-expansion' into patchy\n```\n\nNow that you have this commit, let's generate a `.patch` file for it:\n\n```\n\u003e patchy gen-patch 2fb6c3c7 --patch-filename=merge-11164\n  ✓ Created patch file at .patchy/merge-11164.patch\n```\n\nNow, you can go ahead and add the patch to your config:\n\n```diff\n- pull-requests = [ \"1234\", \"1111\", \"11164\" ]\n+ pull-requests = [ \"1234\", \"1111\" ]\n\n- patches = [ ]\n+ patches = [ \"merge-11164\" ]\n```\n\nWhen you do this, you won't need to solve this merge conflict anymore as the `merge-11164` patch includes both the entire pull request as well as how it was merged.\n\nNote that if you change the _order_ of your pull requests in `pull-requests` you may see merge conflicts again. It is recommended to keep the order the same once you fix the conflicts.\n\n\u003c/details\u003e\n","funding_links":[],"categories":["Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnik-rev%2Fpatchy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnik-rev%2Fpatchy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnik-rev%2Fpatchy/lists"}