Test


🧩 Pre-commit Hooks — Full Session Topics (Basic → Advanced)


1️⃣ Introduction & Motivation


1. What are Pre-commit Hooks?



2. Why do we need Pre-commit Hooks?



3. Real-world problems solved by Pre-commit Hooks



4. How Pre-commit Hooks fit into the Git workflow



5. Difference between native Git hooks and pre-commit framework



6. Benefits of using the pre-commit framework (cross-team consistency, automation)



7. Alternatives to pre-commit (Husky, Lefthook, Overcommit) — quick comparison





---


2️⃣ Installation & Initial Setup


8. Installing the pre-commit package (pip/pipx)



9. Creating a new .pre-commit-config.yaml file



10. Adding your first hook (e.g., trailing-whitespace, end-of-file-fixer)



11. Running pre-commit install to activate hooks



12. Testing hooks manually (pre-commit run --all-files)



13. Viewing the generated .git/hooks/pre-commit script



14. How to update hooks (pre-commit autoupdate)




Demo ideas:


Show installing pre-commit and running a simple hook.


Show a commit blocked by a hook.




---


3️⃣ Understanding Configuration


15. Structure of .pre-commit-config.yaml



16. Important keys: repo, rev, hooks, id, entry, language, files, exclude



17. What does rev: mean and why pin versions?



18. Difference between remote hooks and local hooks



19. Running hooks on specific file types using files: filters



20. Excluding paths or patterns using exclude:



21. Stages: pre-commit, pre-push, commit-msg



22. Where pre-commit stores hook environments (~/.cache/pre-commit)




Demo ideas:


Modify .pre-commit-config.yaml live to include Black or Prettier.


Show how regex filters target specific files.




---


4️⃣ Common & Popular Hooks


23. Formatting hooks — Black, Prettier, gofmt



24. Linting hooks — Ruff, Flake8, ESLint



25. Code hygiene hooks — trailing whitespace, end of file fixer



26. Security hooks — detect-secrets, git-secrets, bandit



27. YAML/JSON syntax validation hooks



28. Git safety hooks — check merge conflict, large file check



29. Commit message hooks — enforce Conventional Commits




Demo ideas:


Show Black + Ruff pre-commit combo in action.




---


5️⃣ Writing Custom Hooks


30. Creating local hooks with repo: local



31. Writing shell script hooks (language: script)



32. Writing Python hooks (language: python)



33. Adding arguments to hooks using args:



34. Handling multiple files in one hook



35. Returning proper exit codes for success/failure



36. Packaging reusable custom hooks for your organization



37. Testing custom hooks with pre-commit try-repo




Demo ideas:


Create a custom hook that fails if “TODO” appears in code.




---


6️⃣ Running, Skipping & Managing Hooks


38. Running all hooks (pre-commit run --all-files)



39. Running a single hook (pre-commit run <hook-id>)



40. Skipping hooks (git commit --no-verify)



41. Re-running hooks only on changed files



42. Viewing which hooks were skipped or passed



43. Debugging hook output (pre-commit run -v)



44. Uninstalling hooks (pre-commit uninstall)





---


7️⃣ Integration with CI/CD


45. Why run pre-commit in CI pipelines



46. Example: GitHub Actions workflow for pre-commit



47. Example: GitLab CI / Jenkins integration



48. Running hooks on all files in CI (pre-commit run --all-files)



49. Failing CI pipeline when hooks fail



50. Using pre-commit.ci cloud service for automation




Demo ideas:


Show a sample GitHub Actions YAML for pre-commit run.




---


8️⃣ Advanced Usage


51. Pre-push and commit-msg hooks (multi-stage hooks)



52. Using Dockerized hooks (language: docker_image)



53. Using language: system for system-installed tools



54. Pre-commit in monorepos (multiple project configs)



55. Selectively applying hooks to folders with regex filters



56. Caching and performance optimization tips



57. Sharing virtualenvs or hook caches between projects





---


9️⃣ Security & Reliability


58. Why pin versions (rev:) to prevent supply-chain attacks



59. Verifying sources of remote hooks



60. Running untrusted hooks safely (Docker or isolated environments)



61. Detecting secrets or credentials before commit



62. Organization-level enforcement policies





---


🔟 Best Practices & Maintenance


63. Keep hooks fast (formatters auto-fix instead of block)



64. Document setup in CONTRIBUTING.md



65. Automate pre-commit install in onboarding scripts



66. Run pre-commit autoupdate regularly



67. Always run in CI as backup



68. Encourage small, clean commits with pre-commit checks



69. Version control .pre-commit-config.yaml file



70. Maintain consistency across all developers





---


1️⃣1️⃣ Troubleshooting & Wrap-Up


71. Common errors (command not found, permission denied, etc.)



72. Hooks fail locally but pass in CI — why?



73. Debugging failed hooks



74. Restoring default hooks after uninstall



75. Recap: Setup → Configure → Run → Custom → CI → Maintain



76. References & recommended hooks list



77. Q&A or small challenge demo





---




---


🧩 Full Step-by-Step Process to Restore data Folder in OpenShift



---


🪜 Step 1: Confirm your Neo4j PVC and Deployment


You already did this — good.

Example:


oc get pvc


Let’s assume your Neo4j PVC name is:


neo4j-data


And your Neo4j pod/deployment name is:


neo4j



---


🪜 Step 2: Scale down Neo4j to stop the running database


This ensures files aren’t locked.


oc scale deployment neo4j --replicas=0


Wait until no Neo4j pod is running:


oc get pods



---


🪜 Step 3: Create a temporary helper pod connected to the same PVC


You will use your internal registry image here (for example):


oc run neo4j-helper --image=image-registry.openshift-image-registry.svc:5000/myproject/busybox:latest -i --tty --overrides='

{

  "apiVersion": "v1",

  "spec": {

    "containers": [

      {

        "name": "neo4j-helper",

        "image": "image-registry.openshift-image-registry.svc:5000/myproject/busybox:latest",

        "command": ["sh"],

        "volumeMounts": [

          {"name": "data", "mountPath": "/var/lib/neo4j"}

        ]

      }

    ],

    "volumes": [

      {"name": "data", "persistentVolumeClaim": {"claimName": "neo4j-data"}}

    ]

  }

}' --restart=Never


Wait for it to start:


oc get pods



---


🪜 Step 4: Open shell into that helper pod


oc rsh neo4j-helper


Now you’re inside the pod, and your PVC is mounted at:


/var/lib/neo4j


Check what’s inside:


ls -l /var/lib/neo4j


You should see folders like:


data/

logs/

metrics/



---


🪜 Step 5: (Optional backup) Move current data aside (safety)


Inside the helper pod:


mv /var/lib/neo4j/data /var/lib/neo4j/data_old

mkdir /var/lib/neo4j/data


Now your old data is safe inside data_old.



---


🪜 Step 6: Copy restored data from your local machine to the pod


Open a new Windows CMD (outside pod) where your extracted backup folder is located.

Let’s say your extracted folder path is:


C:\neo4j_backup\data


Use oc rsync to copy it:


oc rsync C:\neo4j_backup\data neo4j-helper:/var/lib/neo4j/data


💡 If you face path issues in Windows, enclose with quotes:


oc rsync "C:\neo4j_backup\data" neo4j-helper:/var/lib/neo4j/data



---


🪜 Step 7: Verify inside the pod


Back in your pod shell:


ls -l /var/lib/neo4j/data


You should now see folders like:


databases/

transactions/

DBMS/



---


🪜 Step 8: Exit and clean up helper pod


Exit:


exit


Then delete the helper pod:


oc delete pod neo4j-helper



---


🪜 Step 9: Scale Neo4j back up


oc scale deployment neo4j --replicas=1


Wait until the pod starts and check logs:


oc logs -f <your-neo4j-pod-name>



---


✅ If everything is correct:


Neo4j will start without index rebuild errors.


You’ll see logs like “Database started successfully”.


You can connect to it normally.




---


Would you like me to add the verification commands inside Neo4j (via cypher-shell) to confirm that your restored data actually loaded?



<template>

  <div @click="handlePageClick">

    <router-view />

  </div>

</template>


<script setup>

import { ref } from 'vue';


const clickableSelectors = [

  'button',

  'a',

  '[role="button"]',

  'input',

  'select',

  'textarea',

  '[data-clickable="true"]'

];


function handlePageClick(event) {

  // Check if user clicked a clickable element

  const clickedEl = event.target.closest(clickableSelectors.join(','));


  if (!clickedEl) {

    // User clicked on a non-clickable area

    highlightClickables();

  }

}


function highlightClickables() {

  const elements = document.querySelectorAll(clickableSelectors.join(','));


  elements.forEach(el => {

    el.classList.add('highlight-clickable');


    // Remove highlight after 1 second

    setTimeout(() => {

      el.classList.remove('highlight-clickable');

    }, 1000);

  });

}

</script>


<style>

/* Highlight styling - you can customize */

.highlight-clickable {

  outline: 2px solid #42b883;

  box-shadow: 0 0 10px #42b883;

  transition: all 0.2s ease;

}

</style>

Comments