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

Git Lint

Git Lint

A linter and coding buddy for enforcing consistent Git commits. Git Lint ensures you maintain a clean, easy to read, and debuggable project history. Not only does having a tool like this make your code a joy to work with but it also helps you and your team build a wealth of knowledge to fall back on when existing or new members of the team need to understand how the architecture of your system evolved over time.

Brooke Kuhlmann

December 28, 2021
Tweet

More Decks by Brooke Kuhlmann

Other Decks in Programming

Transcript

  1. Git Lint
    Presented by Brooke Kuhlmann

    View Slide

  2. A Non-Descriptive History
    27c7c6211aa1 ok, this works

    3a0843a69fd6 Do the right thing

    e00e9ebc358c Simplify

    74f9dfdac814 I give up

    7eca44a9c9bf hack

    b3eee2292be7 start

    View Slide

  3. A Non-Descriptive History
    27c7c6211aa1 ok, this works

    3a0843a69fd6 Do the right thing

    e00e9ebc358c Simplify

    74f9dfdac814 I give up

    7eca44a9c9bf hack

    b3eee2292be7 start






    View Slide

  4. A Non-Descriptive History
    27c7c6211aa1 ok, this works

    3a0843a69fd6 Do the right thing

    e00e9ebc358c Simplify

    74f9dfdac814 I give up

    7eca44a9c9bf hack

    b3eee2292be7 start






    🚫

    View Slide

  5. Anatomy of a Good Commit
    Added table of contents to README

    Received feedback that the README was hard to navigate. With
    a Table of Contents, people are able to quickly scan what the
    README provides and immediately jump to a topic of interest.

    View Slide

  6. Anatomy of a Good Commit
    Added table of contents to README

    Received feedback that the README was hard to navigate. With
    a Table of Contents, people are able to quickly scan what the
    README provides and immediately jump to a topic of interest.
    Subject

    View Slide

  7. Anatomy of a Good Commit
    Added table of contents to README

    Received feedback that the README was hard to navigate. With
    a Table of Contents, people are able to quickly scan what the
    README provides and immediately jump to a topic of interest.
    Subject
    (what)

    View Slide

  8. Anatomy of a Good Commit
    Added table of contents to README

    Received feedback that the README was hard to navigate. With
    a Table of Contents, people are able to quickly scan what the
    README provides and immediately jump to a topic of interest.
    Subject
    Body
    (what)

    View Slide

  9. Anatomy of a Good Commit
    Added table of contents to README

    Received feedback that the README was hard to navigate. With
    a Table of Contents, people are able to quickly scan what the
    README provides and immediately jump to a topic of interest.
    Subject
    Body
    (what)
    (why)

    View Slide

  10. Anatomy of a Good Commit
    Added table of contents to README

    Received feedback that the README was hard to navigate. With
    a Table of Contents, people are able to quickly scan what the
    README provides and immediately jump to a topic of interest.

    View Slide

  11. Anatomy of a Good Commit
    Added table of contents to README

    Received feedback that the README was hard to navigate. With
    a Table of Contents, people are able to quickly scan what the
    README provides and immediately jump to a topic of interest.
    Fixed
    Added
    Updated
    Removed
    Refactored

    View Slide

  12. Anatomy of a Good Commit
    Added table of contents to README

    Received feedback that the README was hard to navigate. With
    a Table of Contents, people are able to quickly scan what the
    README provides and immediately jump to a topic of interest.

    View Slide

  13. Anatomy of a Good Commit
    Added table of contents to README

    Received feedback that the README was hard to navigate. With
    a Table of Contents, people are able to quickly scan what the
    README provides and immediately jump to a topic of interest.
    72 characters

    View Slide

  14. Anatomy of a Good Commit
    Added table of contents to README

    Received feedback that the README was hard to navigate. With
    a Table of Contents, people are able to quickly scan what the
    README provides and immediately jump to a topic of interest.
    Space

    View Slide

  15. Anatomy of a Good Commit
    Added table of contents to README

    Received feedback that the README was hard to navigate. With
    a Table of Contents, people are able to quickly scan what the
    README provides and immediately jump to a topic of interest.
    Capitalization

    View Slide

  16. Anatomy of a Good Commit
    Added table of contents to README

    Received feedback that the README was hard to navigate. With
    a Table of Contents, people are able to quickly scan what the
    README provides and immediately jump to a topic of interest.
    72 characters

    View Slide

  17. Anatomy of a Good Commit
    Added table of contents to README

    Received feedback that the README was hard to navigate. With
    a Table of Contents, people are able to quickly scan what the
    README provides and immediately jump to a topic of interest.
    actually
    basically
    furthermore
    however
    obviously
    of course
    ...etc...
    🚫

    View Slide

  18. Readable Git History
    📖

    View Slide

  19. Readable Git History
    Added gem skeleton
    📖
    📄
    Added initial architecture and implementation
    📄
    Added command line interface
    📄
    Refactored private API
    📄
    Updated README table of contents
    📄

    View Slide

  20. Team E
    ffi
    ciency
    🕵 🕵
    🕵

    View Slide

  21. Team E
    ffi
    ciency
    🕵 🕵
    🕵
    1 hour
    1 hour
    1 hour

    View Slide

  22. Team E
    ffi
    ciency
    🕵 🕵
    🕵
    1 hour
    1 hour
    1 hour
    3 hours
    😢

    View Slide

  23. Git Lint
    https://www.alchemists.io/projects/git-lint

    View Slide

  24. Your automated coding buddy!
    Git Lint
    https://www.alchemists.io/projects/git-lint

    View Slide

  25. Getting Started
    gem install git-lint
    Installation:
    https://www.alchemists.io/projects/git-lint

    View Slide

  26. Getting Started
    gem install git-lint
    Installation:
    git switch
    Usage:
    https://www.alchemists.io/projects/git-lint

    View Slide

  27. Getting Started
    gem install git-lint
    Installation:
    git switch
    Usage:
    git-lint --analyze
    https://www.alchemists.io/projects/git-lint

    View Slide

  28. Git Hook Support
    .git/hooks/commit-msg
    📄
    https://www.alchemists.io/projects/git-lint

    View Slide

  29. Git Hook Support
    .git/hooks/commit-msg
    📄
    #! /usr/bin/env bash
    https://www.alchemists.io/projects/git-lint

    View Slide

  30. Git Hook Support
    .git/hooks/commit-msg
    📄
    set -o nounset

    set -o errexit

    set -o pipefail

    IFS=$'\n\t'
    #! /usr/bin/env bash
    https://www.alchemists.io/projects/git-lint

    View Slide

  31. Git Hook Support
    .git/hooks/commit-msg
    📄
    set -o nounset

    set -o errexit

    set -o pipefail

    IFS=$'\n\t'
    if ! command -v git-lint > /dev/null; then

    printf "%s\n" "[git]: Git Lint not found. To install, run: gem install git-lint."

    exit 1

    f
    #! /usr/bin/env bash
    https://www.alchemists.io/projects/git-lint

    View Slide

  32. Git Hook Support
    .git/hooks/commit-msg
    📄
    set -o nounset

    set -o errexit

    set -o pipefail

    IFS=$'\n\t'
    if ! command -v git-lint > /dev/null; then

    printf "%s\n" "[git]: Git Lint not found. To install, run: gem install git-lint."

    exit 1

    f
    git-lint --hook "${BASH_ARGV[0]}"

    #! /usr/bin/env bash
    https://www.alchemists.io/projects/git-lint

    View Slide

  33. Git Hook Support
    .git/hooks/commit-msg
    📄
    set -o nounset

    set -o errexit

    set -o pipefail

    IFS=$'\n\t'
    if ! command -v git-lint > /dev/null; then

    printf "%s\n" "[git]: Git Lint not found. To install, run: gem install git-lint."

    exit 1

    f
    git-lint --hook "${BASH_ARGV[0]}"

    #! /usr/bin/env bash
    https://www.alchemists.io/projects/git-lint

    View Slide

  34. Git Hook Support
    .git/hooks/commit-msg
    📄
    set -o nounset

    set -o errexit

    set -o pipefail

    IFS=$'\n\t'
    if ! command -v git-lint > /dev/null; then

    printf "%s\n" "[git]: Git Lint not found. To install, run: gem install git-lint."

    exit 1

    f
    git-lint --hook "${BASH_ARGV[0]}"

    #! /usr/bin/env bash
    https://www.alchemists.io/projects/git-lint

    View Slide

  35. Git Commit Work
    fl
    ow
    git commit
    https://www.alchemists.io/projects/git-lint

    View Slide

  36. Git Commit Work
    fl
    ow
    git commit
    Did some stu
    ff


    fi
    nished discussed work
    📄
    https://www.alchemists.io/projects/git-lint

    View Slide

  37. Git Commit Work
    fl
    ow
    git commit
    Did some stu
    ff


    fi
    nished discussed work
    📄 Subject
    https://www.alchemists.io/projects/git-lint

    View Slide

  38. Git Commit Work
    fl
    ow
    git commit
    Did some stu
    ff


    fi
    nished discussed work
    📄 Subject
    Body
    https://www.alchemists.io/projects/git-lint

    View Slide

  39. Git Commit Work
    fl
    ow
    git commit
    Did some stu
    ff


    fi
    nished discussed work
    📄
    🚫
    https://www.alchemists.io/projects/git-lint

    View Slide

  40. Git Commit Work
    fl
    ow
    git commit
    Did some stu
    ff


    fi
    nished discussed work
    📄
    8790d748e650 (Brooke Kuhlmann, 0 seconds ago): Did some stu
    ff


    Commit Body Leading Line Error. Use blank line between subject and body.

    Commit Body Paragraph Capitalization Error. Capitalize
    fi
    rst word.

    Line 2: "
    fi
    nished discussed work"

    Commit Subject Pre
    fi
    x Error. Use: /Fixed/, /Added/, /Updated/, /Removed/, /Refactored/.

    1 commit inspected. 3 issues detected (0 warnings, 3 errors).
    🚫
    https://www.alchemists.io/projects/git-lint

    View Slide

  41. Git Commit Work
    fl
    ow
    git commit
    Did some stu
    ff


    fi
    nished discussed work
    📄
    8790d748e650 (Brooke Kuhlmann, 0 seconds ago): Did some stu
    ff


    Commit Body Leading Line Error. Use blank line between subject and body.

    Commit Body Paragraph Capitalization Error. Capitalize
    fi
    rst word.

    Line 2: "
    fi
    nished discussed work"

    Commit Subject Pre
    fi
    x Error. Use: /Fixed/, /Added/, /Updated/, /Removed/, /Refactored/.

    1 commit inspected. 3 issues detected (0 warnings, 3 errors).
    🚫
    https://www.alchemists.io/projects/git-lint

    View Slide

  42. Git Commit Work
    fl
    ow
    git commit
    Did some stu
    ff


    fi
    nished discussed work
    📄
    8790d748e650 (Brooke Kuhlmann, 0 seconds ago): Did some stu
    ff


    Commit Body Leading Line Error. Use blank line between subject and body.

    Commit Body Paragraph Capitalization Error. Capitalize
    fi
    rst word.

    Line 2: "
    fi
    nished discussed work"

    Commit Subject Pre
    fi
    x Error. Use: /Fixed/, /Added/, /Updated/, /Removed/, /Refactored/.

    1 commit inspected. 3 issues detected (0 warnings, 3 errors).
    🚫
    https://www.alchemists.io/projects/git-lint

    View Slide

  43. Git Commit Work
    fl
    ow
    git commit
    Did some stu
    ff


    fi
    nished discussed work
    📄
    8790d748e650 (Brooke Kuhlmann, 0 seconds ago): Did some stu
    ff


    Commit Body Leading Line Error. Use blank line between subject and body.

    Commit Body Paragraph Capitalization Error. Capitalize
    fi
    rst word.

    Line 2: "
    fi
    nished discussed work"

    Commit Subject Pre
    fi
    x Error. Use: /Fixed/, /Added/, /Updated/, /Removed/, /Refactored/.

    1 commit inspected. 3 issues detected (0 warnings, 3 errors).
    🚫
    https://www.alchemists.io/projects/git-lint

    View Slide

  44. Git Commit Work
    fl
    ow
    git commit
    Did some stu
    ff


    fi
    nished discussed work
    📄
    8790d748e650 (Brooke Kuhlmann, 0 seconds ago): Did some stu
    ff


    Commit Body Leading Line Error. Use blank line between subject and body.

    Commit Body Paragraph Capitalization Error. Capitalize
    fi
    rst word.

    Line 2: "
    fi
    nished discussed work"

    Commit Subject Pre
    fi
    x Error. Use: /Fixed/, /Added/, /Updated/, /Removed/, /Refactored/.

    1 commit inspected. 3 issues detected (0 warnings, 3 errors).
    🚫
    https://www.alchemists.io/projects/git-lint

    View Slide

  45. Git Commit Work
    fl
    ow
    git commit
    Did some stu
    ff


    fi
    nished discussed work
    📄
    8790d748e650 (Brooke Kuhlmann, 0 seconds ago): Did some stu
    ff


    Commit Body Leading Line Error. Use blank line between subject and body.

    Commit Body Paragraph Capitalization Error. Capitalize
    fi
    rst word.

    Line 2: "
    fi
    nished discussed work"

    Commit Subject Pre
    fi
    x Error. Use: /Fixed/, /Added/, /Updated/, /Removed/, /Refactored/.

    1 commit inspected. 3 issues detected (0 warnings, 3 errors).
    🚫
    https://www.alchemists.io/projects/git-lint

    View Slide

  46. Customizable Con
    fi
    guration
    Analyzers
    • Commit Author
    • Commit Body
    • Commit Subject
    • Commit Trailer
    https://www.alchemists.io/projects/git-lint

    View Slide

  47. Customizable Con
    fi
    guration
    Analyzers
    • Commit Author
    • Commit Body
    • Commit Subject
    • Commit Trailer
    Enablement


    ✅ On


    🚫 Off
    https://www.alchemists.io/projects/git-lint

    View Slide

  48. Customizable Con
    fi
    guration
    Analyzers
    • Commit Author
    • Commit Body
    • Commit Subject
    • Commit Trailer
    Severity


    ⚠ Warning


    ❌ Error
    Enablement


    ✅ On


    🚫 Off
    https://www.alchemists.io/projects/git-lint

    View Slide

  49. Customizable Con
    fi
    guration
    Analyzers
    • Commit Author
    • Commit Body
    • Commit Subject
    • Commit Trailer
    Severity


    ⚠ Warning


    ❌ Error
    Enablement


    ✅ On


    🚫 Off
    Regular
    Expressions



    https://www.alchemists.io/projects/git-lint

    View Slide

  50. Continuous Integration Support
    https://www.alchemists.io/projects/git-lint

    View Slide

  51. Continuous Integration Support
    Circle CI
    https://www.alchemists.io/projects/git-lint

    View Slide

  52. Continuous Integration Support
    Circle CI Netlify
    https://www.alchemists.io/projects/git-lint

    View Slide

  53. Continuous Integration Support
    Circle CI Netlify
    https://www.alchemists.io/projects/git-lint
    GitHub Actions

    View Slide

  54. https://www.alchemists.io/projects/git-lint
    Git Lint

    View Slide

  55. Thanks
    🙇
    https://www.alchemists.io

    View Slide