Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
internewshid
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
aptivate
client-projects
internewshid
Commits
0c255105
Commit
0c255105
authored
5 years ago
by
Martin Burchell
Browse files
Options
Downloads
Patches
Plain Diff
Add pre-commit hook for isort / pylava
parent
5b8e2cb5
No related branches found
Branches containing commit
No related tags found
1 merge request
!124
Staging
Pipeline
#5526
passed
5 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Makefile
+17
-0
17 additions, 0 deletions
Makefile
bin/pre-commit-hook.sh
+27
-0
27 additions, 0 deletions
bin/pre-commit-hook.sh
with
44 additions
and
0 deletions
Makefile
0 → 100644
+
17
−
0
View file @
0c255105
PROJECT_NAME
:=
internewshid
MANAGEPY
:=
python manage.py
PIPENVRUN
:=
pipenv run
PROJECT_ROOT
:=
.
SOURCE_DIR
:=
$(
PROJECT_ROOT
)
/
$(
PROJECT_NAME
)
/
lint
:
@$(
PIPENVRUN
)
pylava
-o
setup.cfg
$(
SOURCE_DIR
)
.PHONY
:
lint
sort
:
$(
PIPENVRUN
)
isort
-c
-rc
--diff
-sp
setup.cfg
$(
SOURCE_DIR
)
.PHONY
:
sort
test
:
@$(
PIPENVRUN
)
pytest
--cov
=
$(
PROJECT_NAME
)
.PHONY
:
test
This diff is collapsed.
Click to expand it.
bin/pre-commit-hook.sh
0 → 100755
+
27
−
0
View file @
0c255105
#!/bin/bash
# pre-commit hook script that runs lint & sort
#
# Usage: ln -s ./bin/pre-commit-hook.sh .git/hooks/pre-commit
#
# This does not run tests, as it would be slow to do at every commit.
# Linting and sorting however ensures we don't get cosmetic commits later
# that break git blame history for no reason.
#
# This script doesn't stash changes to avoid un-expected side effects.
# So if you have non-commited changes that break this you'll need to
# stash your changes before commiting.
RED
=
'\033[0;31m'
GREEN
=
'\033[0;32m'
NC
=
'\033[0m'
# No Color
make lint
&&
make
sort
RESULT
=
$?
if
[
$RESULT
-ne
0
]
;
then
echo
-e
"
${
RED
}
lint/sort failed; commit aborted. See errors above.
${
NC
}
\n
"
exit
1
fi
echo
-e
"
${
GREEN
}
lint/sort success.
${
NC
}
\n
"
exit
0
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment