···1515draft: true
1616---
17171818-We've been having great fun building pull requests. It's a feature we sort of
1919-take for granted
1818+We've spent the last few weeks building out a pull request system for Tangled,
1919+and today we want to lift the hood and show you how it works. What makes our
2020+implementation particularly interesting is that Tangled is federated --
2121+repositories can exist across different servers (which we call "knots"). This
2222+distributed nature creates unique engineering challenges that we had to solve.
20232121-We figured it would be fun to write about the engineering that went into
2222-building this, especially because Tangled is federated and Git repos
2323-can live across different servers (called "knots"). If you're new here,
2424+If you're new to Tangled and wondering what this knot business is all about,
2425[read our intro](/intro) for the full story!
25262627Now, on with the show!
···9495</figure>
959696979797-9898## quick detour: what's in a fork?
9999100100Forks are just "clones" of another repository. They aren't your typical
···157157+refs/heads/main:refs/hidden/feature-1/main
158158```
159159160160-Since we already have a remote connection (`origin`, by default) to the original
161161-repository (remember, we cloned it earlier), we can use `fetch` with this
162162-refspec to bring the remote `main` branch into our local hidden ref. Each pull
163163-request gets its own hidden ref, hence the `refs/hidden/:localRef/:remoteRef`
164164-format. We keep this ref updated whenever you push new commits to your feature
165165-branch, ensuring that comparisons -- and any potential merge conflicts -- are always
166166-based on the latest state of the target branch.
160160+Since we already have a remote (`origin`, by default) to the original repository
161161+(remember, we cloned it earlier), we can use `fetch` with this refspec to bring
162162+the remote `main` branch into our local hidden ref. Each pull request gets its
163163+own hidden ref, hence the `refs/hidden/:localRef/:remoteRef` format. We keep
164164+this ref updated whenever you push new commits to your feature branch, ensuring
165165+that comparisons -- and any potential merge conflicts -- are always based on the
166166+latest state of the target branch.
167167+168168+And just like earlier, we produce the patch by diffing your feature branch with
169169+the hidden tracking ref and do the whole atproto record thing.
170170+171171+## future plans
172172+173173+To close off this post, we wanted to share some of our future plans for pull requests:
174174+175175+* `format-patch` support: both for pasting in the UI and internally. This allows
176176+us to show commits in the PR page, and offer different merge strategies to
177177+choose from (squash, rebase, ...).
178178+179179+* Gerrit-style `refs/for/main`: we're still hashing out the details but being
180180+able to push commits to a ref to "auto-create" a PR would be super handy!
181181+182182+* Change ID support: This will allow us to group changes together and track them
183183+across multiple commits, and to provide "history" for each change.