Upgrade to Pro — share decks privately, control downloads, hide ads and more …

TDD with git. Long live engineering.

Koichi ITO
October 03, 2020

TDD with git. Long live engineering.

Koichi ITO

October 03, 2020
Tweet

More Decks by Koichi ITO

Other Decks in Programming

Transcript

  1. Koichi ITO / ESM, Inc. Kaigi on Rails STAY HOME

    Edition TDD with git. Long live engineering. 2020-10-03(Sat)
  2. @koic • RuboCop core team • OSS Programmer • Agile

    software development practitioner • Distinguished Engineer at ESM, Inc. Me and @amapyon, @fkino, @sizuhiko
  3. Koichi ITO / ESM, Inc. Kaigi on Rails STAY HOME

    Edition TDD with git. Long live engineering. 2020-10-03(Sat)
  4. • ෼ࢄSCMͰ͋ΔGit / Mercurial (hg) / Bazaar ͋ͨΓͰ೼ݖΛ૪͍ͬͯͨ • GitoliteͳͲͰࣾ಺GitαʔόʔΛཱͯͯɺmaster

    ʹ௚઀push͍ͯͨ͠ • git logͰmaster (main) ͷίʔυΛͲΕ͚ͩϨ Ϗϡʔ͠·͔͢ʁ GitHubҎલͷGitར༻ࣄྫ
  5. • ίʔυͷ੒௕ͷϨϕϧΞοϓ … master (main) ʹೖ Δલͷஈ֊Ͱɺࣗଞͷίʔυ͕ʮݟ͑ΔԽʯ͞Εͯ ΑΓྑ͍࣮૷ͷఏҊ΍ɺཁ݅΁ͷൈ͚࿙ΕΛϑΟʔ υόοΫͰ͖Δ •

    ਓͷϨϕϧΞοϓ … ࣗ෼ͷॻ͍ͨಈ͘ίʔυ΁ͷ ίʔυϨϏϡʔ͸ϦϙδτϦʹࢀՃ͍ͯ͠ΔγχΞ ͷࢹ఺Λ֫ಘ͢Δݱࡏ࠷ߴͷΤϯδχΞҭ੒ํ๏ ίʔυϨϏϡʔʹΑΔಇ͖ํվֵ
  6. Green Refactor Red Consider `git push` (SFFO 3FE 3FGBDUPS commit

    commit commit (SFFO push CI Basic 5%% (JU
  7. • ݸਓͷίʔυΛνʔϜͷίʔυʹ͢Δߦҝ • ݸਓͷίϛοτ͸࡞ۀͷ۠੾ΓͰ·Ίʹίϛοτ͢Δ Red, Green, Refactor…
 
 
 


    • νʔϜͷίϛοτͰ͸มߋཧ༝ΛḷΕΔΑ͏ʹ੔͑Δ git push (towards “Collective Ownership”) IUUQTUXJUUFSDPNU@XBEBTUBUVT
  8. Green Refactor Red ୭ͷͨΊͷίʔυʁ (SFFO 3FE 3FGBDUPS commit commit commit

    (SFFO push CI Basic 5%% (JU Personal Code Team’s Code $PMMFDUJWF 0XOFSTIJQ
  9. Green Refactor Red ୭ͷͨΊͷίʔυʁ (SFFO 3FE 3FGBDUPS commit commit commit

    (SFFO push CI Basic 5%% (JU Personal Code Team’s Code $PMMFDUJWF 0XOFSTIJQ
  10. Green Refactor Red Advanced translation technique (SFFO 3FE 3FGBDUPS commit

    commit commit (SFFO push squash (and amend) CI Basic Advanced 5%% (JU 3FGBDUPS Personal Code Team’s Code commit design $PMMFDUJWF 0XOFSTIJQ
  11. HJUCMBNF ͳͲͰ௥੻͠΍͍͢ Α͏ʹมߋཧ༝ͷ୯ ҐͰίϛοτΛ·ͱ Ί͓ͯ͘ มߋཧ༝ʹ ج͍ͮͨ࡞ۀΛ͸͡ Ίͯɺ࡞ۀͷ੾Ε໨ ੾Ε໨Ͱςετͱί ϛοτΛ͍ͯ͘͠

    ϦϑΝΫλϦϯάաఔͱϦϑΝΫλϦϯάޙ pushޙ (ϝϯςφϯεͰಡΉͱ͖) pushલ (ίʔυΛॻ͍͍ͯΔͱ͖) ಈࢺͱͯ͠ͷϦϑΝΫλϦϯάΛਐΊ͍ͯΔ΋ͷ ϦϑΝΫλϦϯάͷ݁Ռ (Χλϩάͷafter) Λ squash͔ͨ͋ͨ͠΋࠷ॳ͔Β៉ྷͳίʔυ
  12. • ࠷ॳ͔Β៉ྷͳίʔυΛॻ͚ΔεʔύʔΤϯδχΞʹ͸ ϦϑΝΫλϦϯά͸ෆཁ͔΋͠Εͳ͍ • ࠷ॳ͔Β៉ྷͳίʔυΛॻ͘͜ͱ͕೉ͯ͘͠΋ςετΛݩʹ ϦϑΝΫλϦϯάΛ܁ΓฦͤΔͱ͍͏TDDͱ͍͏εΩϧ • TDD (Baby steps

    by XP) ʹΑͬͯ࡞ۀܦաίϛοτ͕૿͑Δ • ࡞ۀͷ్தܦաΛsquash͢Δ͜ͱͰεʔύʔΤϯδχΞͱಉ ݁͡Ռʹ͚ۙͮͨίϯτϦϏϡʔγϣϯΛνʔϜʹͰ͖Δ ;ͭ͏ͷਓͷͨΊͷTDDϦϑΝΫλϦϯάͱͦͷઌ
  13. pick, squash, or another PR? ࣮૷աఔͰͷςετ௥Ճɺ όάϑΟοΫε΍খ͞ͳϦ ϑΝΫλϦϯάͰ͔͢ʁ TRVBTI QJDL

    ϦϦʔεࠩ͠໭͠ͷͱ͖ ͳͲಠཱͯ͠Ϧόʔτ͠ ͍ͨίϛοτͰ͔͢ʁ "OPUIFS 13 ͻͱͭͷϒϥϯνʹͻ ͱͭͷίϛοτ͚ͩͰ ͔͢ʁ ػೳͷ௥Ճมߋͱ෼཭ Ͱ͖Δطଘػೳ΁ͷϦ ϑΝΫλϦϯάͰ͔͢ʁ ΋͠ϨϏϡʔͰͷࢦఠͰͳ ࣗ͘ྗͰؾ͍͍ͮͯͨΒ ίϛοτΛ෼͚·͔͢ʁ ͻͱͭͷPRʹෳ਺ͷػ ೳཁٻʹର͢Δมߋ͕ ࠞ͟Γ·͔͢ʁ No Yes Yes No Yes No Yes Yes No Yes No No Start ಠཱͯ͠ϚʔδͰ͖Δ
  14. Use `--fixup` to temporary commit HDJNb"EEOFXA'PP#BSADPQ` <UPQJDBDFD>"EEOFXA'PP#BSADPQ HDJNb&YUSBDUNFUIPE` <UPQJDGEED>&YUSBDUNFUIPE HDJNb'JYBUZQP`

    <UPQJDGEED>'JYBUZQP HDJNb3FOBNFNFUIPE` <UPQJDGEED>3FOBNFNFUIPE HSJHJUSFCBTFJ)&"%d 3FNPWFDPNNJUNFTTBHFTPUIFSUIBO UIFpSTUNFTTBHFBOERVJUUIFFEJUPS git commit HDJNb"EEOFXA'PP#BSADPQ` <UPQJDBDFD>"EEOFXA'PP#BSADPQ HDG <UPQJDGEED>pYVQ"EEOFXA'PP#BSADPQ HDG <UPQJDGEED>pYVQpYVQ"EEOFXA'PP#BSA DPQ HDG <UPQJDGEED>pYVQpYVQpYVQ"EEOFX A'PP#BSADPQ HSJ 2VJUUIFFEJUPS git commit --fixup=HEAD Before Current
  15. Four my git aliases I use a lot SJTIDHJUSFCBTFJ)&"%d 1.

    First commit in the new branch 2. Second commit and the subsequence 3. Squash the above commits into one DGDPNNJUWpYVQ)&"% DJDPNNJUW DBDPNNJUWBNFOE 4. Amend a commit message
  16. Before HDJNb"EEOFXA'PP#BSADPQ` <UPQJDBDFD>"EEOFXA'PP#BSADPQ HDJNb&YUSBDUNFUIPE <UPQJDGEED>&YUSBDUNFUIPE HDJNb'JYBUZQP <UPQJDGEED>'JYBUZQP HDJNb3FOBNFNFUIPE` <UPQJDGEED>3FOBNFNFUIPE HSJ

    3FNPWFDPNNJUNFTTBHFTPUIFSUIBO UIFpSTUNFTTBHFBOERVJUUIFFEJUPS git commit ΛϦϑΝΫλϦϯάͷ౎౓ͯ͠ɺ࠷ޙʹsquash͢Δ 5IJOLBCPVUUIFDPNNJUNFTTBHF 5IJOLBCPVUUIFDPNNJUNFTTBHF 5IJOLBCPVUUIFDPNNJUNFTTBHF 5IJOLBCPVUUIFDPNNJUNFTTBHF /FFEUPBEKVTUUPDPNNJUNFTTBHF
  17. Current HDJNb"EEOFXA'PP#BSADPQ` <UPQJDBDFD>"EEOFXA'PP#BSADPQ HDG <UPQJDGEED>pYVQ"EEOFXA'PP#BSADPQ HDG <UPQJDGEED>pYVQpYVQ"EEOFXA'PP#BSA DPQ HDG <UPQJDGEED>pYVQpYVQpYVQ"EEOFX

    A'PP#BSADPQ HSJ 2VJUUIFFEJUPS git commit —fixup=HEAD Ͱ਺चͭͳ͗ͯ͠ɺsquash Ͱ·ͱΊΔ %PO`U5IJOLBCPVUUIFDPNNJUNFTTBHF %PO`U5IJOLBCPVUUIFDPNNJUNFTTBHF 5IJOLBCPVUUIFDPNNJUNFTTBHF %PO`U5IJOLBCPVUUIFDPNNJUNFTTBHF /PBEKVTUNFOUUPDPNNJUNFTTBHFSFRVJSFE You can think about the details of the commit message
  18. ci = commit -v ͱ͍͏ΤΠϦΞεͰɺPRϒϥϯν΁ ͷ࠷ॳͷίϛοτʹ g ci . -m

    'message' Λ࢖͏ 2 types of commit methods มߋཧ༝΁ͷίϛοτ ࡞ۀͷ੾Ε໨΁ͷίϛοτ cf = commit -v --fixup=HEAD ͱ͍͏ΤΠϦΞεͰɺ
 PRϒϥϯν΁ͷϦϑΝΫλϦϯάͰg cf . Λ૬౰ʹ࢖͏
  19. “Tools and techniques change often, but they don't change a

    lot People, however, change slowly but deeply. XPE2nd Chap. 23 ツールと技術は頻繁に変わるが、⼤幅に変わることはない。 しかし、⼈はゆっくりだが深く変わっていく。 Embrace Change (มԽϮ๊༴ηϤ)