New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add django-diagrams hook #9
base: master
Are you sure you want to change the base?
Conversation
4883542
to
5132ea7
Compare
@@ -20,3 +20,9 @@ | |||
entry: (has_perm|@permission_required)\(["'][^\."']+["']\) | |||
language: pygrep | |||
types: [python] | |||
# when calling this hook in a repo you must add args: [<path to local settings e.g. qrhub.settings.local>] in the repo .pre-commit-config.yaml file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use the DJANGO_SETTINGS_MODULE
env var?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better if we could but I couldn't find a way to get it into the .pre-commit-hooks.yaml
file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to use the env var, otherwise it won't be able to use the correct settings in both local and CI contexts. Not sure what you mean by getting it into the YAML file, but first thing to try would be echo $DJANGO_SETTINGS_MODULE
in the bash script to see if it's set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that but will just double check
|
||
declare -A unique_apps | ||
|
||
MIGRATIONS=$@ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this be empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it shouldn't. The hook passes the migration file names as args (at least testing locally on the hub it does. It should behave the same way here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, then presumably it is passing all changed files and you need to filter out those that are not migrations? Or does the pre-commit files
parameter do that filtering for you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pre-commit files
param does it
generate_diagrams.sh
Outdated
python -m django_diagram -a $APP -o ./docs/model_diagrams/$APP.md -s $SETTINGS_MODULE | ||
done | ||
|
||
git add ./docs/model_diagrams/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This hook will add/update diagram files in the docs directory of a django app when there are migration files present in the commit. The aim is to give a model relationship reference for developers and product owners. This is not intended for end user consumption, it is just an internal reference.