spec-cleaner is a tool that cleans the given RPM spec file according to the style guide and returns the result.
It’s used for openSUSE, where it’s planned to be a replacement for osc service localrun format_spec_file and it is intended to provide the same or better features in order to be able to unify all the spec files in OBS.
The latest version is available on PyPI. It can be installed by running pip install spec_cleaner.
spec-cleaner is also provided as an RPM package for openSUSE Leap (15.0 and 15.1) and openSUSE Tumbleweed. When the new version of spec-cleaner is released then the version updates are performed for all maintained openSUSE codestreams. That means that there is always the latest version available in openSUSE:Leap.
Usage
Simply run spec-cleaner -i <specfile> to clean your specfile up.
Tests
Running the tests
spec-cleaner provides quite an extensive testsuite. You can run these tests locally either directly via pytest.
pytest
Just install python3-pytest, python3-pytest-cov, python3-pytest-isort and python3-pytest-sugar (for a nice progress bar) and then run all tests via:
pytest
Contributing
You are more than welcome to contribute to this project. If you are not sure about your changes, feel free to create an issue where you can discuss it before the implementation.
Contribution Guidelines
When changing anything in the code, make sure that you don’t forget to:
Add tests (mainly if you implement a new feature).
Add mypy support for the new code.
Run and pass all tests, flake8 and mypy checks.
See below for more details.
pre-commit
spec-cleaner project adopted pre-commit framework for managing and maintaining pre-commit hooks. After you clone the spec-cleaner repository, please install pre-commit framework (pip install pre-commit) and run pre-commit install to install pre-commit into your git hooks. Then pre-commit will run automatically on git commit and it will check your contribution with isort, black, flake8, flake8-docstrings and mypy.
Please note that similar checks run in CI when you submit a PR and it won’t pass code review without passing these checks.
mypy
Optional static type checker support was implemented for the most important parts of the code. If you want to run it on your own, just install python3-mypy and run
mypy spec_cleaner
Black
The code of spec-cleaner is formated with Black. We use --skip-string-normalization and --line-length 100 options. Black runs automatically in the pre-commit hook.
spec-cleaner
spec-cleaner is a tool that cleans the given RPM spec file according to the style guide and returns the result.
It’s used for openSUSE, where it’s planned to be a replacement for
osc service localrun format_spec_file
and it is intended to provide the same or better features in order to be able to unify all the spec files in OBS.Table of contents
Installation and usage
Installation
The latest version is available on PyPI. It can be installed by running
pip install spec_cleaner
.spec-cleaner is also provided as an RPM package for openSUSE Leap (15.0 and 15.1) and openSUSE Tumbleweed. When the new version of spec-cleaner is released then the version updates are performed for all maintained openSUSE codestreams. That means that there is always the latest version available in openSUSE:Leap.
Usage
Simply run
spec-cleaner -i <specfile>
to clean your specfile up.Tests
Running the tests
spec-cleaner provides quite an extensive testsuite. You can run these tests locally either directly via
pytest
.pytest
Just install
python3-pytest
,python3-pytest-cov
,python3-pytest-isort
andpython3-pytest-sugar
(for a nice progress bar) and then run all tests via:Contributing
You are more than welcome to contribute to this project. If you are not sure about your changes, feel free to create an issue where you can discuss it before the implementation.
Contribution Guidelines
When changing anything in the code, make sure that you don’t forget to:
pre-commit install
to installpre-commit
into your git hooks.mypy
support for the new code.flake8
andmypy
checks.See below for more details.
pre-commit
spec-cleaner project adopted
pre-commit
framework for managing and maintaining pre-commit hooks. After you clone the spec-cleaner repository, please install pre-commit framework (pip install pre-commit
) and runpre-commit install
to installpre-commit
into your git hooks. Thenpre-commit
will run automatically ongit commit
and it will check your contribution withisort
,black
,flake8
,flake8-docstrings
andmypy
.Please note that similar checks run in CI when you submit a PR and it won’t pass code review without passing these checks.
mypy
Optional static type checker support was implemented for the most important parts of the code. If you want to run it on your own, just install
python3-mypy
and runBlack
The code of spec-cleaner is formated with Black. We use
--skip-string-normalization
and--line-length 100
options. Black runs automatically in thepre-commit
hook.Adding new tests
When a new feature is added to spec-cleaner then a test for this piece of code must be added. See how to write tests for spec-cleaner.
Versioning and releasing
For the versions available, see the tags on this repository.
If you have proper permissions you can find handy how to do a new release.
Authors
SPDX Licenses
SPDX Exceptions
SUSE Additions