|
| 1 | +Symfony Docs Maintainer Guide |
| 2 | +============================= |
| 3 | + |
| 4 | +The `symfony/symfony-docs`_ repository stores the Symfony project documentation |
| 5 | +and is managed by the `Symfony Docs team`_. This article explains in detail some |
| 6 | +of those management tasks, so it's only useful for maintainers and not regular |
| 7 | +readers or Symfony developers. |
| 8 | + |
| 9 | +Reviewing Pull Requests |
| 10 | +----------------------- |
| 11 | + |
| 12 | +All the recommendations of the `Symfony's respectful review comments`_ apply, |
| 13 | +but there are extra things to keep in mind for maintainers: |
| 14 | + |
| 15 | +* Always be nice in all interactions with all contributors. |
| 16 | +* Be extra-patient with new contributors (GitHub shows a special badge for them). |
| 17 | +* Don't assume that contributors know what you think is obvious (e.g. lots of |
| 18 | + them don't know what to "squash commits" means). |
| 19 | +* Don't use acronyms like IMO, IIRC, etc. or complex English words (most |
| 20 | + contributors are not native in English and it's intimidating for them). |
| 21 | +* Never engage in a heated discussion. Lock it right away using GitHub. |
| 22 | +* Never discuss non-tech issues. Some PRs are related to our Diversity initiative |
| 23 | + and some people always try to drag you into politics. Never engage in that and |
| 24 | + lock the issue/PR as off-topic on GitHub. |
| 25 | + |
| 26 | +Fixing Minor Issues Yourself |
| 27 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 28 | + |
| 29 | +It's common for new contributors to make lots of minor mistakes in the syntax |
| 30 | +of the RST format used in the docs. It's also common for non English speakers to |
| 31 | +make minor typos. |
| 32 | + |
| 33 | +Even if your intention is good, if you add lots of comments when reviewing a |
| 34 | +first contribution, that person will probably not contribute again. It's better |
| 35 | +to fix the minor errors and typos yourself while merging. If that person |
| 36 | +contributes again, it's OK to mention some of the minor issues to educate them. |
| 37 | + |
| 38 | +.. code-block:: terminal |
| 39 | +
|
| 40 | + $ gh merge 11059 |
| 41 | +
|
| 42 | + Working on symfony/symfony-docs (branch master) |
| 43 | + Merging Pull Request 11059: dmaicher/patch-3 |
| 44 | +
|
| 45 | + ... |
| 46 | +
|
| 47 | + # This is important!! Say NO to push the changes now |
| 48 | + Push the changes now? (Y/n) n |
| 49 | + Now, push with: git push gh "master" refs/notes/github-comments |
| 50 | +
|
| 51 | + # Now, open your editor and make the needed changes ... |
| 52 | +
|
| 53 | + $ git commit -a |
| 54 | + # Use "Minor reword", "Minor tweak", etc. as the commit message |
| 55 | +
|
| 56 | + # now run the 'push' command shown above by 'gh' (it's different each time) |
| 57 | + $ git push gh "master" refs/notes/github-comments |
| 58 | +
|
| 59 | +Merging Pull Requests |
| 60 | +--------------------- |
| 61 | + |
| 62 | +Technical Requirements |
| 63 | +~~~~~~~~~~~~~~~~~~~~~~ |
| 64 | + |
| 65 | +* `Git`_ installed and properly configured. |
| 66 | +* ``gh`` tool fully installed according to its installation instructions |
| 67 | + (GitHub token configured, Git remote configured, etc.) |
| 68 | + This is a proprietary CLI tool which only Symfony team members have access to. |
| 69 | +* Some previous Git experience, specially merging pull requests. |
| 70 | + |
| 71 | +First Setup |
| 72 | +~~~~~~~~~~~ |
| 73 | + |
| 74 | +First, fork the <https://github.com/symfony/symfony-docs> using the GitHub web |
| 75 | +interface. Then: |
| 76 | + |
| 77 | +.. code-block:: terminal |
| 78 | +
|
| 79 | + # Clone your fork |
| 80 | + $ git clone https://github.com/<YOUR-NAME>/symfony-docs.git |
| 81 | +
|
| 82 | + $ cd symfony-docs/ |
| 83 | +
|
| 84 | + # Add the original repo as 'upstream' remote |
| 85 | + $ git remote add upstream https://github.com/symfony/symfony-docs |
| 86 | +
|
| 87 | + # Add the original repo as 'gh' remote (needed for the 'gh' tool) |
| 88 | + $ git remote add gh https://github.com/symfony/symfony-docs |
| 89 | +
|
| 90 | + # Configure 'gh' in Git as the remote used by the 'gh' tool |
| 91 | + $ git config gh.remote gh |
| 92 | +
|
| 93 | +Merging Process |
| 94 | +~~~~~~~~~~~~~~~ |
| 95 | + |
| 96 | +At first it's common to make mistakes and merge things badly. Don't worry. This |
| 97 | +has happened to all of us and we've always been able to recover from any mistake. |
| 98 | + |
| 99 | +Step 1: Select the right branch to merge |
| 100 | +........................................ |
| 101 | + |
| 102 | +PRs must be merged in the oldest maintained branch where they are applicable: |
| 103 | + |
| 104 | +* Here you can find the currently maintained branches: https://symfony.com/roadmap. |
| 105 | +* Typos and old undocumented features are merged into the oldest maintained branch. |
| 106 | +* New features are merged into the branch where they were introduced. This |
| 107 | + usually means ``master``. And don't forget to check that new feature includes |
| 108 | + the ``versionadded`` directive. |
| 109 | + |
| 110 | +It's very common for contributors (specially newcomers) to select the wrong |
| 111 | +branch for their PRs, so we must always check if the change should go to the |
| 112 | +proposed branch or not. |
| 113 | + |
| 114 | +If the branch is wrong, there's no need to ask the contributor to rebase. The |
| 115 | +``gh`` tool can do that for us. |
| 116 | + |
| 117 | +Step 2: Merge the pull request |
| 118 | +.............................. |
| 119 | + |
| 120 | +Never use GitHub's web interface (or desktop clients) to merge PRs or to solve |
| 121 | +merge conflicts. Always use the ``gh`` tool for anything related to merges. |
| 122 | + |
| 123 | +We require 2 approval votes from team members before merging a PR, except if |
| 124 | +it's a typo, a small change or an obvious error. |
| 125 | + |
| 126 | +If a PR contains lots of commits, there's no need to ask the contributor to |
| 127 | +squash them. The ``gh`` tool does that automatically. The only exceptions are |
| 128 | +when commits are made by more than one person and when there's a merge commit. |
| 129 | +``gh`` can't squash commits in those cases, so it's better to ask to the |
| 130 | +original contributor. |
| 131 | + |
| 132 | +.. code-block:: terminal |
| 133 | +
|
| 134 | + $ cd symfony-docs/ |
| 135 | +
|
| 136 | + # make sure that your local branch is updated |
| 137 | + $ git checkout 3.4 |
| 138 | + $ git fetch upstream |
| 139 | + $ git merge upstream/3.4 |
| 140 | +
|
| 141 | + # merge any PR passing its GitHub number as argument |
| 142 | + $ gh merge 11159 |
| 143 | +
|
| 144 | + # the gh tool will ask you some questions... |
| 145 | +
|
| 146 | + # push your changes (you can merge several PRs and push once at the end) |
| 147 | + $ git push origin |
| 148 | + $ git push upstream |
| 149 | +
|
| 150 | +It's common to have to change the branch where a PR is merged. Instead of asking |
| 151 | +the contributors to rebase their PRs, the "gh" tool can change the branch with |
| 152 | +the ``-s`` option: |
| 153 | + |
| 154 | +.. code-block:: terminal |
| 155 | +
|
| 156 | + # e.g. this PR was sent against 'master', but it's merged in '3.4' |
| 157 | + $ gh merge 11160 -s 3.4 |
| 158 | +
|
| 159 | +Sometimes, when changing the branch, you may face rebase issues, but they are |
| 160 | +usually simple to fix: |
| 161 | + |
| 162 | +.. code-block:: terminal |
| 163 | +
|
| 164 | + $ gh merge 11160 -s 3.4 |
| 165 | +
|
| 166 | + ... |
| 167 | +
|
| 168 | + Unable to rebase the patch for <comment>pull/11183</comment> |
| 169 | + The command "'git' 'rebase' '--onto' '3.4' '4.2' 'pull/11160'" failed. |
| 170 | + Exit Code: 128(Invalid exit argument) |
| 171 | +
|
| 172 | + [...] |
| 173 | + Auto-merging reference/forms/types/entity.rst |
| 174 | + CONFLICT (content): Merge conflict in reference/forms/types/entity.rst |
| 175 | + Patch failed at 0001 Update entity.rst |
| 176 | + The copy of the patch that failed is found in: .git/rebase-apply/patch |
| 177 | +
|
| 178 | + # Now, fix all the conflicts using your editor |
| 179 | +
|
| 180 | + # Add the modified files and continue the rebase |
| 181 | + $ git add reference/forms/types/entity.rst ... |
| 182 | + $ git rebase --continue |
| 183 | +
|
| 184 | + # Lastly, re-run the exact same original command that resulted in a conflict |
| 185 | + # There's no need to change the branch or do anything else. |
| 186 | + $ gh merge 11160 -s 3.4 |
| 187 | +
|
| 188 | + The previous run had some conflicts. Do you want to resume the merge? (Y/n) |
| 189 | +
|
| 190 | +Later in this article you can find a troubleshooting section for the errors that |
| 191 | +you will usually face while merging. |
| 192 | + |
| 193 | +Step 3: Merge it into the other branches |
| 194 | +........................................ |
| 195 | + |
| 196 | +If a PR has not been merged in ``master``, you must merge it up into all the |
| 197 | +maintained branches until ``master``. Imagine that you are merging a PR against |
| 198 | +``3.4`` and the maintained branches are ``3.4``, ``4.2`` and ``master``: |
| 199 | + |
| 200 | +.. code-block:: terminal |
| 201 | +
|
| 202 | + $ git fetch upstream |
| 203 | +
|
| 204 | + $ git checkout 3.4 |
| 205 | + $ git merge upstream/3.4 |
| 206 | +
|
| 207 | + $ gh merge 11159 |
| 208 | + $ git push origin |
| 209 | + $ git push upstream |
| 210 | +
|
| 211 | + $ git checkout 4.2 |
| 212 | + $ git merge upstream/4.2 |
| 213 | + $ git merge --log 3.4 |
| 214 | + # here you can face several errors explained later |
| 215 | + $ git push origin |
| 216 | + $ git push upstream |
| 217 | +
|
| 218 | + $ git checkout master |
| 219 | + $ git merge upstream/master |
| 220 | + $ git merge --log 4.2 |
| 221 | + $ git push origin |
| 222 | + $ git push upstream |
| 223 | +
|
| 224 | +.. tip:: |
| 225 | + |
| 226 | + If you followed the full ``gh`` installation instructions you can remove the |
| 227 | + ``--log`` option in the above commands. |
| 228 | + |
| 229 | +.. tip:: |
| 230 | + |
| 231 | + When the support of a Symfony branch ends, it's recommended to delete your |
| 232 | + local branch to avoid merging in it unawarely: |
| 233 | + |
| 234 | + .. code-block:: terminal |
| 235 | +
|
| 236 | + # if Symfony 3.3 goes out of maintenance today, delete your local branch |
| 237 | + $ git branch -D 3.3 |
| 238 | +
|
| 239 | +Troubleshooting |
| 240 | +~~~~~~~~~~~~~~~ |
| 241 | + |
| 242 | +Wrong merge of your local branch |
| 243 | +................................ |
| 244 | + |
| 245 | +When updating your local branches before merging: |
| 246 | + |
| 247 | +.. code-block:: terminal |
| 248 | +
|
| 249 | + $ git fetch upstream |
| 250 | + $ git checkout 3.4 |
| 251 | + $ git merge upstream/3.4 |
| 252 | +
|
| 253 | +It's possible that you merge a wrong upstream branch unawarely. It's usually |
| 254 | +easy to spot because you'll see lots of conflicts: |
| 255 | + |
| 256 | +.. code-block:: terminal |
| 257 | +
|
| 258 | + # DON'T DO THIS! It's a wrong branch merge |
| 259 | + $ git checkout 3.4 |
| 260 | + $ git merge upstream/4.2 |
| 261 | +
|
| 262 | +As long as you don't push this wrong merge, there's no problem. Delete your |
| 263 | +local branch and check it out again: |
| 264 | + |
| 265 | +.. code-block:: terminal |
| 266 | +
|
| 267 | + $ git checkout master |
| 268 | + $ git branch -D 3.4 |
| 269 | + $ git checkout 3.4 upstream/3.4 |
| 270 | +
|
| 271 | +If you did push the wrong branch merge, ask for help in the documentation |
| 272 | +mergers chat and we'll help solve the problem. |
| 273 | + |
| 274 | +Solving merge conflicts |
| 275 | +....................... |
| 276 | + |
| 277 | +When merging things to upper branches, most of the times you'll see conflicts: |
| 278 | + |
| 279 | +.. code-block:: terminal |
| 280 | +
|
| 281 | + $ git checkout 4.2 |
| 282 | + $ git merge upstream/4.2 |
| 283 | + $ git merge --log 3.4 |
| 284 | +
|
| 285 | + Auto-merging security/entity_provider.rst |
| 286 | + Auto-merging logging/monolog_console.rst |
| 287 | + Auto-merging form/dynamic_form_modification.rst |
| 288 | + Auto-merging components/phpunit_bridge.rst |
| 289 | + CONFLICT (content): Merge conflict in components/phpunit_bridge.rst |
| 290 | + Automatic merge failed; fix conflicts and then commit the result. |
| 291 | +
|
| 292 | +Solve the conflicts with your editor (look for occurrences of ``<<<<``, which is |
| 293 | +the marker used by Git for conflicts) and then do this: |
| 294 | + |
| 295 | +.. code-block:: terminal |
| 296 | +
|
| 297 | + # add all the conflicting files that you fixed |
| 298 | + $ git add components/phpunit_bridge.rst |
| 299 | + $ git commit -a |
| 300 | + $ git push origin |
| 301 | + $ git push upstream |
| 302 | +
|
| 303 | +.. tip:: |
| 304 | + |
| 305 | + When there are lots of conflicts, look for ``<<<<<`` with your editor in all |
| 306 | + docs before committing the changes. It's common to forget about some of them. |
| 307 | + If you prefer, you can run this too: ``git grep --cached "<<<<<"``. |
| 308 | + |
| 309 | +Merging deleted files |
| 310 | +..................... |
| 311 | + |
| 312 | +A common cause of conflict when merging PRs into upper branches are files which |
| 313 | +were modified by the PR but no longer exist in newer branches: |
| 314 | + |
| 315 | +.. code-block:: terminal |
| 316 | +
|
| 317 | + $ git checkout 4.2 |
| 318 | + $ git merge upstream/4.2 |
| 319 | + $ git merge --log 3.4 |
| 320 | +
|
| 321 | + Auto-merging translation/debug.rst |
| 322 | + CONFLICT (modify/delete): service_container/scopes.rst deleted in HEAD and |
| 323 | + modified in 3.4. Version 3.4 of service_container/scopes.rst left in tree. |
| 324 | + Auto-merging service_container.rst |
| 325 | +
|
| 326 | +If the contents of the deleted file were moved to a different file in newer |
| 327 | +branches, redo the changes in the new file. Then, delete the file that Git left |
| 328 | +in the tree as follows: |
| 329 | + |
| 330 | +.. code-block:: terminal |
| 331 | +
|
| 332 | + # delete all the conflicting files that no longer exist in this branch |
| 333 | + $ git rm service_container/scopes.rst |
| 334 | + $ git commit -a |
| 335 | + $ git push origin |
| 336 | + $ git push upstream |
| 337 | +
|
| 338 | +.. _`symfony/symfony-docs`: https://github.com/symfony/symfony-docs |
| 339 | +.. _`Symfony Docs team`: https://github.com/orgs/symfony/teams/team-symfony-docs |
| 340 | +.. _`Symfony's respectful review comments`: https://symfony.com/doc/current/contributing/community/review-comments.html |
| 341 | +.. _`Git`: https://git-scm.com/ |
0 commit comments