Add post checkout pnpm install to git hooks (#36731)
* Add post checkout pnpm install to help devs, disable hooks on pre push. * Disable hooks in all simpleGit instances where checkout is run.
This commit is contained in:
parent
b3b6eacdf4
commit
13b09da2cf
|
@ -0,0 +1,4 @@
|
|||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
pnpm install
|
|
@ -31,8 +31,9 @@ if [ $? -ne 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure both branches are tracked or check-changelogger-use will fail.
|
||||
git checkout $PROTECTED_BRANCH --quiet
|
||||
git checkout $CURRENT_BRANCH --quiet
|
||||
# Ensure both branches are tracked or check-changelogger-use will fail. Note we pass hooksPath
|
||||
# to avoid running the pre-commit hook.
|
||||
git -c core.hooksPath=/dev/null checkout $PROTECTED_BRANCH --quiet
|
||||
git -c core.hooksPath=/dev/null checkout $CURRENT_BRANCH --quiet
|
||||
|
||||
php tools/monorepo/check-changelogger-use.php $PROTECTED_BRANCH $CURRENT_BRANCH
|
||||
|
|
|
@ -132,7 +132,10 @@ export const sparseCheckoutRepo = async (
|
|||
* @return {Response<string>} - the simple-git response.
|
||||
*/
|
||||
export const checkoutRef = ( pathToRepo: string, ref: string ) => {
|
||||
const git = simpleGit( { baseDir: pathToRepo } );
|
||||
const git = simpleGit( {
|
||||
baseDir: pathToRepo,
|
||||
config: [ 'core.hooksPath=/dev/null' ],
|
||||
} );
|
||||
return git.checkout( ref );
|
||||
};
|
||||
|
||||
|
@ -252,7 +255,10 @@ export const getPullRequestNumberFromHash = async (
|
|||
hash: string
|
||||
) => {
|
||||
try {
|
||||
const git = await simpleGit( { baseDir } );
|
||||
const git = await simpleGit( {
|
||||
baseDir,
|
||||
config: [ 'core.hooksPath=/dev/null' ],
|
||||
} );
|
||||
const formerHead = await git.revparse( 'HEAD' );
|
||||
await git.checkout( hash );
|
||||
const cmdOutput = await git.raw( [
|
||||
|
@ -294,7 +300,10 @@ export const generateDiff = async (
|
|||
excludePaths: string[] = []
|
||||
) => {
|
||||
try {
|
||||
const git = simpleGit( { baseDir: tmpRepoPath } );
|
||||
const git = simpleGit( {
|
||||
baseDir: tmpRepoPath,
|
||||
config: [ 'core.hooksPath=/dev/null' ],
|
||||
} );
|
||||
|
||||
const validBranches = [ hashA, hashB ].filter(
|
||||
( hash ) => ! refIsHash( hash )
|
||||
|
|
|
@ -21,7 +21,10 @@ const getPluginData = async (
|
|||
pathToMainFile: string,
|
||||
hashOrBranch: string
|
||||
): Promise< string | void > => {
|
||||
const git = simpleGit( { baseDir: tmpRepoPath } );
|
||||
const git = simpleGit( {
|
||||
baseDir: tmpRepoPath,
|
||||
config: [ 'core.hooksPath=/dev/null' ],
|
||||
} );
|
||||
await git.checkout( [ hashOrBranch ] );
|
||||
|
||||
const mainFile = join( tmpRepoPath, pathToMainFile );
|
||||
|
|
|
@ -81,7 +81,10 @@ export const generateSchemaDiff = async (
|
|||
build: () => Promise< void > | void,
|
||||
error: ( s: string ) => void
|
||||
): Promise< SchemaDiff[] | null > => {
|
||||
const git = simpleGit( { baseDir: tmpRepoPath } );
|
||||
const git = simpleGit( {
|
||||
baseDir: tmpRepoPath,
|
||||
config: [ 'core.hooksPath=/dev/null' ],
|
||||
} );
|
||||
|
||||
// Be sure the wp-env engine is started.
|
||||
await startWPEnv( tmpRepoPath, error );
|
||||
|
|
Loading…
Reference in New Issue