Article
· Sep 26 2m read

Git Pre-commit Hook for Health Connect Cloud

Hi,

Just thought I'd share quite a handy hook that has helped me out when developing on Health Connect Cloud with VS Code and GitBash. When developing on Health Connect Cloud, if changes are made directly on the server such as routing rules or component deployments, they aren't automatically included in source control, therefore you must export from the server into your local files and push to your remote repo. I'm sure there are easier methods to deal with that which I'm in the process of testing, but as a quick solution I thought it would be handy have a pre-commit hook which triggers a reminder in GitBash - see below.

This reminder can be tweaked to mention routing rules and anything you think needs to be considered for export.

The hook code:

#!/bin/bash
# Git pre-commit hook - gentle reminder for Production.cls
targetFile="src/HCC/Connect/Production.cls"
# Check if Production.cls is already staged
staged=$(git diff --cached --name-only | grep "$targetFile")

# If Production.cls is not staged, show a gentle reminder
if [ -z "$staged" ]; then
    echo ""
    echo "💡 Gentle reminder: Have you made any changes to the Production class on the server?"
    echo ""
    echo "   If YES: Export and add $targetFile to this commit"
    echo "   If NO:  Continue with: git commit --no-verify"
    echo ""
    echo "   (This reminder appears on every commit - use --no-verify to skip)"
    echo ""
    exit 1
fi
# Production.cls is staged, proceed normally
exit 0

I hope this is useful for anyone developing with Health Connect Cloud.

 

Jordan

Discussion (1)2
Log in or sign up to continue