Skip to content

Commit 0c2512c

Browse files
authored
Merge pull request #221 from ComputerScienceHouse/wdn/check
add pre-commit hook to run black
2 parents 943e487 + 32778bc commit 0c2512c

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

HACKING/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
2. Follow the _Podman Environment Instructions_ to set up a Podman dev environment. If you'd like to run Proxstar entirely on your own hardware, check out _Setting up a full dev environment_
66

7+
If you'd like, you can also install the hooks by running `install_hooks.sh` from this directory.
8+
79
3. Create a Virtualenv to do your linting in
810
```
911
mkdir venv

HACKING/hooks/pre-commit

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
files="./**/*.py *.py"
2+
# Check if any files need to be re-formatted
3+
black --check --quiet $files
4+
check_status=$?
5+
6+
# Reformat the files
7+
black $files
8+
9+
if [ $check_status -ne 0 ]; then
10+
# Check if Black made any changes
11+
echo "Black has reformatted files."
12+
echo "Please review the changes and run 'git add' to stage them."
13+
exit 1
14+
fi
15+
16+
# If no issues were found, exit successfully
17+
echo "All files are properly formatted."
18+
exit 0

HACKING/install_hooks.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
ln -sf $(pwd)/hooks/* ../.git/hooks/
6+

config.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@
5050

5151
# REDIS
5252
REDIS_HOST = environ.get('PROXSTAR_REDIS_HOST', 'localhost')
53-
RQ_DASHBOARD_REDIS_URL = (
54-
"redis://" + environ.get('PROXSTAR_REDIS_HOST', 'localhost') + ":" +
55-
environ.get('PROXSTAR_REDIS_PORT', '6379') + "/0"
56-
)
53+
RQ_DASHBOARD_REDIS_URL = f"redis://{environ.get('PROXSTAR_REDIS_HOST', 'localhost')}:{environ.get('PROXSTAR_REDIS_PORT', '6379')}/0"
5754
REDIS_PORT = int(environ.get('PROXSTAR_REDIS_PORT', '6379'))
5855

5956
# VNC

0 commit comments

Comments
 (0)