git flow and javascript coding style

Post on 15-Jul-2015

1.460 Views

Category:

Technology

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Git Flow and Coding Style

Bo-Yi Wu

2015/04/10

Agenda

• Git merge vs Git rebase.

• JavaScript Coding Style.

Git merge vs Git rebase

Git merge

• Create your branch– $ git checkout –b ‘response’

• Merge from develop branch– $ git merge develop

git merge develop

New commitMerge branch 'develop' into response (HEAD, response)

git merge develop again

New commitMerge branch 'develop' into response (HEAD, response)

git checkout developgit merge --no-ff response

Git rebase

• Create your branch– $ git checkout –b ‘response’

• Merge from master branch– $ git rebase develop

Git rebase master

No more new commit log

Git rebase master again

No more new commit log

Create your new Pull Requestgit merge --no-ff respnse

git rebase vs git mergenetwork graph

Rebase vs Merge 優缺點

rebase merge

避免過多merge commit log 產生merge commit log

Branch commit log排到最前面(方便追蹤) 依照時間排序 commit log

network graph清楚 network graph不易理解

各別 commit解決 conflict 一次將全部衝突顯示

可任意修改 commit log

可合併多個 commit (避免過多無意義commit log)

Rebase vs Merge使用時機

rebase merge

整理 Branch commit log 主分支記錄合併 xxxx branch

非主分支開發無需記錄何時合併主分支

主分支請勿使用 rebase合併任何分支

Develop NotePlease rebase master branch and test again

before creating new Pull Request

JavaScript Coding Style Guide

原先架構

https://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml

Google JavaScript Style Guide

無任何範例可參考

Airbnb JavaScript Style Guide

https://github.com/airbnb/javascript

Airbnb JavaScript Style Guide

程式碼範例完整

另外也可以參考 ES6 Branch

Yoda Conditions

https://en.wikipedia.org/wiki/Yoda_conditions

if ($a === ‘1’) {// code block

}

if (‘1’ === $a) {// code block

}

程式閱讀性高 程式閱讀性低

Yoda Conditions

https://en.wikipedia.org/wiki/Yoda_conditions

if ($a = ‘1’) {// code block

}

避免此種情況發生

How to prevent the condition?

Write Unit Test

Thanks

top related