Tags:

พอดีนั่งทำ project อยู่แล้วรู้สึกว่าตอน commit git อยากมี standard สักอย่างในการ commit ซึ่งก็พอลองไปหาดูใน Google ก็เหมือนกับมีหลากหลายแบบมาก เลยมาถามความเห็นว่าแต่ละคนมีแนวทางในการ commit git โดยใช้ format อะไรเป็น standard กันครับ

Get latest news from Blognone
By: bluezip
AndroidUbuntuWindows
on 24 July 2019 - 15:45 #1121280

แตก branch แล้วทำแต่ละ features ให้เสร็จและก็ merge เข้า production มั่ง

By: armariya
AndroidUbuntuWindows
on 24 July 2019 - 19:09 #1121295

ผมเพิ่งย้ายมาใช้ https://www.conventionalcommits.org/en/v1.0.0-beta.4/ อันนี้ ผมว่าก็โอเคนะครับ อ่านง่าย

By: bellpocket on 24 July 2019 - 20:13 #1121297

“fixed fn aaa”

By: ZiiT
ContributorAndroidWindows
on 25 July 2019 - 11:06 #1121356

ของผมไม่สนใจ commit description เพราะถือเป็น work in progress แต่จะไปเน้นที่ Pull Request (PR) แทน โดยมีรายละเอียดประมาณนี้

  • PR Title สื่อความหมาย
  • PR ต้อง Link กับงาน (Work Item/Bug)
  • PR มี Code reviewer approve อย่างน้อย 2 คน, approve status จะถูก reset ถ้ามี code ใหม่ push ขึ้นไป
  • PR Build CI ผ่าน
  • Merge PR แบบ squash merge ทำให้ใน Master branch จะเห็นเป็น commit เดี๋ยวโดยมี PR Number/Title เป็น Commit description เพื่อไม่ให้ History ของ Master เปื้อนไปด้วย commit description พวก "fix bug", "fix typo" ที่ไม่มีประโยชน์เวลากลับมาย้อนดู
By: bellpocket on 30 July 2019 - 09:14 #1121916 Reply to:1121356

+1 น่าสนใจ

By: ripzery
AndroidWindows
on 1 August 2019 - 22:08 #1122351 Reply to:1121356

ผมว่า commit msg มีประโยชน์กับ reviewer อยู่ดีนะ

By: ZiiT
ContributorAndroidWindows
on 2 August 2019 - 11:26 #1122416 Reply to:1122351

ใช่ครับ แต่มีประโยชน์แค่ใน Pull Request นั้นๆ พอ Merge เข้าไปใน Master branch แล้ว สำหรับผมมันไม่มีประโยชน์แล้ว เพราะหลายๆครั้งจะเป็น Refactor xx, fix comment yyy

By: whitebigbird
Contributor
on 2 August 2019 - 18:40 #1122475 Reply to:1122416
whitebigbird's picture

แต่ส่วนมากระบบมันก็ดึง commit message มาใส่ PR ไม่ใช่เหรอครับ?

By: ZiiT
ContributorAndroidWindows
on 3 August 2019 - 15:20 #1122553 Reply to:1122475

ขึ้นอยู่กับว่าเราตั้งให้ Merge PR เข้า Master branch แบบไหนครับ

อันนี้ตัวอย่างของ Github https://help.github.com/en/articles/about-merge-methods-on-github

อันนี้ของตัวอย่าง Azure DevOps https://devblogs.microsoft.com/devops/pull-requests-with-rebase/

By: whitebigbird
Contributor
on 3 August 2019 - 17:20 #1122563 Reply to:1122553
whitebigbird's picture

หมายถึงว่ามันจะดึง commit message มารอเอาไว้ก่อนที่จะกด create PR น่ะครับ แล้วเราก็สามารถจะ edit หรือใช้ commit message นั้นๆ ไปเลยก็ได้

แต่คิดไปคิดมา แบบที่คุณทำอ่ะเป็น practice ที่แม่นสุดแล้วครับ

By: ripzery
AndroidWindows
on 14 August 2019 - 21:08 #1123902 Reply to:1122563

ขึ้นอยู่กับ VCS hosting แต่ละเจ้าครับ ถ้า Bitbucket จะดึง commit msg มาเป็นค่า default ของ PR description แต่ถ้า Github จะไม่มีครับ ยกเว้นกำหนด .github/pull_request_template.md ไว้ใน root directory ก็จะใช้ template นั้นแทน

By: tg-thaigamer
ContributoriPhoneAndroidBlackberry
on 3 August 2019 - 12:27 #1122545 Reply to:1121356
tg-thaigamer's picture

เรียกว่า squash merge นี่เอง ปกติ ใช้ Merge pull request แล้วคอมเม้นต์คนอื่นทำมาหมดเลย ทำให้ตัว master ปนเปื้อนจริงๆ


มือใหม่!! ใหม่จริงๆนะ