Skip to content
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

25 custom hooks #34

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .hooks/render-readme.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

# Check if README.qmd has been modified
if git diff --cached --name-only | grep -q "^README\.qmd$"; then
echo "README.qmd has been modified. Rendering README.md..."
if quarto render README.qmd --to markdown; then
# Stage the updated README.md
git add README.md
else
echo "Failed to render README.qmd. Commit aborted."
exit 1
fi
else
echo "README.qmd has not been modified. Skipping rendering."
fi
10 changes: 9 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,12 @@ repos:
- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
hooks:
- id: nbstripout
- id: nbstripout

- repo: local
hooks:
- id: render-readme
name: render README
entry: .hooks/render-readme.sh
language: system
files: ^README\.qmd$
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Earth Observation Datascience

---
title: Earth Observation Datascience
toc-title: Table of contents
---

This is a book on Earth Observation Datascience, consisting of common
workflows in Python at the Department of Geodesy and Geoinformation at
Expand Down Expand Up @@ -36,7 +38,7 @@ following steps:
`_quarto.yml` file
4) Add references to `chapter/references.bib`

Dont worry if your original file is an Jupyter Notebook. Jupyter
Don't worry if your original file is an Jupyter Notebook. Jupyter
notebooks can be easily converted to quarto files by using:

``` {bash}
Expand All @@ -53,6 +55,16 @@ pip install pre-commit
pre-commit install
```

The pre configured hooks check for:

- trailing whitspaces
- large files
- private keys
- and renders the README file

The file `.pre-commin-config.yaml` hereby specifies what hooks should be
run.

The `git workflow` essentialy converts the quarto files in `chapters`
into jupyter notebooks, generates a file for the table of contents and
pushes these files together with the **Makefile** and the
Expand Down
8 changes: 8 additions & 0 deletions README.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,13 @@ The pre-commit hooks can be used to check whether outputs are empty. This can be
pip install pre-commit
pre-commit install
```
The pre configured hooks check for:

* trailing whitspaces
* large files
* private keys
* and renders the README file

The file `.pre-commin-config.yaml` hereby specifies what hooks should be run.

The `git workflow` essentialy converts the quarto files in ``chapters`` into jupyter notebooks, generates a file for the table of contents and pushes these files together with the **Makefile** and the **references.bib** files to the cookbook repository.