From e60e7cc3ff5c32ab663f39203211a4f8927832c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Haitz=20Legarreta=20Gorro=C3=B1o?= Date: Thu, 13 Jun 2019 23:09:52 -0400 Subject: [PATCH] BUG: Fix remotes maintenance scripts Fix remotes maintenance scripts: - Fix scripts input arguments `command not found` error adding the `test` command over each argument.Fixes: ``` ./Utilities/Maintenance/ApplyScriptToRemotes.sh: line 82: UpdateTestingMacrosNames: command not found ./Utilities/Maintenance/ApplyScriptToRemotes.sh: line 82: ENH: Update ITK testing macros names: command not found ``` and idem for `UpdateRequiredITKVersionInRemoteModules.sh`. Avoid the script continuing its execution if not all input parameters have been provided. - Fix the `git add` command failing when not finding any file extension that matches the filters. This was causing that even files whose extension matched any of those before the missing one were not being added. Fixes: ``` fatal: pathspec './*.c' did not match any files fatal: pathspec './*.rst' did not match any files ``` Filters are now applied individually so that if one is not found/fails, the rest can still be added. Also, `stdout` and `stderr` are redirected to `/dev/null` to avoid excessive, additional verbosity. - Fix the commit message not being correctly processed: quotes within the script were missing (in addition to the quotes in the input argument so that the script considers it as a single argument). Fixes: ``` error: pathspec 'Update' did not match any file(s) known to git. error: pathspec 'ITK' did not match any file(s) known to git. error: pathspec 'testing' did not match any file(s) known to git. error: pathspec 'macros' did not match any file(s) known to git. error: pathspec 'names' did not match any file(s) known to git. ``` - Fix the `ITK-build` directory not being removed for being non empty. Fixes: ``` rm: cannot remove '../../../ITK-build': Directory not empty ``` --- Utilities/Maintenance/ApplyScriptToRemotes.sh | 22 ++++++++++++++----- ...UpdateRequiredITKVersionInRemoteModules.sh | 2 +- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Utilities/Maintenance/ApplyScriptToRemotes.sh b/Utilities/Maintenance/ApplyScriptToRemotes.sh index ab370743aaf..a3931ad8304 100755 --- a/Utilities/Maintenance/ApplyScriptToRemotes.sh +++ b/Utilities/Maintenance/ApplyScriptToRemotes.sh @@ -79,7 +79,7 @@ script="$1" feature_branch="$2" commit_message="$3" -if test "${script}" = "" || "${feature_branch}" = "" || "${commit_message}" = "" || $help; then +if test "${script}" = "" || test "${feature_branch}" = "" || test "${commit_message}" = "" || $help; then usage exit 1 fi @@ -175,11 +175,23 @@ function apply_script_and_push_remotes() { git checkout -b $feature_branch origin/master $script - # Add the files, adding filters if necessary - git add -u *.txt ./*.cmake ./*.rst ./*.py ./*.yml ./*.c ./*.cxx ./*.h ./*.hxx ./*.wrap + # Add the files, adding filters if necessary, and redirecting stdout and + # stderr to /dev/null in order to avoid a too verbose output and + # displaying error messages if files with some given extensions are not + # found. + git add -u *.txt > /dev/null 2>&1 + git add -u *.cmake > /dev/null 2>&1 + git add -u *.rst > /dev/null 2>&1 + git add -u *.py > /dev/null 2>&1 + git add -u *.yml > /dev/null 2>&1 + git add -u *.c > /dev/null 2>&1 + git add -u *.cxx > /dev/null 2>&1 + git add -u *.h > /dev/null 2>&1 + git add -u *.hxx > /dev/null 2>&1 + git add -u *.wrap > /dev/null 2>&1 # Commit and push to the feature branch - git commit -m $commit_message + git commit -m "$commit_message" git push --quiet https://$username:$password@github.com/$username/$repository_basename $feature_branch cd .. @@ -198,6 +210,6 @@ echo -e "Applying script to remotes..." apply_script_and_push_remotes echo -e "Done applying script to remotes." -rm -r ../../../ITK-build +rm -Rf ../../../ITK-build echo -e "Visit the remote repositories and open the corresponding pull requests." diff --git a/Utilities/Maintenance/UpdateRequiredITKVersionInRemoteModules.sh b/Utilities/Maintenance/UpdateRequiredITKVersionInRemoteModules.sh index bd73dd78bab..bd2fbddbf3e 100755 --- a/Utilities/Maintenance/UpdateRequiredITKVersionInRemoteModules.sh +++ b/Utilities/Maintenance/UpdateRequiredITKVersionInRemoteModules.sh @@ -63,7 +63,7 @@ done azure_pipelines_ci_filename=$1 python_setup_filename=$2 -if test "${azure_pipelines_ci_filename}" = "" || "${python_setup_filename}" = "" || $help; then +if test "${azure_pipelines_ci_filename}" = "" || test "${python_setup_filename}" = "" || $help; then usage exit 1 fi