Top Banner
Git Flow and Coding Style Bo-Yi Wu 2015/04/10
38

Git Flow and JavaScript Coding Style

Jul 15, 2015

Download

Technology

Bo-Yi Wu
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Git Flow and JavaScript Coding Style

Git Flow and Coding Style

Bo-Yi Wu

2015/04/10

Page 2: Git Flow and JavaScript Coding Style

Agenda

• Git merge vs Git rebase.

• JavaScript Coding Style.

Page 3: Git Flow and JavaScript Coding Style

Git merge vs Git rebase

Page 4: Git Flow and JavaScript Coding Style

Git merge

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

• Merge from develop branch– $ git merge develop

Page 5: Git Flow and JavaScript Coding Style
Page 6: Git Flow and JavaScript Coding Style

git merge develop

Page 7: Git Flow and JavaScript Coding Style
Page 8: Git Flow and JavaScript Coding Style

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

Page 9: Git Flow and JavaScript Coding Style
Page 10: Git Flow and JavaScript Coding Style

git merge develop again

Page 11: Git Flow and JavaScript Coding Style
Page 12: Git Flow and JavaScript Coding Style

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

Page 13: Git Flow and JavaScript Coding Style

git checkout developgit merge --no-ff response

Page 14: Git Flow and JavaScript Coding Style
Page 15: Git Flow and JavaScript Coding Style

Git rebase

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

• Merge from master branch– $ git rebase develop

Page 16: Git Flow and JavaScript Coding Style
Page 17: Git Flow and JavaScript Coding Style

Git rebase master

Page 18: Git Flow and JavaScript Coding Style
Page 19: Git Flow and JavaScript Coding Style

No more new commit log

Page 20: Git Flow and JavaScript Coding Style

Git rebase master again

Page 21: Git Flow and JavaScript Coding Style
Page 22: Git Flow and JavaScript Coding Style

No more new commit log

Page 23: Git Flow and JavaScript Coding Style

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

Page 24: Git Flow and JavaScript Coding Style
Page 25: Git Flow and JavaScript Coding Style

git rebase vs git mergenetwork graph

Page 26: Git Flow and JavaScript Coding Style
Page 27: Git Flow and JavaScript Coding Style

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)

Page 28: Git Flow and JavaScript Coding Style

Rebase vs Merge使用時機

rebase merge

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

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

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

Page 29: Git Flow and JavaScript Coding Style

Develop NotePlease rebase master branch and test again

before creating new Pull Request

Page 30: Git Flow and JavaScript Coding Style

JavaScript Coding Style Guide

Page 31: Git Flow and JavaScript Coding Style

原先架構

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

Page 32: Git Flow and JavaScript Coding Style

Google JavaScript Style Guide

無任何範例可參考

Page 33: Git Flow and JavaScript Coding Style

Airbnb JavaScript Style Guide

https://github.com/airbnb/javascript

Page 34: Git Flow and JavaScript Coding Style

Airbnb JavaScript Style Guide

程式碼範例完整

另外也可以參考 ES6 Branch

Page 35: Git Flow and JavaScript Coding Style

Yoda Conditions

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

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

}

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

}

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

Page 36: Git Flow and JavaScript Coding Style

Yoda Conditions

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

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

}

避免此種情況發生

Page 37: Git Flow and JavaScript Coding Style

How to prevent the condition?

Write Unit Test

Page 38: Git Flow and JavaScript Coding Style

Thanks