{"id":4550,"library":"gitlint","title":"Gitlint","description":"Gitlint is a highly configurable Python library and command-line tool designed to lint Git commit messages for style and compliance with established conventions (e.g., Conventional Commits). It helps enforce consistent commit history quality within development teams. The current version is 0.19.1, and it typically sees several releases per year, addressing bug fixes, new features, and Python version compatibility.","status":"active","version":"0.19.1","language":"en","source_language":"en","source_url":"https://github.com/jorisroovers/gitlint","tags":["git","lint","commit-messages","cli-tool","conventional-commits"],"install":[{"cmd":"pip install gitlint","lang":"bash","label":"Install gitlint"}],"dependencies":[],"imports":[{"note":"Main class for linting operations.","symbol":"GitLinter","correct":"from gitlint.lint import GitLinter"},{"note":"Represents the Git repository context or a specific commit message.","symbol":"GitContext","correct":"from gitlint.git import GitContext"},{"note":"Class for configuring gitlint's behavior programmatically.","symbol":"GitlintOptions","correct":"from gitlint.options import GitlintOptions"}],"quickstart":{"code":"import os\nfrom gitlint.lint import GitLinter\nfrom gitlint.git import GitContext\nfrom gitlint.options import GitlintOptions\n\n# Example commit message to lint\ncommit_message = \"\"\"feat: Add user authentication\n\nThis commit introduces user authentication functionality using OAuth2.0.\nIt includes new models for users and sessions, and updates the API routes.\n\"\"\"\n\n# Initialize options (optional, can be customized programmatically)\noptions = GitlintOptions()\n# Example: Disable a specific rule (e.g., body-max-line-length for a longer line)\n# options.disabled_rules = [\"body-max-line-length\"]\n\n# Create a GitContext from the commit message string\n# For real-world use in a git repository, you'd typically use:\n# GitContext.from_prev_commit() or GitContext.from_staged_commit()\ngitcontext = GitContext.from_commit_msg(commit_message)\n\n# Initialize the linter with the options\nlinter = GitLinter(options)\n\n# Lint the commit message\nviolations = linter.lint(gitcontext)\n\n# Print any detected violations\nif violations:\n    print(f\"Commit message has {len(violations)} violation(s):\")\n    for violation in violations:\n        print(f\"  - [{violation.rule_id}] {violation.message} (Line {violation.line_nr}, Col {violation.violating_line_idx})\")\nelse:\n    print(\"Commit message is clean and adheres to rules!\")\n","lang":"python","description":"This quickstart demonstrates how to use `gitlint` programmatically to lint a commit message string. It initializes a `GitlintOptions` object for configuration, creates a `GitContext` from a provided message, and then uses `GitLinter` to find any violations. For typical CLI usage, simply running `gitlint` in a Git repository will lint the latest commit."},"warnings":[{"fix":"Upgrade your Python environment to 3.7+.","message":"Python 3.6 is no longer supported. Projects using gitlint must upgrade to Python 3.7 or newer.","severity":"breaking","affected_versions":"0.19.0 and later"},{"fix":"Upgrade your Python environment to 3.6+ (preferably 3.7+).","message":"Python 2.7 and Python 3.5 are no longer supported. Ensure your environment is using Python 3.6 or newer (though 3.7+ is recommended for latest versions).","severity":"breaking","affected_versions":"0.15.0 and later"},{"fix":"No immediate user action is required unless you explicitly relied on the `sh` library integration. Be aware that future versions might remove `GITLINT_USE_SH_LIB`.","message":"The internal use of the `sh` library (for executing git commands) is being deprecated. Version 0.19.0 is the last release to officially support it via `GITLINT_USE_SH_LIB=1`. Future versions may remove this dependency entirely.","severity":"deprecated","affected_versions":"0.19.0 and later"},{"fix":"Review your custom rule regexes and update them to be compatible with `re.search` semantics if you receive warnings. More details are available in the gitlint documentation.","message":"Gitlint will be switching to `re.search` semantics instead of `re.match` for all rule regexes in a future release. This will change how regexes are matched (matching anywhere in the string vs. only at the beginning). Gitlint will print a warning if your current regexes might be affected.","severity":"gotcha","affected_versions":"0.18.0 (warning introduced), future release (breaking change)"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}