{"id":4023,"library":"gitlint-core","title":"Gitlint Core","description":"Gitlint-core is the core library for Gitlint, a Python-based linter that enforces style and consistency for Git commit messages. It is an actively maintained project with regular releases, providing robust checks and customizability for commit hooks and CI pipelines.","status":"active","version":"0.19.1","language":"en","source_language":"en","source_url":"https://github.com/jorisroovers/gitlint/tree/main/gitlint-core","tags":["git","linting","commit-messages","development-tools","cli","ci-cd"],"install":[{"cmd":"pip install gitlint-core","lang":"bash","label":"Install core library with looser dependencies"},{"cmd":"pip install gitlint","lang":"bash","label":"Install CLI tool (includes gitlint-core with pinned dependencies)"}],"dependencies":[],"imports":[{"symbol":"Gitlint","correct":"from gitlint.gitlint import Gitlint"},{"symbol":"GitlintConfig","correct":"from gitlint.options import GitlintConfig"},{"note":"For creating custom commit rules","symbol":"CommitRule","correct":"from gitlint.rules import CommitRule"}],"quickstart":{"code":"from gitlint.gitlint import Gitlint\nfrom gitlint.options import GitlintConfig\nfrom gitlint.display import Display\n\ncommit_message = (\n    \"feat: Add new feature\\n\\n\"  # Title\n    \"This commit introduces a brand new feature to the application.\\n\\n\"\n    \"It includes several improvements and bug fixes related to the new functionality.\"\n)\n\n# Initialize GitlintConfig (can be customized, or defaults are used)\nconfig = GitlintConfig()\n# You can set options programmatically, e.g., config.max_line_length = 100\n\n# Initialize Gitlint with a display (e.g., to print to stdout)\ndisplay = Display(config)\ngitlint = Gitlint(config, display)\n\n# Lint the commit message\nviolations = gitlint.lint(commit_msg_str=commit_message)\n\nif violations:\n    print(f\"Found {len(violations)} violations:\")\n    for violation in violations:\n        print(f\"- {violation.rule_id}: {violation.message} (line {violation.line_nr})\")\nelse:\n    print(\"Commit message is valid!\")\n","lang":"python","description":"Demonstrates how to programmatically lint a commit message string using `gitlint-core`. It initializes a `GitlintConfig` and `Gitlint` instance, then passes a commit message string to the `lint` method. Violations are returned as a list of `RuleViolation` objects."},"warnings":[{"fix":"Upgrade your Python interpreter to 3.7 or later. Check the official Python EOL dates for guidance.","message":"Python 3.6 is no longer supported since v0.19.0. Ensure your environment uses Python 3.7 or newer. Earlier versions (2.7 and 3.5) were dropped in v0.15.0.","severity":"breaking","affected_versions":">=0.19.0 (for 3.6), >=0.15.0 (for 2.7/3.5)"},{"fix":"Remove any reliance on the `GITLINT_USE_SH_LIB` environment variable. The library now uses a more robust internal git command execution.","message":"The `sh` library, used under-the-hood for git command execution, is no longer used by default since v0.18.0. It was completely removed in v0.19.0 (though v0.19.0 stated it was the last release to *support* re-enabling it). Relying on the `GITLINT_USE_SH_LIB=1` environment variable is no longer supported.","severity":"deprecated","affected_versions":">=0.19.0"},{"fix":"Review your custom rule regexes and update them if they were implicitly relying on `re.match`'s start-of-string anchoring. Explicitly use `^` for start-of-string matching if needed.","message":"Gitlint switched to `re.search` semantics instead of `re.match` for all rules. This means regexes that previously matched only at the start of a string might now match anywhere. Gitlint will print a warning if your rule regexes might need updating.","severity":"gotcha","affected_versions":">=0.18.0"},{"fix":"For CLI usage or pinned dependencies, `pip install gitlint`. For programmatic use with looser dependency control, `pip install gitlint-core`. If you previously installed `gitlint`, you might need to uninstall both to fully clean up (e.g., `pip uninstall gitlint gitlint-core`).","message":"Gitlint split into two packages (`gitlint` and `gitlint-core`) in v0.17.0. `gitlint-core` provides the core linting logic with looser dependency requirements, while `gitlint` is the CLI tool with pinned dependencies. Ensure you install the correct package for your use case.","severity":"gotcha","affected_versions":">=0.17.0"},{"fix":"Run `gitlint uninstall-hook` followed by `gitlint install-hook` in your repository to update the hook.","message":"The `commit-msg` git hook was rewritten in Python (around v0.15.0). Existing users of the hook need to reinstall it to benefit from fixes and new features.","severity":"gotcha","affected_versions":">=0.15.0"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}