Introduce scoped PR patches over "main-branch" patches

Aperta
#425 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
30/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
kotlin

Direzione di ricerca

Start by reading the existing applyPatches workflow and how patches are organized in patches/sources and patches/features. The proposed entry points are fixupPrSourcePatches, rebuildPrPatches, and updateWithPrPatches; the issue leaves their design open. Done would mean PR patches can be created, applied after main patches, and incorporated into main patches as described in the example workflow.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

The Problem

When one wants to PR a change to Paper that involves editing (feature) patches, one regularly simply PRs the diff from the original patch file to the new, through the PR updated patch file.

This however introduces very annoying merge conflicts as soon as the very same patch file is updated on the main branch in the meantime. Those merge conflicts can oftentimes be annoying to solve for bigger feature patches, such as Moonrise, which may mean to completely re-apply your PR's changes by hand.

Additionally, the diff of a diff is very busy for review. For example, the very simple change below:

Image

Now of course this is something that should just be an access transformer, but I think it highlights that noise very well. You have the actual changes the PR does (replace a private with a public), but you also have the big red and green highlighted lines caused by the diff file syntax highlighting.

Proposal

I propose to introduce a new feature to paperweight, which allows PR authors to create "pr-patches". This feature would work similarly to regular patches, except that they are stored in a separate directory (as file patches are stored in patches/sources, file pr-patches would be stored in patches/sources-pr.) Pr-patches would be applied right after the main patch. This means the primary patch stays unedited, and the pr-patch patches over the already patched Java file.

For the purpose of the above, the Gradle tasks, fixupPrSourcePatches and rebuildPrPatches, for patch creation, and updateWithPrPatches, for applying the PR patches directly onto the "main" patches, used right before a PR is merged (this could maybe also be automatized), would be introduced.

Implementation

The implementation of these is of course its own interesting difficulty. It is not really possible to differentiate between main-patch and pr-patch based on the commit history of the patched minecraft directory alone. Instead, when applyPatches is run, paperweight would have to keep track of which commits are applied by the main patches. The pr-patches Gradle tasks would basically operate on the commits not kept track of by paperweight.

For feature patches specifically, it could depend on how the commit actually looks. If the commit history notices that a feature-patch commit was edited, it could take the diff as a direct "edit" and create a feature patch in the pr-patched directory with the same name as the original patch, again with only the changes being recorded. If a new commit is added after a feature patch commit, paperweight could treat it as the user wanting to add a new feature patch entirely. For all intends and purposes, that would create a new pr-patched feature patch with the same number, but different name.

Example Workflow

  1. User checks out PaperMC/Paper (main) --> New branch (feat) --> gradle applyPatches
  2. User edits the commit for 0016-Optimise-EntityScheduler-ticking.patch inside the patched directory
  3. gradle rebuildPrPatches -> New file created: patches/features-pr/0016-Optimise-EntityScheduler-ticking.patch, with only the changes ontop of the existing feature patch
  4. Main branch gets updated, with changes to EntityScheduler
  5. User: git pull && git merge main --> No merge commit --> gradle applyPatches --> Conflict; triggers new three-way merge on the affected files
  6. User fixes conflicts --> gradle rebuildPrPatches --> git push
  7. Maintainer can review the changes --> Maintainer: gradle updateWithPrPatches --> CI passes --> Merge

And everything works out nicely! That's kinda what I envision. Same would also work for file patches, even though admittedly, it doesn't have as much demand there.

Closing notes

I think this could make both the process of maintaining a PR over an extended period of time, as well as the process of reviewing a PR a more pleasant process. The task names I have given here are only first draft examples, I am obviously open to different naming and general changes.

I would generally be ready to open a paperweight PR to implement this. But as is good etiquette with bigger changes such as this, I would really love opinions by paperweight maintainers and users alike on this feature. This should also work for forks accepting contributions just as well as it would for Paper itself.

Lingua principale
Kotlin
Stelle
321
Fork
77
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di PaperMC/paperweight

Tutte le issue di PaperMC/paperweight

Issue simili

Altre issue su Kotlin

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.