From bbb55769a94d14b694afa25d010fe8b845bdac28 Mon Sep 17 00:00:00 2001 From: Kevin Heis Date: Wed, 28 Jul 2021 14:35:43 -0700 Subject: [PATCH] Allow git operations when LFS isn't functioning (#20569) * Allow git operations when LFS isn't functioning * Update to be easier to read --- .husky/post-checkout | 10 +++++++++- .husky/post-commit | 10 +++++++++- .husky/post-merge | 10 +++++++++- .husky/pre-push | 10 +++++++++- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/.husky/post-checkout b/.husky/post-checkout index 70430c22c26f..280d12de2a7d 100755 --- a/.husky/post-checkout +++ b/.husky/post-checkout @@ -1,3 +1,11 @@ #!/bin/sh [ -n "$CI" ] && exit 0 -command -v git-lfs >/dev/null 2>&1 && git lfs post-checkout "$@" || { echo >&2 "\nGitHub Docs requires Git LFS but 'git-lfs' was not found on your path.\nLearn how to install Git LFS at .\n"; } +if command -v git-lfs >/dev/null 2>&1 +then + if ! (git lfs post-checkout "$@") + then + printf >&2 "\nGitHub Docs requires Git LFS but using the 'git-lfs' on your path failed.\n" + fi +else + printf >&2 "\nGitHub Docs requires Git LFS but 'git-lfs' was not found on your path.\nLearn how to install Git LFS at .\n" +fi diff --git a/.husky/post-commit b/.husky/post-commit index 5fd9b1be149c..8951e3706c3e 100755 --- a/.husky/post-commit +++ b/.husky/post-commit @@ -1,3 +1,11 @@ #!/bin/sh [ -n "$CI" ] && exit 0 -command -v git-lfs >/dev/null 2>&1 && git lfs post-commit "$@" || { echo >&2 "\nGitHub Docs requires Git LFS but 'git-lfs' was not found on your path.\nLearn how to install Git LFS at .\n"; } +if command -v git-lfs >/dev/null 2>&1 +then + if ! (git lfs post-commit "$@") + then + printf >&2 "\nGitHub Docs requires Git LFS but using the 'git-lfs' on your path failed.\n" + fi +else + printf >&2 "\nGitHub Docs requires Git LFS but 'git-lfs' was not found on your path.\nLearn how to install Git LFS at .\n" +fi diff --git a/.husky/post-merge b/.husky/post-merge index 12ce97f1f67f..e6f13fe2443b 100755 --- a/.husky/post-merge +++ b/.husky/post-merge @@ -1,3 +1,11 @@ #!/bin/sh [ -n "$CI" ] && exit 0 -command -v git-lfs >/dev/null 2>&1 && git lfs post-merge "$@" || { echo >&2 "\nGitHub Docs requires Git LFS but 'git-lfs' was not found on your path.\nLearn how to install Git LFS at .\n"; } +if command -v git-lfs >/dev/null 2>&1 +then + if ! (git lfs post-merge "$@") + then + printf >&2 "\nGitHub Docs requires Git LFS but using the 'git-lfs' on your path failed.\n" + fi +else + printf >&2 "\nGitHub Docs requires Git LFS but 'git-lfs' was not found on your path.\nLearn how to install Git LFS at .\n" +fi diff --git a/.husky/pre-push b/.husky/pre-push index 00ab5eeaadb6..fa5490bfd8f0 100755 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -1,6 +1,14 @@ #!/bin/sh [ -n "$CI" ] && exit 0 -command -v git-lfs >/dev/null 2>&1 && git lfs pre-push "$@" || { echo >&2 "\nGitHub Docs requires Git LFS but 'git-lfs' was not found on your path.\nLearn how to install Git LFS at .\n"; } +if command -v git-lfs >/dev/null 2>&1 +then + if ! (git lfs pre-push "$@") + then + printf >&2 "\nGitHub Docs requires Git LFS but using the 'git-lfs' on your path failed.\n" + fi +else + printf >&2 "\nGitHub Docs requires Git LFS but 'git-lfs' was not found on your path.\nLearn how to install Git LFS at .\n" +fi . "$(dirname "$0")/_/husky.sh"