`
love~ruby+rails
  • 浏览: 849753 次
  • 性别: Icon_minigender_1
  • 来自: lanzhou
社区版块
存档分类
最新评论

BugMash Cheat Sheet

阅读更多

Here's a list of handy shortcuts for BugMashers.

Required software

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.

Generating a Rails app on master branch

You can generate a quick sample application from the Rails source code tree by

cd railties
rake dev

This will create a new application named rails at the root of your Rails repository. (NOTE: As of Sept 26, rake dev appears to be busted. https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/3261-rake-dev-not-working-on-master has a fix.)

Testing Active Record

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 activerecord directory.

rake mysql:build_databases

There is also a PostgreSQL task for doing the same job given you have PostgreSQL installed on your system.

rake postgresql:build_databases

When you're done testing patches, you can delete the generated databases.

rake mysql:drop_databases
rake postgresql:drop_databases

There are also useful tasks for deleting and regenerating databases if you need to refresh.

rake mysql:rebuild_databases
rake postgresql:rebuild_databases

If you're writing new tests for ActiveRecord, please try to reuse the existing test models instead of adding new ones.

Testing specified frameworks only

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.

cd activesupport
rake test

Testing Active Record

Running rake test for Active Record will run tests for MySQL, SQLite3 and PostgreSQL. To run test individually based on different adapters:

rake test_mysql
rake test_postgresql
rake test_sqlite3

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.

Testing Individual Files

Better yet, you can test a separate file for a speed boost.

rake test TEST=test/ordered_options_test.rb

If testing ActiveRecord and you've changed the schema, you have to initialize the database before running the test:

rake test_mysql TEST=test/cases/aaa_create_tables_test.rb # update the schema
rake test_mysql
TEST=test/cases/associations/has_many_through_associations_test.rb

Working with Rails and git

Getting the Rails source:
git clone git://github.com/rails/rails.git
cd rails
git checkout -b 2-3-stable origin/2-3-stable # this will leave you on the 2-3-stable branch
(you can also do: git checkout -t origin/2-3-stable # this will also leave you on the 2-3-stable branch)
Working on the master (3.0) branch:
git checkout master
Working on the 2-3-stable branch:
git checkout 2-3-stable
Creating your own feature branch:
git checkout -b my_feature_branch
Apply a patch:
git apply <patch file>
Creating a patch:
git checkout master
git checkout -b my_feature_branch
(write and test code)
git commit -a -m "This is my great patch" 
git checkout master
git pull
git checkout my_feature_branch
git rebase master
rake (to be sure tests still patch)
git format-patch master --stdout > my_great_patch.diff
Patching both master and 2-3-stable:

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:

git checkout -b my-feature-2-3 2-3-stable
git cherry-pick <revision of change made to master>
rake test
git format-patch 2-3-stable --stdout > my_great_patch_for_rails23.diff

As a last resort, you can write a completely separate patch for 2.3:

git checkout 2-3-stable
git checkout -b my_feature_branch
(write and test code)
git commit -a -m "This is my great patch" 
git checkout 2-3-stable
git pull
git checkout my_feature_branch
git rebase 2-3-stable
rake (to be sure tests still patch)
git format-patch 2-3-stable --stdout > my_great_patch.diff

NOTE

Please keep in mind the core workflow here for Rails itself:

  • All active development happens on master
  • Changes targeting the stable release are made to master and flow back to 2.3
  • Development on 2.3 with forward port to master causes log jams and is strongly discouraged

    Editing someone else's patch:

First, apply the existing patch:

git checkout stable
git apply <patch file>

Then if you need to make changes to the patch (perhaps because Rails has moved on), follow this advice from core:

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 &lt;foobar@example.com&gt;" --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.

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.

分享到:
评论

相关推荐

    CheatSheet for Mac

    "CheatSheet for Mac"就是一款专为Mac用户设计的快捷键查看工具,它能够帮助用户快速了解并记忆系统及应用中的快捷键组合,提升操作效率。这款软件的版本号是1.0.1,且提供免费下载,使得更多用户得以轻松享受便捷的...

    cheatsheet for mac

    标题中的“cheatsheet for mac”指的是Mac操作系统中的一种实用工具,它可以帮助用户快速了解并记忆各种应用程序的快捷键。快捷键是提高工作效率的关键,尤其是在使用计算机时,熟练掌握快捷键能够大大提升工作速度...

    CheatSheet_1.2.9 for MacOS

    《CheatSheet_1.2.9 for MacOS:掌握Mac系统的高效快捷键操作》 在数字化办公的时代,熟练掌握计算机快捷键是提升工作效率的关键。针对Mac操作系统,有一款名为"CheatSheet"的实用工具,其版本1.2.9特别为Mac用户...

    CheatSheet_1.2.7 最新中文版

    标题中的"CheatSheet_1.2.7 最新中文版"指的是CheatSheet这款软件的最新版本1.2.7,它是一款专为Mac操作系统设计的实用工具。CheatSheet的主要功能是帮助用户快速掌握并记忆各种应用程序的快捷键,从而提高在Mac系统...

    CheatSheet_1.3.1

    《CheatSheet_1.3.1:提升软件使用效率的快捷键指南》 在数字化时代,高效使用各种软件已经成为日常工作中不可或缺的技能。而掌握软件的快捷键,无疑是提升工作效率的一大法宝。CheatSheet_1.3.1,这款实用工具,...

    CheatSheet.app.zip

    标题中的"CheatSheet.app.zip"表明这是一个用于Mac操作系统的应用程序,它被压缩成ZIP格式以方便下载和分发。这个应用程序的主要功能是提供一个快捷键的清单,帮助用户快速了解和使用各种系统及应用的快捷键。 在...

    clojure-cheatsheet, 用于Emacs的Clojure Cheatsheet.zip

    clojure-cheatsheet, 用于Emacs的Clojure Cheatsheet 用于Emacs的难以置信方便的 Clojure Cheatsheet,更新为 Clojure,打包成简单,快速,可以搜索的离线形式: 状态准备使用基于 Clojure 1.7.0.安装如果你连接到 ...

    conda cheat sheet v4.6.zip

    conda cheat sheet,4.6.1 版本。有了这份 conda cheat sheet 再配合 help 命令,基本能解决 conda 使用中的大部分问题。这份 cheat sheet 从官网搬运,上传到 CSDN 资源主要是为了网络环境不太理想的 Python 学习者...

    markdown-cheatsheet, 用于 Github README.md的Markdown Cheatsheet.zip

    markdown-cheatsheet, 用于 Github README.md的Markdown Cheatsheet Markdown Heading HeadingMarkup : # Heading 1 #-OR-Markup : ============= (below H1 text)标题 2Mark

    Python 3 Cheat Sheet

    Python 3 Cheat Sheet 2012-2013 - Laurent Pointal Mémento v1.2.1bis Official Python documentation on http://docs.python.o

    CheatSheet_1.3.4.zip

    CheatSheet for Mac是专门用来查看应用程序快捷键的工具,安装好cheatsheet软件后,在软件界面长按Command键即可快速查看快捷键列表,非常的便捷,想要了解更多关于软件的快捷键,那就赶紧试试cheatsheet for mac吧...

    opencv_cheatsheet

    opencv_cheatsheet

    x86 assembly cheatsheet

    x86 assembly cheatsheet

    Machine Learning Super VIP Cheatsheet

    Machine Learning Super VIP Cheatsheet

    第18章 备忘单(CheatSheet)

    第18章 备忘单(CheatSheet),swt,eclipse插件开发学习笔记 第18章 备忘单(CheatSheet),swt,eclipse插件开发学习笔记 第18章 备忘单(CheatSheet),swt,eclipse插件开发学习笔记 第18章 备忘单(CheatSheet...

    RAPIDS cheatsheet.pdf

    在RAPIDS的cheatsheet中,通常会包括以下几个方面的知识点: 1. 数据操作基础:RAPIDS利用 cudf 库来执行类似Pandas的DataFrame操作。例如,`gdf.sort_values('mpg')`和`gdf.sort_values('mpg', ascending=False)`...

    R cheatsheet advanced

    为了提高工作效率和编写更流畅的代码,开发者们常常会使用一些快捷方式或者技巧,这些内容被整理成“cheatsheet”(速查表),以供快速查阅和参考。这次我们讨论的“R cheatsheet advanced”涉及到在使用R语言进行...

    CSS3 CHM版手册和 CSS3 Cheat Sheet打包

    **CSS3 CHM版手册和CSS3 Cheat Sheet打包**提供了全面深入学习CSS3的重要资源,这两份资料旨在帮助开发者快速掌握和应用CSS3的各种新特性。CHM版手册和Cheat Sheet结合使用,能有效提升理解和实践能力。 **CSS3 CHM...

    Vim cheatsheet中文版 绝对珍藏版

    Vim cheatsheet中文版 绝对珍藏版 很不错的

    CheatSheet合集1.pdf

    标题《CheatSheet合集1.pdf》中包含的知识点: - CheatSheet是一种速查手册,为程序员提供快速查阅各种编程语言和技术的要点、函数、方法和快捷键等重要信息。 - 本合集涵盖了多种编程语言和技术的常见用法和快捷...

Global site tag (gtag.js) - Google Analytics