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

Git & GitLab & コードレビューって? / about Git, GitLab, ...

Taiju Aoki
February 21, 2020

Git & GitLab & コードレビューって? / about Git, GitLab, CodeReview

Study Slide for Git Newbie

Taiju Aoki

February 21, 2020
Tweet

More Decks by Taiju Aoki

Other Decks in Programming

Transcript

  1. ࢲ͸୭ʁ blue (@blue_1617) https://blue0513.github.io/show_room/ 2 Rails, JavaScript, Scala etc ΤϜεϦʔ:

    Ϋϥ΢υిࢠΧϧςνʔϜॴଐ ͨ·ʹ C# ͱ͔ DevOps ΋΍ΔΑ GitHubͱ͔ ‣ slackdeck-proto : Slack ͷ TweetDeck ෩ Viewer ‣ minideck : TweetDeck ͷ͍͍ײ͡ͷ Viewer ‣ phantom-inline-comment: Emacs ͷ package ‣ point-history: Emacs ͷ package ‣ instant-maximized-window: Emacs ͷ package
  2. લఏ৚݅ 4 υϯυϯ࣭໰ͪ͠Ό͍ͬͯͩ͘͞ʂ ‣ Ұํతͳߨٛ͡Όͳ͍Ͱ͢ ؒҧͬͯͨΒڭ͍͑ͯͩ͘͞ʂ ‣ blue ΋·ͩۦ͚ग़͠ͷΤϯδχΞͰ͢ ଞͷҙݟ΋͍ͬͺ͍͋Δͱࢥ͍·͢

    ‣ ઈରతͳՁ஋ج४Ͱ͸ͳ͍Ͱ͢ ΤϯδχΞ͸ֶͼଓ͚Δ࢟੎͕ඞཁͩͱࢥ͍·͢ ‣ ͜ͷษڧձΛ੒௕ͷ͖͔͚ͬʹ͍ͯͩ͘͠͞
  3. ͦ΋ͦ΋ Git ͬͯԿ͕Ͱ͖Δͷʁ 6 Git is a free and open

    source distributed version control system designed to handle everything from small to very large projects with speed and efficiency https://git-scm.com/
  4. ͦ΋ͦ΋ Git ͬͯԿ͕Ͱ͖Δͷʁ 7 Git is a free and open

    source distributed version control system designed to handle everything from small to very large projects with speed and efficiency https://git-scm.com/ Branching & Merging Data Assurance Staging Area
  5. Branching & Merging 8 ෳ਺ͷ Branch Λ·͕ͨͬͯ։ൃͰ͖Δ ʢBranch: ֤ʑಠཱͨ͠ workspaceʣ

    ‣ Master branch ‣ Develop branch ‣ Topic branch ຊ൪؀ڥʹσϓϩΠ͢Δ/ͨ͠ branch Topic branch Λ·ͱΊͨ౷߹ branch ݕূ؀ڥͳͲʹ͋͛ͯ QA ͞ΕΔ ػೳ։ൃͷ branch ػೳ͝ͱʹ࡞ΒΕΔͨΊɺ࠷΋਺͕ଟ͍ https://git-scm.com/about/branching-and-merging
  6. Branching & Merging 9 ෳ਺ͷ Branch Λ·͕ͨͬͯ։ൃͰ͖Δ ʢBranch: ֤ʑಠཱͨ͠ workspaceʣ

    ‣ Master branch ‣ Develop branch ‣ Topic branch ຊ൪؀ڥʹσϓϩΠ͢Δ/ͨ͠ branch Topic branch Λ·ͱΊͨ౷߹ branch ݕূ؀ڥͳͲʹ͋͛ͯ QA ͞ΕΔ ػೳ։ൃͷ branch ػೳ͝ͱʹ࡞ΒΕΔͨΊɺ࠷΋਺͕ଟ͍ Topic into Develop Develop into Master https://git-scm.com/about/branching-and-merging
  7. Branching & Merging 10 ΋͠΋ Master branch ҰຊͰӡ༻͢Δͱʁ 1. Ͳͷ

    commit ·Ͱ͕ຊ൪؀ڥʹσϓϩΠ͞Ε͍ͯΔ͔ෆ໌ 2. ۓٸमਖ਼൛ΛϦϦʔε͢Δͱ͖ʹɺະ QA ͷ΋ͷ͕ࠞ͡Δ etc etc .... 3. ϨϏϡʔΛ͢Δͷ͕೉͍͠ ੡඼ͷΫΦϦςΟΛ୲อͰ͖ͳ͍ʂ
  8. Staging Area 11 ‣ Working Directory ‣ Staging Area ‣

    Repository มߋΛ֬ఆ͢Δલͷஈ֊͕ଘࡏ͢Δ (commit) ࡞ۀதͷۭؒ var temp = 'DEBUG' ͱ͔ͯ͠΋OK มߋ֬ఆલͷۭؒ มߋ͕ଥ౰ͳ΋ͷ͔ΛνΣοΫ͢Δ มߋ֬ఆޙͷۭؒ git add file git commit -m "msg" https://git-scm.com/about/staging-area
  9. Staging Area 12 ‣ Working Directory ‣ Staging Area ‣

    Repository มߋΛ֬ఆ͢Δલͷஈ֊͕ଘࡏ͢Δ (commit) ཤྺʹ࢒͢/࢒͞ͳ͍มߋΛબ୒Ͱ͖Δ https://git-scm.com/about/staging-area commit ͷཻ౓Λ؆୯ʹௐ੔Ͱ͖Δ
  10. Data Assurance 13 commit ͨ͠಺༰ͦͷ΋ͷ͕อ࣋͞ΕΔ ޙʑมߋ͢Δ͜ͱ͕ʢࣄ্࣮ʣෆՄೳ 1. Project ಺༰Λ commit

    ͳ͠ʹมߋ͢Δ͜ͱ͕ෆՄ 2. ୭͕ clone ͯ͠΋ಉ݁͡ՌʹͳΔ 3. ྺ࢙Λ׬શʹอ࣋͢ΔʢVersion Controlʣ https://git-scm.com/about/info-assurance
  11. Data Assurance 14 commit ͨ͠಺༰ͦͷ΋ͷ͕อ࣋͞ΕΔ ޙʑมߋ͢Δ͜ͱ͕ʢࣄ্࣮ʣෆՄೳ 1. Project ಺༰Λ commit

    ͳ͠ʹมߋ͢Δ͜ͱ͕ෆՄ 2. ୭͕ clone ͯ͠΋ಉ݁͡ՌʹͳΔ 3. ྺ࢙Λ׬શʹอ࣋͢ΔʢVersion Controlʣ ෳ਺ਓͰͷ։ൃ͕ඇৗʹ༰қ https://git-scm.com/about/info-assurance
  12. Git ͬͯͳʹ͕خ͍͠ͷʁ 15 https://git-scm.com/about/ ‣ Branching & Merging ͷ࢓૊ΈͰɺฒߦͨ͠։ൃ͕༰қʹ ‣

    Staging Area ʹΑͬͯɺมߋΛۛຯͰ͖Δ ‣ Data Assurance ͷੑ࣭Ͱɺෳ਺ਓ։ൃ͕༰қʹ
  13. ͦ΋ͦ΋ GitLab ͬͯԿʁ 17 GitLab is a web-based DevOps lifecycle

    tool that provides a Git- repository manager providing wiki, issue-tracking and CI/CD https://en.wikipedia.org/wiki/GitLab pipeline features https://about.gitlab.com/stages-devops-lifecycle/continuous-integration/
  14. ͦ΋ͦ΋ GitLab ͬͯԿʁ 18 GitLab is a web-based DevOps lifecycle

    tool that provides a Git- repository manager providing wiki, issue-tracking and CI/CD https://en.wikipedia.org/wiki/GitLab pipeline features https://about.gitlab.com/stages-devops-lifecycle/continuous-integration/ WIKI ISSUE MR
  15. Merge Request (MR) 19 Merge requests allow you to visualize

    and collaborate on the proposed changes to source code that exist as commits on a given Git branch Title Description Target Branch https://about.gitlab.com/
  16. Merge Request (MR) 20 Merge requests allow you to visualize

    and collaborate on the proposed changes to source code that exist as commits on a given Git branch Modified Sources https://about.gitlab.com/
  17. Continuous Integration/Deployment (CI/CD) 22 Continuous Integration works by pushing small

    code chunks to your application’s code base hosted in a Git repository, and, to every push, run a pipeline of scripts to build, test, and validate the code changes before merging them into the main branch. Continuous Delivery and Deployment consist of a step further CI, deploying your application to production at every push to the default branch of the repository. https://about.gitlab.com/
  18. CI/CD ͕Ͱ͖Δͱɺͳʹ͕خ͍͠ͷʁ 23 build unit test E2E ςετ Lint ຊ൪

    deploy ؀ڥม਺ͷॻ͖׵͑ ϦϦʔε build QA ؀ڥ΁ͷ deploy ssh unit test etc etc .... ‣ ͢΂ͯख࡞ۀͰ࣮ߦ͢Δඞཁ͕͋Δ ‣ खॱΛϛεΔͱαʔϏε͕ࢭ·Δ ‣ खݩͰ build ΍ ςετ ͢Δ͕͔͔࣌ؒΔ ‣ ਫ਼ਆ͕͢ΓݮΔ.....
  19. 26 ίʔυϨϏϡʔͬͯԿ͢Δͷʁ https://github.com/google/eng-practices/blob/master/review/index.md A code review is a process where

    someone other than the author(s) of a piece of code examines that code. At Google we use code review to maintain the quality of our code and products.
  20. 27 ίʔυϨϏϡʔͬͯԿ͢Δͷʁ A code review is a process where someone

    other than the author(s) of a piece of code examines that code. At Google we use code review to maintain the quality of our code and products. ‣ ૈ୳͠΍൷൑Λ͢ΔͷͰ͸ͳ͘ɺ ίʔυ΍ϓϩμΫτͷΫΦϦςΟΛ୲อ͢Δ৔
  21. 28 ίʔυϨϏϡʔͬͯԿ͢Δͷʁ A code review is a process where someone

    other than the author(s) of a piece of code examines that code. At Google we use code review to maintain the quality of our code and products. ‣ ૈ୳͠΍൷൑Λ͢ΔͷͰ͸ͳ͘ɺ ‣ ໾৬΍೥࣍ʹґΒͳ͍ϑϥοτͳ৔ ίʔυ΍ϓϩμΫτͷΫΦϦςΟΛ୲อ͢Δ৔
  22. 29 ίʔυϨϏϡʔͬͯԿ͢Δͷʁ A code review is a process where someone

    other than the author(s) of a piece of code examines that code. At Google we use code review to maintain the quality of our code and products. ‣ ૈ୳͠΍൷൑Λ͢ΔͷͰ͸ͳ͘ɺ ‣ ໾৬΍೥࣍ʹґΒͳ͍ϑϥοτͳ৔ ‣ ΤϯδχΞͨͪͷίϛϡχέʔγϣϯͷ৔ ίʔυ΍ϓϩμΫτͷΫΦϦςΟΛ୲อ͢Δ৔
  23. 32 ίʔυϨϏϡʔͬͯԿ͢Δͷʁ ‣ Nits: ඞਢ͡Όͳ͍͚Ͳɺ·͋ࢦఠ ‣ Ask: ७ਮʹ࣭໰ͳΜͰ͕͢ ‣ IMO:

    ࣗ෼ͷҙݟͰ͸ ‣ FYI: ຊےͱؔ܎ͳ͍͚Ͳɺ৘ใڞ༗͢Δͱ ‣ Must: मਖ਼͸ඞਢͰ͢Α ͨ·ʹ࢖͏ prefix ͨͪ ϨϏϡʔίϝϯτͷԹ౓ײΛ఻͑Δͷʹศར
  24. 34 ·ͱΊ ‣ GitLab ‣ Code Review ‣ Git ‣

    ίʔυͷΫΦϦςΟΛ্͛ΒΕΔ ‣ υΩϡϝϯτΛ࢒ͤΔ ‣ ΤϯδχΞͷίϛϡχέʔγϣϯͷ৔Ͱ͋Δ ‣ Test ͳͲΛܧଓతʹ࣮ߦͰ͖Δ ‣ Deploy ΛࣗಈԽͰ͖Δ ‣ ։ൃΛߴ଎ԽͰ͖Δ ‣ ҆શʹ։ൃΛਐΊΒΕΔΑ͏ʹͳΔ