BugMashCheatSheet
Version 6 (Jonathan Roes, 09/26/2009 02:19 pm)
| 1 | 1 | h1. BugMash Cheat Sheet |
|
|---|---|---|---|
| 2 | 1 | ||
| 3 | 1 | Here's a list of handy shortcuts for BugMashers. |
|
| 4 | 1 | ||
| 5 | 1 | h2. Required software |
|
| 6 | 1 | ||
| 7 | 1 | If you're having trouble getting the Rails source code set up on your computer, use our [[Pre-flight Checklist]] as a guide, or drop by #railsbridge on Freenode IRC to ask for help. |
|
| 8 | 1 | ||
| 9 | 1 | h2. Generating a Rails app on master branch |
|
| 10 | 1 | ||
| 11 | 1 | You can generate a quick sample application from the Rails source code tree by |
|
| 12 | 1 | ||
| 13 | 1 | <pre> |
|
| 14 | 1 | cd railties |
|
| 15 | 1 | rake dev |
|
| 16 | 1 | </pre> |
|
| 17 | 1 | ||
| 18 | 1 | This will create a new application named rails at the root of your Rails repository. |
|
| 19 | 1 | ||
| 20 | 1 | h2. Testing Active Record |
|
| 21 | 1 | ||
| 22 | 6 | Jonathan Roes | If you wish to test patches on Active Record, you'll have to generate test databases for MySQL. Otherwise, most of the Active Record tests won't pass. You should run these tasks in the <pre>activerecord</pre> directory. |
| 23 | 1 | ||
| 24 | 1 | <pre> |
|
| 25 | 1 | rake mysql:build_databases |
|
| 26 | 1 | </pre> |
|
| 27 | 1 | ||
| 28 | 1 | There is also a PostgreSQL task for doing the same job given you have PostgreSQL installed on your system. |
|
| 29 | 1 | ||
| 30 | 1 | <pre> |
|
| 31 | 1 | rake postgresql:build_databases |
|
| 32 | 1 | </pre> |
|
| 33 | 1 | ||
| 34 | 1 | When you're done testing patches, you can delete the generated databases. |
|
| 35 | 1 | ||
| 36 | 1 | <pre> |
|
| 37 | 1 | rake mysql:drop_databases |
|
| 38 | 1 | rake postgresql:drop_databases |
|
| 39 | 1 | </pre> |
|
| 40 | 1 | ||
| 41 | 1 | There are also useful tasks for deleting and regenerating databases if you need to refresh. |
|
| 42 | 1 | ||
| 43 | 1 | <pre> |
|
| 44 | 1 | rake mysql:rebuild_databases |
|
| 45 | 1 | rake postgresql:rebuild_databases |
|
| 46 | 1 | </pre> |
|
| 47 | 1 | ||
| 48 | 1 | If you're writing new tests for ActiveRecord, please try to reuse the existing test models instead of adding new ones. |
|
| 49 | 1 | ||
| 50 | 1 | h2. Testing specified frameworks only |
|
| 51 | 1 | ||
| 52 | 1 | Running the whole test suite takes a lot of time? You can run tests in the individual Rails frameworks also. Just cd into the library you wish to test and rake test. |
|
| 53 | 1 | ||
| 54 | 1 | <pre> |
|
| 55 | 1 | cd activesupport |
|
| 56 | 1 | rake test |
|
| 57 | 1 | </pre> |
|
| 58 | 1 | ||
| 59 | 1 | h3. Testing Active Record |
|
| 60 | 1 | ||
| 61 | 1 | Running rake test for Active Record will run tests for MySQL, SQLite3 and PostgreSQL. To run test individually based on different adapters: |
|
| 62 | 1 | ||
| 63 | 1 | <pre> |
|
| 64 | 1 | rake test_mysql |
|
| 65 | 1 | rake test_postgresql |
|
| 66 | 1 | rake test_sqlite3 |
|
| 67 | 1 | </pre> |
|
| 68 | 1 | ||
| 69 | 1 | You should test all three of these widely-used database adapters if you're contributing to Active Record. See rake -T for all the adapters Rails supports, as this is only a fraction of them. |
|
| 70 | 1 | ||
| 71 | 1 | h3. Testing Individual Files |
|
| 72 | 1 | ||
| 73 | 1 | Better yet, you can test a separate file for a speed boost. |
|
| 74 | 1 | ||
| 75 | 1 | <pre> |
|
| 76 | 1 | rake test TEST=test/ordered_options_test.rb |
|
| 77 | 1 | </pre> |
|
| 78 | 1 | ||
| 79 | 1 | If testing ActiveRecord and you've changed the schema, you have to initialize the database before running the test: |
|
| 80 | 1 | ||
| 81 | 1 | <pre> |
|
| 82 | 1 | rake test_mysql TEST=test/cases/aaa_create_tables_test.rb # update the schema |
|
| 83 | 1 | rake test_mysql |
|
| 84 | 1 | TEST=test/cases/associations/has_many_through_associations_test.rb |
|
| 85 | 1 | </pre> |
|
| 86 | 1 | ||
| 87 | 1 | h2. Working with Rails and git |
|
| 88 | 1 | ||
| 89 | 1 | Getting the Rails source: |
|
| 90 | 1 | ||
| 91 | 1 | <pre> |
|
| 92 | 1 | git clone git://github.com/rails/rails.git |
|
| 93 | 1 | cd rails |
|
| 94 | 3 | Redmine Admin | git checkout -b 2-3-stable origin/2-3-stable # this will leave you on the 2-3-stable branch |
| 95 | 4 | Mike Breen | (you can also do: git checkout -t origin/2-3-stable # this will also leave you on the 2-3-stable branch) |
| 96 | 1 | </pre> |
|
| 97 | 1 | ||
| 98 | 1 | Working on the master (3.0) branch: |
|
| 99 | 1 | ||
| 100 | 1 | <pre> |
|
| 101 | 1 | git checkout master |
|
| 102 | 1 | </pre> |
|
| 103 | 1 | ||
| 104 | 1 | Working on the 2-3-stable branch: |
|
| 105 | 1 | ||
| 106 | 1 | <pre> |
|
| 107 | 1 | git checkout 2-3-stable |
|
| 108 | 1 | </pre> |
|
| 109 | 1 | ||
| 110 | 1 | Creating your own feature branch: |
|
| 111 | 1 | ||
| 112 | 1 | <pre> |
|
| 113 | 1 | git checkout -b my_feature_branch |
|
| 114 | 1 | </pre> |
|
| 115 | 1 | ||
| 116 | 1 | Apply a patch: |
|
| 117 | 1 | ||
| 118 | 1 | <pre> |
|
| 119 | 1 | git apply <patch file> |
|
| 120 | 1 | </pre> |
|
| 121 | 1 | ||
| 122 | 1 | Creating a patch: |
|
| 123 | 1 | ||
| 124 | 1 | <pre> |
|
| 125 | 1 | git checkout master |
|
| 126 | 1 | git checkout -b my_feature_branch |
|
| 127 | 1 | (write and test code) |
|
| 128 | 1 | git commit -a -m "This is my great patch" |
|
| 129 | 1 | git checkout master |
|
| 130 | 1 | git pull |
|
| 131 | 1 | git checkout my_feature_branch |
|
| 132 | 1 | git rebase master |
|
| 133 | 1 | rake (to be sure tests still patch) |
|
| 134 | 1 | git format-patch master --stdout > my_great_patch.diff |
|
| 135 | 1 | </pre> |
|
| 136 | 1 | ||
| 137 | 1 | Patching both master and 2-3-stable: |
|
| 138 | 1 | ||
| 139 | 3 | Redmine Admin | First, follow above to create a patch for master. If the same patch applies cleanly to 2-3-stable, just say so in the Lighthouse ticket and the committer will apply it to both. Otherwise, you'll need to generate a separate patch for 2-3-stable (assuming that this issue should be patched on both branches). The first thing to try is just cherry-picking your patch over to 2-3-stable: |
| 140 | 1 | ||
| 141 | 1 | <pre> |
|
| 142 | 3 | Redmine Admin | git checkout -b my-feature-2-3 2-3-stable |
| 143 | 3 | Redmine Admin | git cherry-pick <revision of change made to master> |
| 144 | 3 | Redmine Admin | rake test |
| 145 | 3 | Redmine Admin | git format-patch 2-3-stable --stdout > my_great_patch_for_rails23.diff |
| 146 | 3 | Redmine Admin | </pre> |
| 147 | 3 | Redmine Admin | |
| 148 | 3 | Redmine Admin | As a last resort, you can write a completely separate patch for 2.3: |
| 149 | 3 | Redmine Admin | |
| 150 | 3 | Redmine Admin | <pre> |
| 151 | 1 | git checkout 2-3-stable |
|
| 152 | 1 | git checkout -b my_feature_branch |
|
| 153 | 1 | (write and test code) |
|
| 154 | 1 | git commit -a -m "This is my great patch" |
|
| 155 | 1 | git checkout 2-3-stable |
|
| 156 | 1 | git pull |
|
| 157 | 1 | git checkout my_feature_branch |
|
| 158 | 1 | git rebase 2-3-stable |
|
| 159 | 1 | rake (to be sure tests still patch) |
|
| 160 | 1 | git format-patch 2-3-stable --stdout > my_great_patch.diff |
|
| 161 | 1 | </pre> |
|
| 162 | 1 | ||
| 163 | 3 | Redmine Admin | |
| 164 | 3 | Redmine Admin | *NOTE* |
| 165 | 3 | Redmine Admin | |
| 166 | 3 | Redmine Admin | Please keep in mind the core workflow here for Rails itself: |
| 167 | 3 | Redmine Admin | |
| 168 | 3 | Redmine Admin | * All active development happens on master |
| 169 | 3 | Redmine Admin | * Changes targeting the stable release are made to master and flow *back* to 2.3 |
| 170 | 3 | Redmine Admin | * Development on 2.3 with forward port to master causes log jams and is strongly discouraged |
| 171 | 3 | Redmine Admin | |
| 172 | 1 | Editing someone else's patch: |
|
| 173 | 1 | ||
| 174 | 1 | First, apply the existing patch: |
|
| 175 | 1 | ||
| 176 | 1 | <pre> |
|
| 177 | 1 | git checkout stable |
|
| 178 | 1 | git apply <patch file> |
|
| 179 | 1 | </pre> |
|
| 180 | 1 | ||
| 181 | 3 | Redmine Admin | Then if you need to make changes to the patch (perhaps because Rails has moved on), follow this advice from core: |
| 182 | 3 | Redmine Admin | |
| 183 | 3 | Redmine Admin | For updating others' patches: preserving authorship is a common courtesy we encourage. The simplest is to assign authorship of the fixed commit to the original author and sign off on it. You can @git commit --author "Foo Bar <foobar@example.com>" --signoff@ to make a commit this way, or even @git commit --amend --author ... --signoff@ to change the author and add a signoff to the previous commit. |
| 184 | 3 | Redmine Admin | |
| 185 | 3 | Redmine Admin | Another scenario is building on an incomplete patch. Rather than apply the patch and commit it as yourself, apply it as the original author. Then do subsequent commits as yourself. This preserves the full history and authorship. |
| 186 | 2 | Ryan Bigg | |
| 187 | 2 | Ryan Bigg | h2. Bot commands |
| 188 | 2 | Ryan Bigg | |
| 189 | 2 | Ryan Bigg | *!work <num> or !working <num>* - You start working on a ticket with this ID. Will return an error if ticket does not exist, or is not bugmashable. |
| 190 | 2 | Ryan Bigg | *!stop <num> or !stopworking <num>* - You stop working on a ticket with this ID. Will return an error if you're not working on it, ticket does not exist or is not bugmashable. |
| 191 | 2 | Ryan Bigg | *!gimme* - Tells you about a random ticket from lighthouse that nobody is (yet) working on. To start work on it, use the *!work* command. |
| 192 | 2 | Ryan Bigg | *!review <num>* - Marks the ticket for bugmash-review in Lighthouse. |
| 193 | 2 | Ryan Bigg | *!unreview <num>* - Removes the bugmash-review tag on the ticket in Lighthouse. |
| 194 | 2 | Ryan Bigg | *!me* - Private messages you telling you the number of tickets you're working on and lists them off. |
| 195 | 5 | Mike Gunderloy | |
| 196 | 5 | Mike Gunderloy | h2. Bugmash.com |
| 197 | 5 | Mike Gunderloy | |
| 198 | 5 | Mike Gunderloy | Some information from the [[BugMashFlowChart]] about the special strings in Lighthouse messages that Bugmash.com is looking for: |
| 199 | 5 | Mike Gunderloy | |
| 200 | 5 | Mike Gunderloy | # To up or down vote a ticket use "+1" and "-1". Your comment should also include a brief explanation of your vote. |
| 201 | 5 | Mike Gunderloy | # When verifying a patch or bug use "verified" or "not reproducible". |
| 202 | 5 | Mike Gunderloy | # If you've included a patch make sure your comment includes the phrase "I've attached a patch." |
| 203 | 5 | Mike Gunderloy | # Changeset points will be awarded when the patch is committed to the Rails core. |
| 204 | 5 | Mike Gunderloy | # You can check your score at the "official scoreboard":http://bugmash.com and if we've botched your score please "let us know":http://bugmash.com/issues/new |