maedhroz commented on code in PR #2114:
URL: https://github.com/apache/cassandra/pull/2114#discussion_r1097919024


##########
dev-support/install-git-defaults.sh:
##########
@@ -0,0 +1,115 @@
+#!/usr/bin/env bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#set -o xtrace
+set -o errexit
+set -o pipefail
+set -o nounset
+
+bin="$(cd "$(dirname "$0")" > /dev/null; pwd)"
+
+install_template_script() {
+  local -r name="$1"
+  local -r d_dir="$2"
+
+  cat <<EOF > "$name"
+#!/usr/bin/env bash
+
+# This script is autogenerated by the Apache Cassandra build; DO NOT CHANGE!
+# When this script is not found it will be installed automatically by the build
+# If an existing script is found, that script will be reloated under ${d_dir} 
as 000-original.sh
+
+# Redirect output to stderr.
+exec 1>&2
+
+# Find all scripts to run
+for path in \$(find "$d_dir" -name '*.sh' | perl -e "print sort{(split '/', 
\\\$a)[-1] <=> (split '/', \\\$b)[-1]}<>"); do
+  "\$path" "\$@"
+done
+EOF
+  chmod a+x "$name"
+}
+
+install_hook() {
+  local -r git_dir="$1"
+  local -r hooks_dir="${git_dir}/hooks"
+  local -r name="$2"
+  local -r d_dir="${hooks_dir}/${name}.d"
+  local -r trigger_on_install=$3
+
+  mkdir "${d_dir}" &> /dev/null || true
+  local -r script_name="${hooks_dir}/${name}"
+  local installed=true
+  if [[ -e "$script_name" ]]; then
+    # was the script already installed?
+    if ! grep "This script is autogenerated by the Apache Cassandra build" 
"$script_name" &> /dev/null ; then
+      # user already has a script... move it!
+      #TODO should we bail and ask user to deal with this?

Review Comment:
   > #TODO should we bail and ask user to deal with this?
   
   My vote would be to bail and make the user deal w/ it, rather than making 
the script more complicated (including inline documentation of the additional 
behaviors) to deal w/ it. (It seems like we'd mostly be expecting not to be in 
this state.)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to