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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ensure both branches are tracked or check-changelogger-use will fail.
|
# Ensure both branches are tracked or check-changelogger-use will fail. Note we pass hooksPath
|
||||||
git checkout $PROTECTED_BRANCH --quiet
|
# to avoid running the pre-commit hook.
|
||||||
git checkout $CURRENT_BRANCH --quiet
|
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
|
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.
|
* @return {Response<string>} - the simple-git response.
|
||||||
*/
|
*/
|
||||||
export const checkoutRef = ( pathToRepo: string, ref: string ) => {
|
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 );
|
return git.checkout( ref );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -252,7 +255,10 @@ export const getPullRequestNumberFromHash = async (
|
||||||
hash: string
|
hash: string
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const git = await simpleGit( { baseDir } );
|
const git = await simpleGit( {
|
||||||
|
baseDir,
|
||||||
|
config: [ 'core.hooksPath=/dev/null' ],
|
||||||
|
} );
|
||||||
const formerHead = await git.revparse( 'HEAD' );
|
const formerHead = await git.revparse( 'HEAD' );
|
||||||
await git.checkout( hash );
|
await git.checkout( hash );
|
||||||
const cmdOutput = await git.raw( [
|
const cmdOutput = await git.raw( [
|
||||||
|
@ -294,7 +300,10 @@ export const generateDiff = async (
|
||||||
excludePaths: string[] = []
|
excludePaths: string[] = []
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const git = simpleGit( { baseDir: tmpRepoPath } );
|
const git = simpleGit( {
|
||||||
|
baseDir: tmpRepoPath,
|
||||||
|
config: [ 'core.hooksPath=/dev/null' ],
|
||||||
|
} );
|
||||||
|
|
||||||
const validBranches = [ hashA, hashB ].filter(
|
const validBranches = [ hashA, hashB ].filter(
|
||||||
( hash ) => ! refIsHash( hash )
|
( hash ) => ! refIsHash( hash )
|
||||||
|
|
|
@ -21,7 +21,10 @@ const getPluginData = async (
|
||||||
pathToMainFile: string,
|
pathToMainFile: string,
|
||||||
hashOrBranch: string
|
hashOrBranch: string
|
||||||
): Promise< string | void > => {
|
): Promise< string | void > => {
|
||||||
const git = simpleGit( { baseDir: tmpRepoPath } );
|
const git = simpleGit( {
|
||||||
|
baseDir: tmpRepoPath,
|
||||||
|
config: [ 'core.hooksPath=/dev/null' ],
|
||||||
|
} );
|
||||||
await git.checkout( [ hashOrBranch ] );
|
await git.checkout( [ hashOrBranch ] );
|
||||||
|
|
||||||
const mainFile = join( tmpRepoPath, pathToMainFile );
|
const mainFile = join( tmpRepoPath, pathToMainFile );
|
||||||
|
|
|
@ -81,7 +81,10 @@ export const generateSchemaDiff = async (
|
||||||
build: () => Promise< void > | void,
|
build: () => Promise< void > | void,
|
||||||
error: ( s: string ) => void
|
error: ( s: string ) => void
|
||||||
): Promise< SchemaDiff[] | null > => {
|
): 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.
|
// Be sure the wp-env engine is started.
|
||||||
await startWPEnv( tmpRepoPath, error );
|
await startWPEnv( tmpRepoPath, error );
|
||||||
|
|
Loading…
Reference in New Issue