Automatic Updates
Note: This guide primarily describes features beneficial for Consumers – those using libraries managed by a Creator. The setup of the hook itself might be done by a Creator or an advanced Consumer.
KiLM provides a helper command kilm add-hook
to easily create a basic post-merge
Git hook that runs kilm sync
.
Using kilm add-hook
(Recommended)
Section titled “Using kilm add-hook (Recommended)”Navigate to the root of your Git repository containing your KiCad libraries and run:
kilm add-hook
This creates a .git/hooks/post-merge
script that automatically executes kilm sync
every time you successfully run git pull
or git merge
in that repository.
Manual Hook Setup (Alternative)
Section titled “Manual Hook Setup (Alternative)”If you prefer manual setup or want to customize the hook script further, you can follow these steps:
-
Create Hook Directory (if needed): Make sure the hooks directory exists in your repository:
Terminal window mkdir -p .git/hooks -
Create Hook Script: Create a file named
.git/hooks/post-merge
. -
Add Script Content: Add the commands you want to run. For basic KiLM integration, use:
#!/bin/sh# BEGIN KiLM-managed section# KiCad Library Manager auto-update hook# Added manuallyecho "Running KiCad Library Manager sync..."kilm sync# Uncomment to set up libraries automatically (use with caution)# kilm setupecho "KiCad libraries sync complete."# END KiLM-managed section -
Make Executable: Set the execute permission:
Terminal window chmod +x .git/hooks/post-merge
How It Works
Section titled “How It Works”When you run git pull
or git merge
:
- Git executes the
post-merge
hook automatically - The hook runs
kilm sync
to check for library updates - If new versions are available, they are pulled from remote repositories
- Your local KiCad libraries stay synchronized with the latest versions
Customization Options
Section titled “Customization Options”Automatic Setup
Section titled “Automatic Setup”You can modify the hook to automatically run kilm setup
after updates by uncommenting the kilm setup
line. This is useful for automatically updating KiCad’s configuration files, but use with caution as it modifies your KiCad setup.
Additional Commands
Section titled “Additional Commands”Add any other commands you want to run after library updates, such as:
- Notifications or logging
- Additional validation steps
- Integration with other tools
Troubleshooting
Section titled “Troubleshooting”Hook Not Running
Section titled “Hook Not Running”- Ensure the hook file has execute permissions (
chmod +x .git/hooks/post-merge
) - Check that you’re running
git pull
orgit merge
(notgit fetch
) - Verify the hook is in the correct repository’s
.git/hooks
directory
Custom Hooks Directory
Section titled “Custom Hooks Directory”If your repository uses git config core.hooksPath
, KiLM will automatically detect and use that location. You can check your current hooks path with:
git config core.hooksPath
Git Worktrees
Section titled “Git Worktrees”For repositories using Git worktrees, KiLM correctly identifies the main repository location and installs hooks in the appropriate hooks directory.