diff --git a/common_tools/git/hooks/client-side/copy_hooks_scripts.sh b/common_tools/git/hooks/client-side/copy_hooks_scripts.sh index d56b37729..a3a2b1fd8 100755 --- a/common_tools/git/hooks/client-side/copy_hooks_scripts.sh +++ b/common_tools/git/hooks/client-side/copy_hooks_scripts.sh @@ -1,6 +1,8 @@ #!/bin/sh # -# Run from the base TriBITS git repo clone to install local git hooks +# Run from a base git repo clone to install local git hooks +# +# For example: # # $ cd TriBITS/ # $ ./commont_tools/git/client-side/copy_hooks_scripts.sh @@ -14,13 +16,14 @@ fi _SCRIPT_DIR=`echo $0 | sed "s/\(.*\)\/copy_hooks_scripts.sh/\1/g"` function copy_hook_script { - orig_file="$_SCRIPT_DIR/$1" - dest_file=".git/hooks/$1" + hook_file_name=$1 + orig_file="$_SCRIPT_DIR/${hook_file_name}" + dest_file=".git/hooks/${hook_file_name}" if diff ${orig_file} ${dest_file} &> /dev/null ; then - : + echo "NOTE: Local git hook script is same as installed: ${hook_file_name}" else - echo "Copy local git hook script: $1" + echo "Copy local git hook script: ${hook_file_name}" cp "${orig_file}" "${dest_file}" fi } @@ -28,4 +31,4 @@ function copy_hook_script { #echo "_SCRIPT_DIR = '$_SCRIPT_DIR'" copy_hook_script commit-msg - +copy_hook_script pre-push diff --git a/common_tools/git/hooks/client-side/pre-push b/common_tools/git/hooks/client-side/pre-push new file mode 100755 index 000000000..80a261e37 --- /dev/null +++ b/common_tools/git/hooks/client-side/pre-push @@ -0,0 +1,86 @@ +#!/usr/bin/env python3 +# +# pre-push hook to check that commits are signed before pushing +# + +import os +import sys +import subprocess + + +# Functions + + +def s(x): + try: + return x.decode("utf-8") + except AttributeError: + return x + + +def getCmndOutput(cmnd): + result = subprocess.run(cmnd, stdout=subprocess.PIPE, + stderr = subprocess.STDOUT) + output = s(result.stdout) + if result.returncode != 0: + print("Error, the command "+str(cmnd)+" returned error code "+str(result.returncode)\ + +" with the stderr message:\n\n"+str(result.stderr)\ + +"\n\nReturned output was:\n\n"+output) + exit(1) + return output + + +# +# Main +# + + +# Read in command-line args +cmndLineArgs = sys.argv[1:] +remoteName = cmndLineArgs[0] +remoteURL = cmndLineArgs[1] +#print("remoteName = "+str(remoteName)) +#print("remoteURL = "+str(remoteURL)) + +# Read in data from STDIIN +stdinStr = sys.stdin.read().strip() +if stdinStr: + stdinArray = stdinStr.split(" ") + #print("stdinArray = "+str(stdinArray)) + localRef = stdinArray[0] + localObjectName = stdinArray[1] + remoteRef = stdinArray[2] + remoteObjectName = stdinArray[3] + #print("localRef = "+localRef) + #print("localObjectName = "+localObjectName) + #print("remoteRef = "+remoteRef) + #print("remoteObjectName = "+remoteObjectName) + +# Get the commits +if stdinStr: + gitCommits = getCmndOutput(["git", "rev-list", + remoteObjectName+".."+localObjectName]).strip() + #print("gitCommits = '"+gitCommits+"'") +else: + gitCommits = None + +# Loop over commits and check for the proper usage +if gitCommits: + + gitCommitsArray = str(gitCommits).split("\n") + #print("gitCommitsArray = "+str(gitCommitsArray)) + + for commit in gitCommitsArray: + commitMsg = getCmndOutput(["git", "log", "-1", "--pretty=format:\"%B\"", commit]) + if not "Signed-off-by:" in commitMsg: + print("Error: Commit "+commit+" does not have a Signed-off-by line!") + exit(1) + +# Abort if only doing testing +prePushHookTesting = os.environ.get("PRE_PUSH_HOOK_TESTING", "0") +if prePushHookTesting == "1": + print("Aborting pre-push because PRE_PUSH_HOOK_TESTING="+str(prePushHookTesting)) + exit(1) + +# If you get here, it is okay to push! +exit(0) diff --git a/dev_testing/cee-rhel8/load-env.gnu-10.3.0.sh b/dev_testing/cee-rhel8/load-env.gnu-10.3.0.sh index d029a4db0..8ff3a1301 100644 --- a/dev_testing/cee-rhel8/load-env.gnu-10.3.0.sh +++ b/dev_testing/cee-rhel8/load-env.gnu-10.3.0.sh @@ -2,6 +2,6 @@ module purge module load aue/cmake/3.27.7 module load aue/ninja/1.11.1 module load aue/gcc/10.3.0 -module load aue/openmpi/4.1.6-gcc-10.3.0 +module load aue/openmpi/4.1.6-gcc-10.3.0 export TribitsExMetaProj_GIT_URL_REPO_BASE=git@github.com:tribits/ diff --git a/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake b/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake index 67d7e611e..6004b26c4 100644 --- a/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake +++ b/test/core/ExamplesUnitTests/TribitsExampleProject_Tests.cmake @@ -781,12 +781,12 @@ tribits_add_advanced_test( TribitsExampleProject_install_perms install_base/install/lib install_base/install/share/WithSubpackagesB/stuff PASS_REGULAR_EXPRESSION_ALL - "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base" - "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install" - "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install/bin" - "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install/include" - "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install/lib" - "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install/share/WithSubpackagesB/stuff" + "drwxrw[xs]r-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base" + "drwxrw[xs]r-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install" + "drwxrw[xs]r-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install/bin" + "drwxrw[xs]r-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install/include" + "drwxrw[xs]r-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install/lib" + "drwxrw[xs]r-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install/share/WithSubpackagesB/stuff" ALWAYS_FAIL_ON_NONZERO_RETURN TEST_6 @@ -800,10 +800,10 @@ tribits_add_advanced_test( TribitsExampleProject_install_perms install_base/install/share/WithSubpackagesB/stuff PASS_REGULAR_EXPRESSION_ALL "${mixedLangHeaderRegex}" - "[d]rwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* wsp_c" + "[d]rwxrw[xs]r-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* wsp_c" "[-]rw-rw-r--.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* C.hpp" "[-]rw-rw-r--.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* libpws_c.a" - "[-]rwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* exec_script.sh" + "[-]rwxrw[xs]r-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* exec_script.sh" "[-]rw-rw-r--.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* regular_file.txt" ALWAYS_FAIL_ON_NONZERO_RETURN @@ -915,13 +915,13 @@ tribits_add_advanced_test( TribitsExampleProject_install_package_by_package_perm install_base/subdir/install/lib install_base/subdir/install/share/WithSubpackagesB/stuff PASS_REGULAR_EXPRESSION_ALL - "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base" - "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/subdir" - "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/subdir/install" - "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/subdir/install/bin" - "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/subdir/install/include" - "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/subdir/install/lib" - "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/subdir/install/share/WithSubpackagesB/stuff" + "drwxrw[xs]r-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base" + "drwxrw[xs]r-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/subdir" + "drwxrw[xs]r-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/subdir/install" + "drwxrw[xs]r-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/subdir/install/bin" + "drwxrw[xs]r-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/subdir/install/include" + "drwxrw[xs]r-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/subdir/install/lib" + "drwxrw[xs]r-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/subdir/install/share/WithSubpackagesB/stuff" ALWAYS_FAIL_ON_NONZERO_RETURN TEST_7 @@ -936,7 +936,7 @@ tribits_add_advanced_test( TribitsExampleProject_install_package_by_package_perm "${mixedLangHeaderRegex}" "[-]rw-rw-r--.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* B.hpp" "[-]rw-rw-r--.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* libpws_b.a" - "[-]rwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* exec_script.sh" + "[-]rwxrw[xs]r-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* exec_script.sh" "[-]rw-rw-r--.* .* ${TribitsExProj_INSTALL_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* regular_file.txt" ALWAYS_FAIL_ON_NONZERO_RETURN @@ -1060,13 +1060,13 @@ tribits_add_advanced_test( TribitsExampleProject_install_perms_nonowning_base_di ${installPrefix}/lib ${installPrefix}/share/WithSubpackagesB/stuff PASS_REGULAR_EXPRESSION_ALL - "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_BASE_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* ${installBaseDir}" - "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} +${TribitsExProj_INSTALL_OWNING_GROUP} .* ${installPrefixBaseDir}" - "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} +${TribitsExProj_INSTALL_OWNING_GROUP} .* ${installPrefix}" - "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} +${TribitsExProj_INSTALL_OWNING_GROUP} .* ${installPrefix}/bin" - "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} +${TribitsExProj_INSTALL_OWNING_GROUP} .* ${installPrefix}/include" - "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} +${TribitsExProj_INSTALL_OWNING_GROUP} .* ${installPrefix}/lib" - "drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} +${TribitsExProj_INSTALL_OWNING_GROUP} .* ${installPrefix}/share/WithSubpackagesB/stuff" + "drwxrw[xs]r-x.* .* ${TribitsExProj_INSTALL_BASE_OWNING_USER} *${TribitsExProj_INSTALL_OWNING_GROUP} .* ${installBaseDir}" + "drwxrw[xs]r-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} +${TribitsExProj_INSTALL_OWNING_GROUP} .* ${installPrefixBaseDir}" + "drwxrw[xs]r-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} +${TribitsExProj_INSTALL_OWNING_GROUP} .* ${installPrefix}" + "drwxrw[xs]r-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} +${TribitsExProj_INSTALL_OWNING_GROUP} .* ${installPrefix}/bin" + "drwxrw[xs]r-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} +${TribitsExProj_INSTALL_OWNING_GROUP} .* ${installPrefix}/include" + "drwxrw[xs]r-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} +${TribitsExProj_INSTALL_OWNING_GROUP} .* ${installPrefix}/lib" + "drwxrw[xs]r-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} +${TribitsExProj_INSTALL_OWNING_GROUP} .* ${installPrefix}/share/WithSubpackagesB/stuff" ALWAYS_FAIL_ON_NONZERO_RETURN ) diff --git a/test/core/ExamplesUnitTests/TribitsHelloWorld_Tests.cmake b/test/core/ExamplesUnitTests/TribitsHelloWorld_Tests.cmake index bbfb22eef..15bd7e346 100644 --- a/test/core/ExamplesUnitTests/TribitsHelloWorld_Tests.cmake +++ b/test/core/ExamplesUnitTests/TribitsHelloWorld_Tests.cmake @@ -684,10 +684,10 @@ tribits_add_advanced_test( TribitsHelloWorld_install_perms CMND ls ARGS -ld install install/include install/lib install/bin PASS_REGULAR_EXPRESSION_ALL - "drwx------.* .* install" - "drwx------.* .* install/bin" - "drwx------.* .* install/include" - "drwx------.* .* install/lib" + "drwx--[-S]---.* .* install" + "drwx--[-S]---.* .* install/bin" + "drwx--[-S]---.* .* install/include" + "drwx--[-S]---.* .* install/lib" ALWAYS_FAIL_ON_NONZERO_RETURN )