diff options
author | Jiri Malak <malak.jiri@gmail.com> | 2020-04-15 05:27:33 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-04-15 14:30:04 (GMT) |
commit | 22aff63653ea6350a2963b75eda3d372ad1fe3ab (patch) | |
tree | be0794c96849af13874d0cbf94d3ab8899e17071 | |
parent | 734238d64f292af9d3f68742c18b0ac96b78ac06 (diff) | |
download | CMake-22aff63653ea6350a2963b75eda3d372ad1fe3ab.zip CMake-22aff63653ea6350a2963b75eda3d372ad1fe3ab.tar.gz CMake-22aff63653ea6350a2963b75eda3d372ad1fe3ab.tar.bz2 |
setup-user: restore portability
Changes in commit 5129e97285 (setup-user: switch to git-var to check if
username and e-mail are set, 2019-11-24, v3.17.0-rc1~379^2) now require
the `rev` and `cut` tools to be available. Revise the logic to use that
approach only when they are available, and otherwise fall back to the
previous more portable approach.
Co-Author: Brad King <brad.king@kitware.com>
-rwxr-xr-x | Utilities/GitSetup/setup-user | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Utilities/GitSetup/setup-user b/Utilities/GitSetup/setup-user index 0b98879..4cbd184 100755 --- a/Utilities/GitSetup/setup-user +++ b/Utilities/GitSetup/setup-user @@ -20,7 +20,14 @@ # Project configuration instructions: NONE for (( ; ; )); do - ident="$(git var GIT_AUTHOR_IDENT 2>/dev/null | rev | cut -d' ' -f3- | rev)" + if type -p rev >/dev/null && type -p cut >/dev/null; then + ident="$(git var GIT_AUTHOR_IDENT 2>/dev/null | rev | cut -d' ' -f3- | rev)" + elif user_name=$(git config --get user.name) && + user_email=$(git config --get user.email); then + ident="$user_name <$user_email>" + else + ident="" + fi if test -n "$ident"; then echo 'Your commits will record as Author: |