Update .chezmoidata/packages.yaml

Add .git-hooks/pre-commit
This commit is contained in:
Florian Beisel 2024-06-04 16:55:43 +02:00
parent 955ede336b
commit 655f7064b7
2 changed files with 61 additions and 0 deletions

View File

@ -13,11 +13,14 @@ packages:
- ca-certificates - ca-certificates
- chezmoi - chezmoi
- coreutils - coreutils
- eza
- gettext - gettext
- git
- gmp - gmp
- icu4c - icu4c
- jq - jq
- jsoncpp - jsoncpp
- libgit2
- liblinear - liblinear
- libnghttp2 - libnghttp2
- libssh2 - libssh2
@ -31,6 +34,7 @@ packages:
- luv - luv
- m4 - m4
- mactop - mactop
- make
- mosh - mosh
- mpdecimal - mpdecimal
- msgpack - msgpack
@ -57,13 +61,16 @@ packages:
- unibilium - unibilium
- unixodbc - unixodbc
- xz - xz
- z
- zsh-autocomplete - zsh-autocomplete
casks: casks:
- alacritty - alacritty
- batteryboi
- bitwarden - bitwarden
- crystalfetch - crystalfetch
- divvy - divvy
- docker - docker
- keepingyouawake - keepingyouawake
- loop - loop
- signal
- utm - utm

View File

@ -0,0 +1,54 @@
#!/usr/bin/env node
const { execSync } = require('child_process');
// Define the allowed email addresses for each directory pattern
const EMAILS = {
"/Users/beisel/git/privat": "florian@beisel.it",
"/Users/beisel/git/": "florian.beisel@intersport.de",
"/Users/beisel/.local/share/chezmoi": "florian@beisel.it",
};
// Get the current repository path
const REPO_PATH = execSync('git rev-parse --show-toplevel', { encoding: 'utf8' }).trim();
// Get the current user email
const CURRENT_EMAIL = execSync('git config user.email', { encoding: 'utf8' }).trim();
// Initialize allowed email as empty
let ALLOWED_EMAIL = "";
// Check each directory pattern
for (const DIR in EMAILS) {
if (REPO_PATH.startsWith(DIR)) {
ALLOWED_EMAIL = EMAILS[DIR];
break;
}
}
// If no matching directory pattern was found, exit
if (!ALLOWED_EMAIL) {
console.error("Error: No allowed email found for this repository");
process.exit(1);
}
// Check if the current email is allowed
if (CURRENT_EMAIL !== ALLOWED_EMAIL) {
console.error(`Error: You are using the wrong email for this repository
Your current email: ${CURRENT_EMAIL}
Allowed email: ${ALLOWED_EMAIL}`);
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});
readline.question(`Do you want to change the email for this repository to ${ALLOWED_EMAIL}? (y/n) `, (answer) => {
if (answer.toLowerCase() === 'y') {
execSync(`git config user.email "${ALLOWED_EMAIL}"`);
console.log(`Email changed to ${ALLOWED_EMAIL}`);
}
readline.close();
process.exit(answer.toLowerCase() !== 'y' ? 1 : 0);
});
}