Skip to content

Commit 4a3784d

Browse files
committed
Add additional demo
1 parent 7208021 commit 4a3784d

1 file changed

Lines changed: 26 additions & 6 deletions

File tree

demo-notes.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,46 @@ Run the demos in VS Code for the combined view of the file contents and the term
1313
3. Change `workbench.color.theme` to `Light High Contrast` (default `Dark Modern`).
1414

1515
4. Create a fresh virtual environment:
16-
16+
1717
```shell
1818
$ conda create --name pre-commit-demo python=3.12
1919
$ conda activate pre-commit-demo
2020
```
2121

2222
5. Disable Copilot completions by clicking the icon in the bottom right of VS Code.
2323

24+
6. Save a PDF copy of the slides to distribute as needed:
25+
26+
```shell
27+
$ curl -OJ https://stefaniemolin.com/pre-commit-workshop/slides.pdf
28+
```
29+
2430
## Section 1 demos
2531

26-
### Pre-commit package installation
32+
### Git hooks demo
2733

2834
1. Branch off of `main` (name it after the event).
29-
2. With a pre-made virtual environment activated, run `python3 -m pip install pre-commit`.
35+
2. Run `tree .git/hooks` and discuss output.
36+
3. Run `less .git/hooks/pre-commit.sample` and discuss output.
37+
4. Create a version of the file that will get run: `cp .git/hooks/pre-commit.sample .git/hooks/pre-commit`.
38+
5. Edit the `.git/hooks/pre-commit` file to have `exit 1` near the top (automatic failure).
39+
6. Attempt to commit the slides PDF to this branch. Discuss why it failed.
40+
7. Run `rm .git/hooks/pre-commit` to get rid of the automatic failure hook.
41+
8. Attempt the commit again. Discuss why it succeeds.
42+
9. Push the changes up so the PDF version of the slides is available for everyone.
43+
44+
### Pre-commit package installation
45+
46+
1. With a pre-made virtual environment activated, run `python3 -m pip install pre-commit`.
47+
2. Run `pre-commit --version` to show it worked.
3048

3149
### Install first set of hooks
3250

33-
1. Create `.pre-commit-config.yaml` file copying the contents from the slides.
34-
2. Run `pre-commit install`.
35-
3. Commit the `.pre-commit-config.yaml` file.
51+
1. Show that `pre-commit sample-config` can be used to see what an example looks like, but mention that the version is outdated, and the contents are different than what we will use.
52+
2. Create `.pre-commit-config.yaml` file copying the contents from the slides.
53+
3. Run `pre-commit install`.
54+
4. Run `less .git/hooks/pre-commit` and show that the contents are now coming from `pre-commit` and referencing the `.pre-commit-config.yaml` file.
55+
5. Commit the `.pre-commit-config.yaml` file.
3656

3757
### Adding `ruff`
3858

0 commit comments

Comments
 (0)