Setup test environment.
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
8515f20cc9
commit
b60881e533
33
coauthors.sh
33
coauthors.sh
@ -10,3 +10,36 @@ cat <<-EOF > ~/.git-coauthors
|
||||
}
|
||||
EOF
|
||||
git mob sig
|
||||
cat <<-EOF > ./git/hooks/prepare-commit-msg
|
||||
#!/usr/bin/env node
|
||||
let exec = require('child_process').exec,
|
||||
fs = require('fs');
|
||||
|
||||
const commitMessage = process.argv[2];
|
||||
// expect .git/COMMIT_EDITMSG
|
||||
if(/COMMIT_EDITMSG/g.test(commitMessage)){
|
||||
let contents = "";
|
||||
exec("git mob-print",
|
||||
function (err, stdout) {
|
||||
if(err) {
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
// opens .git/COMMIT_EDITMSG
|
||||
contents = fs.readFileSync(commitMessage);
|
||||
|
||||
if(contents.indexOf(stdout.trim()) !== -1) {
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const commentPos = contents.indexOf('# ');
|
||||
const gitMessage = contents.slice(0, commentPos);
|
||||
const gitComments = contents.slice(commentPos)
|
||||
|
||||
fs.writeFileSync(commitMessage, gitMessage + stdout + gitComments);
|
||||
process.exit(0);
|
||||
});
|
||||
}
|
||||
EOF
|
||||
chmod +x ./git/hooks/prepare-commit-msg
|
||||
echo "Environment is setup!"
|
Loading…
x
Reference in New Issue
Block a user