Skip to content

Commit

Permalink
Split into gitlint and gitlint-core to allow unpinning requirements
Browse files Browse the repository at this point in the history
gitlint’s pinned requirements make it difficult to use with other
libraries and tools that have newer requirements, and may hold back
important security updates.  However, the maintainer prefers to expose
pinned requirements by default.

Reconcile this by splitting gitlint into two packages:

* gitlint-core has unpinned requirements by default, but pinned
  requirements with the [trusted-deps] extra.
* gitlint becomes an empty package that requires
  gitlint-core[trusted-deps].

Fixes jorisroovers#162.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
  • Loading branch information
andersk committed Nov 13, 2021
1 parent a8b178c commit 8e7f44d
Show file tree
Hide file tree
Showing 122 changed files with 143 additions and 79 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ fail_under = 97

[run]
branch = true
omit=*dist-packages*,*site-packages*,gitlint/tests/*,.venv/*,*virtualenv*
omit=*dist-packages*,*site-packages*,gitlint-core/gitlint/tests/*,.venv/*,*virtualenv*
10 changes: 5 additions & 5 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ jobs:
run: gitlint --version

- name: Tests (sanity)
run: tools\windows\run_tests.bat "gitlint\tests\cli\test_cli.py::CLITests::test_lint"
run: tools\windows\run_tests.bat "gitlint-core\gitlint\tests\cli\test_cli.py::CLITests::test_lint"

- name: Tests (ignore cli\*)
run: pytest --ignore gitlint\tests\cli -rw -s gitlint
run: pytest --ignore gitlint-core\gitlint\tests\cli -rw -s gitlint gitlint-core

- name: Tests (test_cli.py only - continue-on-error:true)
run: tools\windows\run_tests.bat "gitlint\tests\cli\test_cli.py"
run: tools\windows\run_tests.bat "gitlint-core\gitlint\tests\cli\test_cli.py"
continue-on-error: true # Known to fail at this point

- name: Tests (all - continue-on-error:true)
Expand All @@ -127,10 +127,10 @@ jobs:
continue-on-error: true # Known to fail at this point

- name: PEP8
run: flake8 gitlint qa examples
run: flake8 gitlint gitlint-core qa examples

- name: PyLint
run: pylint gitlint qa --rcfile=".pylintrc" -r n
run: pylint gitlint-core\gitlint qa --rcfile=".pylintrc" -r n

# Re-add git version control so we can run gitlint on itself.
- name: Re-add git version control to code
Expand Down
22 changes: 0 additions & 22 deletions LICENSE

This file was deleted.

1 change: 1 addition & 0 deletions LICENSE
23 changes: 0 additions & 23 deletions README.md

This file was deleted.

1 change: 1 addition & 0 deletions README.md
2 changes: 1 addition & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ ignore-merge-commits=false
# This is useful for when developers often erroneously edit certain files or git submodules.
# By specifying this rule, developers can only change the file when they explicitly
# reference it in the commit message.
files=gitlint/rules.py,README.md
files=gitlint-core/gitlint/rules.py,README.md

[body-match-regex]
# python-style regex that the commit-msg body must match.
Expand Down
6 changes: 3 additions & 3 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ that's open to a lot of change and input.

When contributing code, please consider all the parts that are typically required:

- [Unit tests](https://github.com/jorisroovers/gitlint/tree/main/gitlint/tests) (automatically
- [Unit tests](https://github.com/jorisroovers/gitlint/tree/main/gitlint-core/gitlint/tests) (automatically
[enforced by CI](https://github.com/jorisroovers/gitlint/actions)). Please consider writing
new ones for your functionality, not only updating existing ones to make the build pass.
- [Integration tests](https://github.com/jorisroovers/gitlint/tree/main/qa) (also automatically
Expand Down Expand Up @@ -118,8 +118,8 @@ Then, we suggest taking the following approach to add a Contrib rule:

1. **Write your rule as a [user-defined rule](../user_defined_rules)**. In terms of code, Contrib rules are identical to
user-defined rules, they just happen to have their code sit within the gitlint codebase itself.
2. **Add your user-defined rule to gitlint**. You should put your file(s) in the [gitlint/contrib/rules](https://github.com/jorisroovers/gitlint/tree/main/gitlint/contrib/rules) directory.
3. **Write unit tests**. The gitlint codebase contains [Contrib rule test files you can copy and modify](https://github.com/jorisroovers/gitlint/tree/main/gitlint/tests/contrib/rules).
2. **Add your user-defined rule to gitlint**. You should put your file(s) in the [gitlint/contrib/rules](https://github.com/jorisroovers/gitlint/tree/main/gitlint-core/gitlint/contrib/rules) directory.
3. **Write unit tests**. The gitlint codebase contains [Contrib rule test files you can copy and modify](https://github.com/jorisroovers/gitlint/tree/main/gitlint-core/gitlint/tests/contrib/rules).
4. **Write documentation**. In particular, you should update the [gitlint/docs/contrib_rules.md](https://github.com/jorisroovers/gitlint/blob/main/docs/contrib_rules.md) file with details on your Contrib rule.
5. **Create a Pull Request**: code review typically requires a bit of back and forth. Thanks for your contribution!

Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ useful throughout the years.
### Installation
```sh
# Pip is recommended to install the latest version
pip install gitlint
pip install gitlint[pinned]

# Community maintained packages:
brew install gitlint # Homebrew (macOS)
Expand Down
4 changes: 2 additions & 2 deletions docs/user_defined_rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ class ReleaseConfigurationRule(ConfigurationRule):
```

For all available properties and methods on the `config` object, have a look at the
[LintConfig class](https://github.com/jorisroovers/gitlint/blob/main/gitlint/config.py). Please do not use any
[LintConfig class](https://github.com/jorisroovers/gitlint/blob/main/gitlint-core/gitlint/config.py). Please do not use any
properties or methods starting with an underscore, as those are subject to change.


Expand All @@ -385,7 +385,7 @@ As long as you stick with simple rules that are similar to the sample user-defin
should be able to discover and execute them. While clearly you can run any python code you want in your rules,
you might run into some issues if you don't follow the conventions that gitlint requires.

While the [rule finding source-code](https://github.com/jorisroovers/gitlint/blob/main/gitlint/rule_finder.py) is the
While the [rule finding source-code](https://github.com/jorisroovers/gitlint/blob/main/gitlint-core/gitlint/rule_finder.py) is the
ultimate source of truth, here are some of the requirements that gitlint enforces.

### Rule class requirements
Expand Down
2 changes: 1 addition & 1 deletion examples/gitlint
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ ignore-merge-commits=false
# This is useful for when developers often erroneously edit certain files or git submodules.
# By specifying this rule, developers can only change the file when they explicitly reference
# it in the commit message.
files=gitlint/rules.py,README.md
files=gitlint-core/gitlint/rules.py,README.md
22 changes: 22 additions & 0 deletions gitlint-core/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2015 Joris Roovers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

File renamed without changes.
23 changes: 23 additions & 0 deletions gitlint-core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# gitlint: [jorisroovers.github.io/gitlint](http://jorisroovers.github.io/gitlint/) #

[![Tests](https://github.com/jorisroovers/gitlint/workflows/Tests%20and%20Checks/badge.svg)](https://github.com/jorisroovers/gitlint/actions?query=workflow%3A%22Tests+and+Checks%22)
[![PyPi Package](https://img.shields.io/pypi/v/gitlint.png)](https://pypi.python.org/pypi/gitlint)
![Supported Python Versions](https://img.shields.io/pypi/pyversions/gitlint.svg)

Git commit message linter written in python (for Linux and Mac, experimental on Windows), checks your commit messages for style.

**See [jorisroovers.github.io/gitlint](http://jorisroovers.github.io/gitlint/) for full documentation.**

<a href="http://jorisroovers.github.io/gitlint/" target="_blank">
<img src="docs/images/readme-gitlint.png" />
</a>

## Contributing ##
All contributions are welcome and very much appreciated!

**I'm [looking for contributors](https://github.com/jorisroovers/gitlint/issues/134) that are interested in taking a more active co-maintainer role as it's becoming increasingly difficult for me to find time to maintain gitlint. Please leave a comment in [#134](https://github.com/jorisroovers/gitlint/issues/134) if you're interested!**

See [jorisroovers.github.io/gitlint/contributing](http://jorisroovers.github.io/gitlint/contributing) for details on
how to get started - it's easy!

We maintain a [loose roadmap on our wiki](https://github.com/jorisroovers/gitlint/wiki/Roadmap).
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
# This is useful for when developers often erroneously edit certain files or git submodules.
# By specifying this rule, developers can only change the file when they explicitly reference
# it in the commit message.
# files=gitlint/rules.py,README.md
# files=gitlint-core/gitlint/rules.py,README.md

# [body-match-regex]
# python-style regex that the commit-msg body must match.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 8 additions & 5 deletions setup.py → gitlint-core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def get_version(package):


setup(
name="gitlint",
name="gitlint-core",
version=get_version("gitlint"),
description=description,
long_description=long_description,
Expand All @@ -60,12 +60,15 @@ def get_version(package):
],
python_requires=">=3.6",
install_requires=[
'Click==8.0.3',
'arrow==1.2.1',
'Click>=8',
'arrow>=1',
'sh>=1 ; sys_platform != "win32"',
],
extras_require={
':sys_platform != "win32"': [
'sh==1.14.2',
'trusted-deps': [
'Click==8.0.3',
'arrow==1.2.1',
'sh==1.14.2 ; sys_platform != "win32"',
],
},
keywords='gitlint git lint',
Expand Down
62 changes: 62 additions & 0 deletions gitlint/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env python
from __future__ import print_function
from setuptools import setup

description = "Git commit message linter written in python, checks your commit messages for style."
long_description = """
Great for use as a commit-msg git hook or as part of your gating script in a CI pipeline (e.g. jenkins, github actions).
Many of the gitlint validations are based on `well-known`_ community_ `standards`_, others are based on checks that
we've found useful throughout the years. Gitlint has sane defaults, but you can also easily customize it to your
own liking.
Demo and full documentation on `jorisroovers.github.io/gitlint`_.
To see what's new in the latest release, visit the CHANGELOG_.
Source code on `github.com/jorisroovers/gitlint`_.
.. _well-known: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
.. _community: http://addamhardy.com/blog/2013/06/05/good-commit-messages-and-enforcing-them-with-git-hooks/
.. _standards: http://chris.beams.io/posts/git-commit/
.. _jorisroovers.github.io/gitlint: https://jorisroovers.github.io/gitlint
.. _CHANGELOG: https://github.com/jorisroovers/gitlint/blob/main/CHANGELOG.md
.. _github.com/jorisroovers/gitlint: https://github.com/jorisroovers/gitlint
"""


version = "0.17.0dev"

setup(
name="gitlint",
version=version,
description=description,
long_description=long_description,
classifiers=[
"Development Status :: 5 - Production/Stable",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Environment :: Console",
"Intended Audience :: Developers",
"Topic :: Software Development :: Quality Assurance",
"Topic :: Software Development :: Testing",
"License :: OSI Approved :: MIT License"
],
python_requires=">=3.6",
install_requires=[
'gitlint-core[trusted-deps]==' + version,
],
keywords='gitlint git lint',
author='Joris Roovers',
url='https://jorisroovers.github.io/gitlint',
project_urls={
'Documentation': 'https://jorisroovers.github.io/gitlint',
'Source': 'https://github.com/jorisroovers/gitlint',
},
license='MIT',
)
5 changes: 2 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
setuptools
wheel==0.37.0
Click==8.0.3
sh==1.14.2; sys_platform != 'win32' # sh is not supported on windows
arrow==1.2.1
-e ./gitlint
-e ./gitlint-core[trusted-deps]
18 changes: 8 additions & 10 deletions run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ handle_test_result(){

run_pep8_check(){
# FLAKE 8
target=${testargs:-"gitlint qa examples"}
target=${testargs:-"gitlint gitlint-core qa examples"}
echo -ne "Running flake8..."
RESULT=$(flake8 $target)
local exit_code=$?
Expand All @@ -88,7 +88,7 @@ run_unit_tests(){
clean
# py.test -s => print standard output (i.e. show print statement output)
# -rw => print warnings
target=${testargs:-"gitlint"}
target=${testargs:-"gitlint-core"}
coverage run -m pytest -rw -s $target
TEST_RESULT=$?
if [ $include_coverage -eq 1 ]; then
Expand Down Expand Up @@ -129,7 +129,7 @@ run_git_check(){

run_lint_check(){
echo -ne "Running pylint...${RED}"
target=${testargs:-"gitlint qa"}
target=${testargs:-"gitlint-core/gitlint qa"}
RESULT=$(pylint $target --rcfile=".pylintrc" -r n)
local exit_code=$?
handle_test_result $exit_code "$RESULT"
Expand All @@ -149,14 +149,14 @@ run_build_test(){

# Update the version to include a timestamp
echo -n "Writing new version to file..."
version_file="$temp_dir/gitlint/__init__.py"
version_file="$temp_dir/gitlint-core/gitlint/__init__.py"
version_str="$(cat $version_file)"
version_str="${version_str:0:${#version_str}-1}-$datestr\""
echo "$version_str" > $version_file
echo -e "${GREEN}DONE${NO_COLOR}"
# Attempt to build the package
echo "Building package ..."
pushd "$temp_dir"
pushd "$temp_dir/gitlint-core"
# Copy stdout file descriptor so we can both print output to stdout as well as capture it in a variable
# https://stackoverflow.com/questions/12451278/bash-capture-stdout-to-a-variable-but-still-display-it-in-the-console
exec 5>&1
Expand All @@ -183,7 +183,7 @@ run_stats(){
echo "*** Docs ***"
echo " Markdown: $(cat docs/*.md | wc -l | tr -d " ") lines"
echo "*** Tests ***"
nr_unit_tests=$(py.test gitlint/ --collect-only | grep TestCaseFunction | wc -l)
nr_unit_tests=$(py.test gitlint/ gitlint-core/ --collect-only | grep TestCaseFunction | wc -l)
nr_integration_tests=$(py.test qa/ --collect-only | grep TestCaseFunction | wc -l)
echo " Unit Tests: ${nr_unit_tests//[[:space:]]/}"
echo " Integration Tests: ${nr_integration_tests//[[:space:]]/}"
Expand Down Expand Up @@ -212,10 +212,8 @@ run_stats(){

clean(){
echo -n "Cleaning the *.pyc, site/, build/, dist/ and all __pycache__ directories..."
find gitlint -type d -name "__pycache__" -exec rm -rf {} \; 2> /dev/null
find qa -type d -name "__pycache__" -exec rm -rf {} \; 2> /dev/null
find gitlint -iname *.pyc -exec rm -rf {} \; 2> /dev/null
find qa -iname *.pyc -exec rm -rf {} \; 2> /dev/null
find gitlint gitlint-core qa -type d -name "__pycache__" -exec rm -rf {} \; 2> /dev/null
find gitlint gitlint-core qa -iname "*.pyc" -exec rm -rf {} \; 2> /dev/null
rm -rf "site" "dist" "build"
echo -e "${GREEN}DONE${NO_COLOR}"
}
Expand Down
2 changes: 1 addition & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ radon==5.1.0
flake8-polyfill==1.0.2 # Required when installing both flake8 and radon>=4.3.1
pytest==6.2.5;
pylint==2.11.1;
-e .
-r requirements.txt

0 comments on commit 8e7f44d

Please sign in to comment.