-
Notifications
You must be signed in to change notification settings - Fork 127
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·49 lines (40 loc) · 1.3 KB
/
setup.py
File metadata and controls
executable file
·49 lines (40 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#! /usr/bin/env python3
"""
Copyright (C) 2025-2026 Intel Corporation
SPDX-License-Identifier: MIT
"""
"""
Setup script to configure git hooks for this repository.
This script is cross-platform compatible (Linux, macOS, Windows).
"""
import subprocess
import sys
from pathlib import Path
def main():
"""Configure git to use the .githooks directory."""
try:
# Get the root directory of the repo
result = subprocess.run(
['git', 'rev-parse', '--show-toplevel'],
capture_output=True,
text=True,
check=True
)
repo_root = Path(result.stdout.strip())
githooks_dir = repo_root / '.githooks'
# Configure git to use .githooks directory
subprocess.run(
['git', 'config', 'core.hooksPath', str(githooks_dir)],
check=True
)
print("Git hooks configured successfully!")
print("The pre-commit hook will now automatically update copyright years.")
return 0
except subprocess.CalledProcessError as e:
print(f"Error configuring git hooks: {e}", file=sys.stderr)
return 1
except Exception as e:
print(f"Unexpected error: {e}", file=sys.stderr)
return 1
if __name__ == '__main__':
sys.exit(main())