Skip to content

Commit

Permalink
hooks: pre-commit hook to duplicate file
Browse files Browse the repository at this point in the history
We have a file that's always a duplicate of another file, until we can
get rid of this requirement a pre-commit hook to take care of it would
be nice

Signed-off-by: Omer Tuchfeld <omer@tuchfeld.dev>
  • Loading branch information
omertuc committed Aug 7, 2024
1 parent 55fde6e commit 1892603
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,15 @@ currently built images are tracked in
## [Training](./training/README.md)

Linux Operating System Bootable containers enabled for AI Training

## Setting Up Git Hooks

To install our standard git hooks, run the following command:

```sh
./install-hooks.sh
```

### pre-commit hook

Ensures that `training/ilab-wrapper/ilab` is duplicated into `training/nvidia-bootc/duplicated/ilab-wrapper/ilab`
13 changes: 13 additions & 0 deletions hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

SOURCE_FILE="training/ilab-wrapper/ilab"
DEST_FILE="training/nvidia-bootc/duplicated/ilab-wrapper/ilab"

if [[ -f "$SOURCE_FILE" ]]; then
mkdir -p "$(dirname "$DEST_FILE")"
cp "$SOURCE_FILE" "$DEST_FILE"
git add "$DEST_FILE"
else
echo "Source file $SOURCE_FILE does not exist. Aborting commit."
exit 1
fi
8 changes: 8 additions & 0 deletions install-hooks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

HOOKS_DIR="hooks"
GIT_HOOKS_DIR=".git/hooks"

cp "$HOOKS_DIR/pre-commit" "$GIT_HOOKS_DIR/pre-commit"

echo "Hooks installed successfully."

0 comments on commit 1892603

Please sign in to comment.