Skip to content

Commit

Permalink
feat: show versions of configured hooks for repo (#419)
Browse files Browse the repository at this point in the history
secureli-175

When running `secureli --version` will display the versions of all the
pre-commit hooks installed


## Changes

![image](https://github.com/slalombuild/secureli/assets/127901972/f6279aa8-2863-40ba-84e5-f9a1bdddfc96)
<!-- A detailed list of changes -->
* Display list versions of versions of pre-commit hooks installed when
running `secureli --version`
* Added launch.json setting file to debug in vscode

## Testing
<!--
Mention updated tests and any manual testing performed.
Are aspects not yet tested or not easily testable?
Feel free to include screenshots if appropriate.
 -->
* All existing unit tests are passing

## Clean Code Checklist
<!-- This is here to support you. Some/most checkboxes may not apply to
your change -->
- [x] Meets acceptance criteria for issue
- [ ] New logic is covered with automated tests
- [ ] Appropriate exception handling added
- [ ] Thoughtful logging included
- [ ] Documentation is updated
- [ ] Follow-up work is documented in TODOs
- [ ] TODOs have a ticket associated with them
- [x] No commented-out code included


<!--
Github-flavored markdown reference:
https://docs.github.com/en/get-started/writing-on-github
-->
  • Loading branch information
isaac-heist-slalom authored Feb 2, 2024
1 parent 187a78d commit fd098ab
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: secureli --version",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/secureli/main.py",
"cwd": "${workspaceFolder}",
"stopOnEntry": false,
"console": "integratedTerminal",
"justMyCode": true,
"args": ["--version"]
},
{
"name": "Python: secureli --help",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/secureli/main.py",
"cwd": "${workspaceFolder}",
"stopOnEntry": false,
"console": "integratedTerminal",
"justMyCode": true,
"args": ["--help"]
},
{
"name": "Python: secureli init",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/secureli/main.py",
"cwd": "${workspaceFolder}",
"stopOnEntry": false,
"console": "integratedTerminal",
"justMyCode": true,
"args": ["init"]
},
{
"name": "Python: secureli scan",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/secureli/main.py",
"cwd": "${workspaceFolder}",
"stopOnEntry": false,
"console": "integratedTerminal",
"justMyCode": true,
"args": ["scan"]
},
{
"name": "Python: secureli update",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/secureli/main.py",
"cwd": "${workspaceFolder}",
"stopOnEntry": false,
"console": "integratedTerminal",
"justMyCode": true,
"args": ["update"]
}
]
}
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"python.testing.pytestArgs": ["tests"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
15 changes: 15 additions & 0 deletions secureli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@
def version_callback(value: bool):
if value:
typer.echo(secureli_version())
typer.echo("\nHook Versions:")
typer.echo("--------------")
config = container.pre_commit_abstraction().get_pre_commit_config(Path("."))

all_repos = [
(hook.id, repo.rev.lstrip("v"))
for repo in config.repos
for hook in repo.hooks
]

sorted_repos = sorted(all_repos, key=lambda x: x[0])

for hook_id, version in sorted_repos:
typer.echo(f"{hook_id:<30} {version}")

raise typer.Exit()


Expand Down

0 comments on commit fd098ab

Please sign in to comment.