Skip to content

Commit b695ee8

Browse files
authored
Merge pull request #5 from scanoss/fix/mdaloia/SP-3538-Pre-commit-hook-failing-when-committing-a-no-match-file
feat: pre-commit refactor, allow cli arguments
2 parents b3c3025 + a5faf17 commit b695ee8

File tree

12 files changed

+342
-173
lines changed

12 files changed

+342
-173
lines changed

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
workflow_dispatch:
66
push:
77
tags:
8-
- 'v*.*.*'
8+
- "v*.*.*"
99

1010
jobs:
1111
deploy:
@@ -16,7 +16,7 @@ jobs:
1616
- name: Set up Python
1717
uses: actions/setup-python@v5
1818
with:
19-
python-version: '3.9.x'
19+
python-version: "3.9.x"
2020

2121
- name: Install dependencies
2222
run: |
@@ -29,7 +29,7 @@ jobs:
2929
- name: Run Local Tests
3030
run: |
3131
which scanoss-check-undeclared-code
32-
scanoss-check-undeclared-code --version
32+
scanoss-check-undeclared-code --help
3333
scanoss-check-undeclared-code
3434
3535
- name: Dev Uninstall

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ jobs:
3535
- name: Run Local Tests
3636
run: |
3737
which scanoss-check-undeclared-code
38-
scanoss-check-undeclared-code --version
38+
scanoss-check-undeclared-code --help
3939
scanoss-check-undeclared-code

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ docs/build
3030
!.devcontainer/*.example.json
3131

3232
.scanoss
33+
.env

.pre-commit-hooks.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
language: python
66
stages: [pre-commit, pre-push, manual]
77
pass_filenames: false
8-
8+
require_serial: true
9+
verbose: true

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
### Added
1010
- Upcoming changes...
1111

12+
## [0.3.0] - 2025-10-24
13+
### Added
14+
- CLI arguments support: `--api-url`, `--api-key`, `--proxy`, `--pac`, `--ca-cert`, `--output`, `--debug`, `--ignore-cert-errors`, `--rest`
15+
- Support for custom output path for scan results
16+
- Improved logging with configurable debug mode
17+
- Sensitive information sanitization in command logging
18+
- Click library for enhanced CLI experience
19+
20+
### Changed
21+
- Refactored from argparse to click for better CLI argument handling
22+
- Consolidated utility functions into main module (removed utils.py)
23+
- Enhanced error handling and user feedback
24+
- Updated GitHub Actions workflows to use `--help` instead of `--version`
25+
26+
### Fixed
27+
- Pre-commit hook behavior when committing files with no matches
28+
- Release workflow improvements
29+
1230
## [0.2.0] - 2025-03-21
1331
### Added
1432
- Added version details
@@ -23,3 +41,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2341

2442
[0.1.0]: https://github.com/scanoss/pre-commit-hooks/compare/v0.0.1...v0.1.0
2543
[0.2.0]: https://github.com/scanoss/pre-commit-hooks/compare/v0.1.0...v0.2.0
44+
[0.3.0]: https://github.com/scanoss/pre-commit-hooks/compare/v0.2.0...v0.3.0

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- [License](#license)
99
- [Bugs/Features](#bugsfeatures)
1010
- [Contributing](#contributing)
11+
- [Release and Deployment](#release-and-deployment)
1112
- [Changelog](#changelog)
1213

1314
## Available Hooks
@@ -128,5 +129,53 @@ To request features or alert about bugs, please do so [here](https://github.com/
128129
## Contributing
129130
We welcome contributions to this project! Please clone the repository and submit a pull request with your changes. Ensure that your code passes all pre-commit checks before submitting.
130131
132+
## Release and Deployment
133+
134+
This project uses automated GitHub Actions workflows to manage releases. The package is distributed through GitHub Releases and the pre-commit framework (not PyPI).
135+
136+
### Release Process
137+
138+
1. **Update Version**: Modify `__version__` in `src/hooks/__init__.py` following semantic versioning (MAJOR.MINOR.PATCH)
139+
140+
2. **Create Tag**: Run the `tag-version.yml` workflow manually:
141+
- Go to Actions → "Tag Version" → "Run workflow"
142+
- The workflow compares the Python package version with the latest Git tag
143+
- If versions differ, it creates and pushes a new tag (e.g., `v0.3.0`)
144+
145+
3. **Automated Release**: The `release.yml` workflow triggers automatically when a tag is pushed:
146+
- Builds the package in a clean environment
147+
- Runs verification tests (binary check, `--help`, basic execution)
148+
- Creates a draft GitHub Release
149+
150+
4. **Publish Release**: A maintainer reviews and publishes the draft release manually
151+
152+
### Version Management
153+
154+
- **Current Version Source**: `src/hooks/__init__.py`
155+
- **Versioning Strategy**: Semantic Versioning (SemVer)
156+
- **Tag Format**: `v0.3.0` (with 'v' prefix)
157+
- **Major Version Tags**: The repository maintains `v0` and `v1` tags that point to the latest patch release, allowing users to pin to a major version and automatically receive updates
158+
159+
### Distribution
160+
161+
Users reference this package in their `.pre-commit-config.yaml`:
162+
163+
```yaml
164+
repos:
165+
- repo: https://github.com/scanoss/pre-commit-hooks
166+
rev: v0 # Pin to major version, or use v0.3.0 for specific version
167+
hooks:
168+
- id: scanoss-check-undeclared-code
169+
```
170+
171+
The pre-commit framework installs directly from the Git repository—no PyPI publishing required.
172+
173+
### Key Workflows
174+
175+
- `.github/workflows/tag-version.yml` - Manual workflow for version tagging
176+
- `.github/workflows/release.yml` - Automated draft release creation
177+
- `.github/workflows/test.yml` - Continuous testing on main branch and PRs
178+
- `.github/workflows/update-main-version.yml` - Major version tag maintenance
179+
131180
## Changelog
132181
Details of major changes to the library can be found in [CHANGELOG.md](CHANGELOG.md).

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
scanoss>=1.20.5
2-
rich>=13.9.3
2+
rich>=13.9.3
3+
click==8.1.8

scanoss.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
"settings": {
33
"skip": {
44
"patterns": {
5-
"scanning": [
6-
"src/hooks/__init__.py"
7-
]
5+
"scanning": ["src/hooks/__init__.py"]
86
},
97
"sizes": {}
108
}
@@ -24,4 +22,4 @@
2422
}
2523
]
2624
}
27-
}
25+
}

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ python_requires = >=3.9
2828
install_requires =
2929
scanoss>=1.20.5
3030
rich>=13.9.3
31+
click==8.1.8
3132

3233
[options.packages.find]
3334
where = src

src/hooks/__init__.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,25 @@
1+
"""
2+
SPDX-License-Identifier: MIT
13
2-
__version__ = '0.2.0'
4+
Copyright (c) 2024, SCANOSS
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in
14+
all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
THE SOFTWARE.
23+
"""
24+
25+
__version__ = "0.3.0"

0 commit comments

Comments
 (0)