-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
614 additions
and
5,162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
/package.json | ||
.\#* | ||
\#*\# | ||
run-tests/**/target/** | ||
test-project/**/target/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env python3 | ||
|
||
# This code was mostly written by Claude.ai. | ||
|
||
import os | ||
import sys | ||
|
||
|
||
def main() -> None: | ||
""" | ||
Main entry point to create a pre-commit hook symlink. | ||
""" | ||
symlink_hook("pre-commit") | ||
|
||
|
||
def symlink_hook(hook: str) -> None: | ||
""" | ||
Create a symlink for a Git hook if it doesn't already exist. | ||
Args: | ||
hook: Name of the Git hook (e.g., 'pre-commit') | ||
""" | ||
# Path to the hook in .git/hooks | ||
dot_hook_path = os.path.join(".git", "hooks", hook) | ||
|
||
# Path to the actual hook script | ||
file_hook_path = os.path.join("git", "hooks", f"{hook}.sh") | ||
|
||
# Relative symlink path | ||
link_path = os.path.join("..", "..", file_hook_path) | ||
|
||
# Check if the hook already exists | ||
if os.path.exists(dot_hook_path): | ||
# If it's already a symlink, check if it points to the correct location | ||
if os.path.islink(dot_hook_path): | ||
# If the existing symlink is correct, do nothing | ||
if os.readlink(dot_hook_path) == link_path: | ||
return | ||
|
||
# If a hook exists and is not the expected symlink, warn and exit | ||
print(f"You already have a hook at {dot_hook_path}!", file=sys.stderr) | ||
return | ||
|
||
# Create the symlink | ||
try: | ||
os.symlink(link_path, dot_hook_path) | ||
except OSError as e: | ||
print(f"Error creating symlink: {e}", file=sys.stderr) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.