Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Upcoming changes...

## [0.4.0] - 2025-10-31
### Added
- Load environment variables from .env file if it exists

## [0.3.1] - 2025-10-27
### Fixed
- Capture stderr output from subprocesses
Expand Down Expand Up @@ -48,3 +52,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[0.2.0]: https://github.com/scanoss/pre-commit-hooks/compare/v0.1.0...v0.2.0
[0.3.0]: https://github.com/scanoss/pre-commit-hooks/compare/v0.2.0...v0.3.0
[0.3.1]: https://github.com/scanoss/pre-commit-hooks/compare/v0.3.0...v0.3.1
[0.4.0]: https://github.com/scanoss/pre-commit-hooks/compare/v0.3.1...v0.4.0
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ This repository currently includes the following pre-commit hooks:
- **scanoss-check-undeclared-code**
- This hook checks for potential undeclared open source software in the files being committed.
- It is designed to run at the `pre-commit`, `pre-push`, and `manual` stages.
- Configuration can be provided via command-line arguments, environment variables, or a `.env` file.


## Installation
Expand Down Expand Up @@ -65,7 +66,19 @@ For more installation options, refer to the [pre-commit documentation](https://p
pre-commit install
```

4. (Optional) Run the hooks against all files to ensure everything is in order:
4. (Optional) Configure the hook using a `.env` file in your project root:

```bash
# .env
SCANOSS_API_KEY=your_api_key_here
SCANOSS_SCAN_URL=https://api.scanoss.com/scan/direct
HTTPS_PROXY=http://proxy.example.com:8080
SCANOSS_DEBUG=true
```

The hook automatically loads environment variables from the `.env` file if it exists. You can also set these variables directly in your environment or pass them as command-line arguments.

5. (Optional) Run the hooks against all files to ensure everything is in order:

```bash
pre-commit run --all-files
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
scanoss>=1.20.5
rich>=13.9.3
click==8.1.8
python-dotenv>=1.0.0
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ install_requires =
scanoss>=1.20.5
rich>=13.9.3
click==8.1.8
python-dotenv>=1.0.0

[options.packages.find]
where = src
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
THE SOFTWARE.
"""

__version__ = "0.3.1"
__version__ = "0.4.0"
5 changes: 5 additions & 0 deletions src/hooks/check_undeclared_software.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from typing import List

import click
from dotenv import load_dotenv
from rich.console import Console
from rich.table import Table

Expand All @@ -44,6 +45,9 @@

console = Console()

# Load environment variables from .env file if it exists
load_dotenv()


def configure_logging(debug: bool) -> None:
"""
Expand Down Expand Up @@ -229,6 +233,7 @@ def main(

This pre-commit hook scans staged files using SCANOSS to detect undeclared open source code.
"""

# TODO: Warn users if .scanoss is not in .gitignore
configure_logging(debug)

Expand Down