gicait / geoserver-rest

Python library for management of geospatial data in GeoServer.
https://geoserver-rest.readthedocs.io
MIT License
195 stars 77 forks source link

Clean and update git hooks #92

Closed Guts closed 1 year ago

Guts commented 1 year ago

Hi there,

First of all, thanks for your great package, it's really useful and well thought-out :).

I saw that you have a configuration for git hooks through pre-commit framework, but it seems to be a bit unmaintained or unused. So, in this PR:

See https://github.com/gicait/geoserver-rest/pull/92#issuecomment-1373375892 for more details.

Guts commented 1 year ago

Hi @iamtekson

In a nutshell, git hooks are scripts which are launched before/after a git operation, generally the git commit (so the name). It's not an additional tool but one of those included with git: have a look to the .git/hooks subfolder in one of your local repo.

pre-commit is a Python micro-framework to easily manage hooks and handle different languages to code them (Python, rust, node, ruby, etc.). On the nodejs side of the force, you would find husky.

Concretely, git hooks are a really good mechanism to help keeping the code base clean and homogeneous.

You can try it on this repository:

python -m pip install pre-commit
pre-commit install
pre-commit run -a

That should give something like this:

❯ pre-commit run -a
pyupgrade................................................................Failed
- hook id: pyupgrade
- exit code: 1
- files were modified by this hook

Rewriting geo/__version__.py
Rewriting geo/Geoserver.py
Rewriting setup.py

check yaml...............................................................Passed
debug statements (python)................................................Passed
fix end of files.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

Fixing setup.cfg
Fixing .pre-commit-config.yaml
Fixing docs/source/geo.rst

trim trailing whitespace.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook

Fixing .readthedocs.yaml
Fixing docs/source/change_log.rst

black....................................................................Failed
- hook id: black
- files were modified by this hook

reformatted docs/source/conf.py
reformatted setup.py
reformatted tests/test_geoserver.py
reformatted geo/Geoserver.py

All done! ✨ 🍰 ✨
4 files reformatted, 6 files left unchanged.

isort....................................................................Failed
- hook id: isort
- files were modified by this hook

Fixing /home/jmo/Git/External/geoserver-rest/tests/test_geoserver.py

flake8...................................................................Passed
pydocstyle...............................................................Passed
Check hooks apply to the repository......................................Passed
Check for useless excludes...............................................Passed

Next steps:

Zeitsperre commented 1 year ago

Hello @iamtekson and @Guts, I'm off work for another couple of days, but I can give this PR a look very soon!

Zeitsperre commented 1 year ago

@iamtekson This is good for merge IMO. In order to get the pre-commit CI hooks running, you simply need to give permissions to the repo at https://pre-commit.ci/. I use this service in many of my company's repositories, and it's fantastic!