Patch workflow for contributing to Drupal 7

Inspired by https://pittet.ca/drupal/sprint/patch

One time clone of Drupal repo

git clone --branch 7.x https://git.drupal.org/project/drupal.git

One time create a branch that will take a test-only patch to confirm that it fails.

git branch test-only

See https://www.drupal.org/node/3060/git-instructions/7.x/nonmaintainer for other branches.

Workflow when also creating a test-only patch

A test only patch is useful for maintainers since it clearly demonstrates the problem, by failing, and then proves that the solution actually solves the problem illustrated by the test when the test-and-solution patch passes tests.

  1. Bring in latest changes from upstream git fetch --all
  2. Create new branch for the issue you’re working on git branch issue-description-1438940
  3. Create a fresh install of Drupal drush si --db-url=mysql://user-name:user-pass@localhost/db-name --account-name=admin --account-pass=admin
  4. Enable simpletest drush en -y simpletest
  5. Create a failing test that you will solve in the main issue branch. Add/commit/etc. Run the test with php scripts/run-tests.sh --browser --verbose --url http://example.com/ --class "TestClass"
  6. Create a test-only failing patch. Get the latest from upstream, rebase, then make diff. This captures differences only in the module test file. git fetch --all && git rebase origin/7.x && git diff origin/7.x module-name.test > issue-description-1438940-13-test-only.patch
    1. Use debug($variable) to debug tests.
  7. Checkout the branch where you’ll solve the issue git checkout issue-description-1438940
  8. Apply patch if you’re modifying one curl http://drupal.org/files/patch-name-1438940-2.patch | git apply
  9. Commit that initial patch git commit -m '[comment number]'
  10. Merge in the test from the test-only branch git merge issue-description-1438940-test-only
  11. Do stuff! Add, modify, and make commits. Run the test until it passes.
  12. Get the latest from upstream again (things change fast!) git fetch --all
  13. Rebase so that all commits made to your branch get added ahead of the most recent commit to the origin. git rebase origin/7.x
  14. Make an interdiff, if that’s useful git diff commit-with-original-patch > interdiff.txt
  15. Make a solution patch git diff origin/7.x > patch-name-1438940-13-test-and-solution.patch

Now wait until the testbot approves!