Skip to content

Commit c681561

Browse files
authored
Merge pull request #52 from satyam-seth-learnings/setup-pre-push
Setup pre push
2 parents d6d29aa + beaaddf commit c681561

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

.githooks/pre-push

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
echo "Running tests with coverage..."
4+
5+
coverage run manage.py test
6+
status=$?
7+
8+
if [ $status -ne 0 ]; then
9+
echo "❌ Tests failed. Push aborted."
10+
exit 1
11+
fi
12+
13+
coverage report --fail-under=85 # set your threshold
14+
if [ $? -ne 0 ]; then
15+
echo "❌ Coverage is below threshold. Push aborted."
16+
exit 1
17+
fi
18+
19+
echo "✅ Tests passed and coverage is acceptable. Proceeding with push."

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,3 +1073,17 @@ python3 manage.py test
10731073
```
10741074

10751075
- Note:- pre commit official [doc](https://pre-commit.com/)
1076+
1077+
14. Setup pre push hook
1078+
1079+
- for linux or macos
1080+
1081+
```sh
1082+
cp .githooks/pre-push .git/hooks/pre-push && chmod +x .git/hooks/pre-push
1083+
```
1084+
1085+
- for windowns
1086+
1087+
```sh
1088+
copy .githooks\pre-push .git\hooks\pre-push
1089+
```

0 commit comments

Comments
 (0)