Update .chezmoidata/packages.yaml
Add .git-hooks/pre-commit
This commit is contained in:
parent
955ede336b
commit
655f7064b7
|
@ -13,11 +13,14 @@ packages:
|
|||
- ca-certificates
|
||||
- chezmoi
|
||||
- coreutils
|
||||
- eza
|
||||
- gettext
|
||||
- git
|
||||
- gmp
|
||||
- icu4c
|
||||
- jq
|
||||
- jsoncpp
|
||||
- libgit2
|
||||
- liblinear
|
||||
- libnghttp2
|
||||
- libssh2
|
||||
|
@ -31,6 +34,7 @@ packages:
|
|||
- luv
|
||||
- m4
|
||||
- mactop
|
||||
- make
|
||||
- mosh
|
||||
- mpdecimal
|
||||
- msgpack
|
||||
|
@ -57,13 +61,16 @@ packages:
|
|||
- unibilium
|
||||
- unixodbc
|
||||
- xz
|
||||
- z
|
||||
- zsh-autocomplete
|
||||
casks:
|
||||
- alacritty
|
||||
- batteryboi
|
||||
- bitwarden
|
||||
- crystalfetch
|
||||
- divvy
|
||||
- docker
|
||||
- keepingyouawake
|
||||
- loop
|
||||
- signal
|
||||
- utm
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue