vitess.io/vitess@v0.16.2/misc/git/commit-msg.signoff (about)

     1  #!/bin/bash
     2  
     3  # This script is run during "git commit" after the commit message was entered.
     4  #
     5  # If it does not find a Signed-off-by: line in this commit,
     6  # it prints a message about using the -s flag and a link
     7  # to an explanation of the DCO.
     8  #
     9  # If it detects an interactive session, it prompts the user
    10  # to acknowledge signoff now, and adds the line if so.
    11  
    12  msg_file="$1"
    13  
    14  git_email="$(git config --get user.email)"
    15  git_name="$(git config --get user.name)"
    16  signoff="Signed-off-by: ${git_name} <${git_email}>"
    17  
    18  if git interpret-trailers --parse $msg_file | grep -q -F "$signoff"; then
    19    exit 0
    20  fi
    21  
    22  # No signoff found, or the email doesn't match. Print some instructions.
    23  echo
    24  echo "==================================================================="
    25  echo "No 'Signed-off-by:' line was found, or it didn't match the"
    26  echo "expected author: ${git_name} <${git_email}>"
    27  echo
    28  echo "This project uses a Developer Certificate of Origin"
    29  echo "instead of a Contributor License Agreement."
    30  echo "For more information, see: https://wiki.linuxfoundation.org/dco"
    31  echo
    32  echo "Please certify each contribution meets the requirements in the"
    33  echo "'DCO' file in the root of this repository by committing with"
    34  echo "the --signoff flag (or the short form: -s):"
    35  echo
    36  echo "    git commit --signoff"
    37  
    38  # git doesn't give us access to user input, so let's steal it.
    39  exec < /dev/tty
    40  if [[ $? -ne 0 ]]; then
    41    # non-interactive shell (e.g. called from Eclipse). Give up here.
    42    exit 1
    43  fi
    44  
    45  # Offer to add the signoff line.
    46  echo
    47  echo "Alternatively, you can acknowledge your signoff and continue below:"
    48  echo
    49  echo "    ${signoff}"
    50  echo
    51  echo -n "Do you want to add the above signoff and continue? [y/N] "
    52  read reply
    53  
    54  if [[ "${reply}" != "y" ]]; then
    55    exit 1
    56  fi
    57  
    58  git interpret-trailers --trailer "$signoff" --in-place "$msg_file"