现在您已经在桌面上运行 Gaia, 并且对源代码的工作方式有了一定程度的理解,下一步就应该准备好为项目做贡献了。本文则描述了如何修改代码以及如何在代码中找到 bug 出现的位置。
Git 最佳实践
- 当对 Gaia 修改时, 首先需要从 master 上获取最新的代码:
cd path/to/gaia git checkout master git pull
- 下面切换到您解决问题的分支:
git checkout -b my-code-fix
- 最后,到
gaia/apps
目录下,可以修改对应的文件了。
注意: 在 gaia/profile-debug/
目录下,您会找到 webapps/
, 但其中只包含需要运行的 app 的manifest 文件,而 app 是存在于 gaia/apps/
目录下的。
简单的代码修改示例
您可以按照需求对代码作出修改,保存修改,在 Firefox 桌面中运行 Gaia 并刷新 tab 页以查看效果。 Let's do something simple like change the text colour of the clock on the lock screen:
- The best way to find how this style is set is to use the developer tools. Ctrl/right + click on the clock in Firefox Desktop and select Inspect Element from the context menu.
- You can then work out which CSS file to edit —
gaia/apps/system/style/lockscreen.css
in this case — and then make your changes in the CSS styles on the right hand side of the display to get it to the state you want. - When you are happy with the change, go and make the change in the file directly.
- Next, refresh the tab (or use the Reload application button) and the HTTP server serves the changes instantly:
Limitations of Gaia Desktop Firefox rendering:
- In the Desktop Firefox rendering, the apps are fairly accurate compared to how they work on a real phone, but you may notice some differences here and there.
- Not all device APIs are supported in desktop Firefox; you can find a list of the ones that are enabled in preferences.js.
发现 bug 出现的地方
The best way to find Firefox OS bugs to work on is to consult Josh Matthews' Bugs Ahoy app — this pulls in bugs directly from Mozilla's Bugzilla and displays them in an easy to search and browse way. One you have found a bug that you want to work on, go to its Bugzilla page, enter yourself in the "assigned to" field, and start work, as indicated above.
有用的提示
- When you work on mentored bugs, one of the Gaia core team will monitor your progress and provide help with the code and process. If you are a beginner to the Firefox OS contribution process, signing up for one of these can be helpful. These are indicated in Firefox OS Bugzilla pages by an entry in the "Mentors" field. Buys Ahoy lists mentored bugs.
- If you are a completely new Bugzilla user, you may not be able to assign yourself to work on a bug. If you can’t, ask the mentor assigned to that bug to assign you if it has one, or just ask in the bug comments otherwise.
- After you have a bit more experience, you should ask someone to give you permission to assign bugs to yourself.
- Another good whiteboard entry to look out for is
[good first bug]
, if you are a new contributor and want to start with something simple. You can list just good first bugs using https://www.joshmatthews.net/bugsahoy/?b2g=1&simple=1. - You should save a search for projects you want to contribute to. For example, the following would give you a Gaia Clock app bug search:
参考
- Gaia powerpoints for visual/interaction specifications
- Weekly Gaia meeting Etherpad
- Datazilla: Mozilla's performance test utility