diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 18:31:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 18:31:44 +0000 |
commit | c23a457e72abe608715ac76f076f47dc42af07a5 (patch) | |
tree | 2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /vendor/gix/src/assets/init/hooks | |
parent | Releasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip |
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/gix/src/assets/init/hooks')
11 files changed, 281 insertions, 0 deletions
diff --git a/vendor/gix/src/assets/init/hooks/applypatch-msg.sample b/vendor/gix/src/assets/init/hooks/applypatch-msg.sample new file mode 100755 index 000000000..945f2f6b3 --- /dev/null +++ b/vendor/gix/src/assets/init/hooks/applypatch-msg.sample @@ -0,0 +1,25 @@ +#!/bin/sh +# A sample hook to check commit messages created by `git am` +########################################################### +# +# When you receive a patch via email, the `git am` command is commonly used to apply +# that patch. During the `git am` process, the `applypatch-msg` hook is executed before +# creating the commit. Its purpose is to validate and modify the commit log message +# before the patch is applied as a commit in your Git repository. +# +# This script serves as an example to validate that the commit message introduced by +# the patch from an email would pass the `commit-msg` hook, which would be executed +# if you had created the commit yourself. +# +# This hook is the first and followed up by `pre-applypatch` and `post-applypatch`. +# +# To enable this hook remove the `.sample` suffix from this file entirely. + +# Retrieve the path of the commit-msg hook script. +commitmsg="$(git rev-parse --git-path hooks/commit-msg)" + +# If the commit-msg hook script is executable, execute it and pass any command-line arguments to it. +test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"} + +# Be sure to exit without error if `exec` isn't called. +: diff --git a/vendor/gix/src/assets/init/hooks/commit-msg.sample b/vendor/gix/src/assets/init/hooks/commit-msg.sample new file mode 100755 index 000000000..a7f612f6b --- /dev/null +++ b/vendor/gix/src/assets/init/hooks/commit-msg.sample @@ -0,0 +1,25 @@ +#!/bin/sh +# A sample hook to check commit messages created by `git commit` +################################################################ +# +# This example script checks commit messages for duplicate `Signed-off-by` +# lines and rejects the commit if these are present. +# +# It is called by "git commit" with a single argument: the name of the file +# that contains the final commit message, which would be used in the commit. +# A a non-zero exit status after issuing an appropriate message stops the operation. +# The hook is allowed to edit the commit message file by rewriting the file +# containing it. +# +# To enable this hook remove the `.sample` suffix from this file entirely. + +# Check for duplicate Signed-off-by lines in the commit message. +# The following command uses grep to find lines starting with "Signed-off-by: " +# in the commit message file specified by the first argument `$1`. +# It then sorts the lines, counts the number of occurrences of each line, +# and removes any lines that occur only once. +# If there are any remaining lines, it means there are duplicate Signed-off-by lines. +test "$(grep '^Signed-off-by: ' "$1" | sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" = "" || { + echo "Remove duplicate Signed-off-by lines and repeat the commit." 1>&2 + exit 1 +} diff --git a/vendor/gix/src/assets/init/hooks/docs.url b/vendor/gix/src/assets/init/hooks/docs.url new file mode 100644 index 000000000..bbec3978f --- /dev/null +++ b/vendor/gix/src/assets/init/hooks/docs.url @@ -0,0 +1 @@ +https://git-scm.com/docs/githooks diff --git a/vendor/gix/src/assets/init/hooks/fsmonitor-watchman.sample b/vendor/gix/src/assets/init/hooks/fsmonitor-watchman.sample new file mode 100755 index 000000000..cd8985bc8 --- /dev/null +++ b/vendor/gix/src/assets/init/hooks/fsmonitor-watchman.sample @@ -0,0 +1,16 @@ +#!/usr/bin/sh +# How to use hook-based fs-monitor integrations +############################################### + +# This script is meant as a placeholder for integrating filesystem monitors with git +# using hooks in order to speed up commands like `git-status`. +# +# To setup the fs-monitor for use with watchman, run +# `git config core.fsmonitor .git/hooks/fsmonitor-watchman` and paste the content of +# the example script over at https://github.com/git/git/blob/aa9166bcc0ba654fc21f198a30647ec087f733ed/templates/hooks--fsmonitor-watchman.sample +# into `.git/hooks/fsmonitor-watchman`. +# +# Note that by now and as of this writing on MacOS and Windows and starting from git 2.35.1 +# one can use the built-in fs-monitor implementation using `git config core.fsmonitor true` + +exit 42 diff --git a/vendor/gix/src/assets/init/hooks/post-update.sample b/vendor/gix/src/assets/init/hooks/post-update.sample new file mode 100755 index 000000000..506a06511 --- /dev/null +++ b/vendor/gix/src/assets/init/hooks/post-update.sample @@ -0,0 +1,12 @@ +#!/bin/sh +# A sample hook that runs after receiving a pack on a remote +############################################################ +# This hook is called after a pack was received on the remote, i.e. after a successful `git push` operation. +# It's useful on the server side only. +# +# There many more receive hooks which are documented in the official documentation: https://git-scm.com/docs/githooks. +# +# To enable this hook remove the `.sample` suffix from this file entirely. + +# Update static files to support the 'dumb' git HTTP protocol. +exec git update-server-info diff --git a/vendor/gix/src/assets/init/hooks/pre-applypatch.sample b/vendor/gix/src/assets/init/hooks/pre-applypatch.sample new file mode 100755 index 000000000..de06c7f7f --- /dev/null +++ b/vendor/gix/src/assets/init/hooks/pre-applypatch.sample @@ -0,0 +1,27 @@ +#!/bin/sh +# A sample hook to check commit messages created by `git am` +########################################################### + +# This hook script is triggered by `git am` without any context just before creating a commit, +# which is useful to inspect the current tree or run scripts for further verification. +# +# If it exits with a non-zero exit code, the commit will not be created. Everything printed +# to the output or error channels will be visible to the user. +# +# Note that there is a sibling hook called `post-applypatch` (also without further context) +# which is run after the commit was created. It is useful to use the commit hash for further +# processing, like sending information to the involved parties. +# Finally, the `applypatch-msg` hook is called at the very beginning of the `git am` operation +# to provide access to the commit-message. +# +# To enable this hook remove the `.sample` suffix from this file entirely. + +# Retrieve the path to the pre-commit hook script using the "git rev-parse" command. +precommit="$(git rev-parse --git-path hooks/pre-commit)" + +# Check if the pre-commit hook script exists and is executable. +# If it does, execute it passing the arguments from this script (if any) using the "exec" command. +test -x "$precommit" && exec "$precommit" ${1+"$@"} + +# Be sure to exit without error if `exec` isn't called. +: diff --git a/vendor/gix/src/assets/init/hooks/pre-commit.sample b/vendor/gix/src/assets/init/hooks/pre-commit.sample new file mode 100755 index 000000000..9d256d4c6 --- /dev/null +++ b/vendor/gix/src/assets/init/hooks/pre-commit.sample @@ -0,0 +1,19 @@ +#!/bin/sh +# A sample hook to prevent commits with merge-markers +##################################################### +# This example hook rejects changes that are about to be committed with merge markers, +# as that would be a clear indication of a failed merge. It is triggered by `git commit` +# and returning with non-zero exit status prevents the commit from being created. +# +# To enable this hook remove the `.sample` suffix from this file entirely. + +# Check for merge markers in modified files +for file in $(git diff --cached --name-only); do + if grep -q -E '^(<<<<<<<|=======|>>>>>>>|\|\|\|\|\|\|\|)$' "$file"; then + echo "Error: File '$file' contains merge markers. Please remove them before committing." + exit 1 + fi +done + +# Exit with success if there are no errors +exit 0 diff --git a/vendor/gix/src/assets/init/hooks/pre-merge-commit.sample b/vendor/gix/src/assets/init/hooks/pre-merge-commit.sample new file mode 100755 index 000000000..0896f5b6f --- /dev/null +++ b/vendor/gix/src/assets/init/hooks/pre-merge-commit.sample @@ -0,0 +1,16 @@ +#!/bin/sh +# A sample hook to check commits created by `git merge` +####################################################### +# +# This hook is invoked by `git merge` without further context right before creating a commit. +# It should be used to validate the current state that is supposed to be committed, or exit +# with a non-zero status to prevent the commit. +# All output will be visible to the user. +# +# To enable this hook remove the `.sample` suffix from this file entirely. + +# Check if the pre-commit hook exists and is executable. If it is, it executes the pre-commit hook script. +test -x "$GIT_DIR/hooks/pre-commit" && exec "$GIT_DIR/hooks/pre-commit" + +# Be sure to exit without error if `exec` isn't called. +: diff --git a/vendor/gix/src/assets/init/hooks/pre-push.sample b/vendor/gix/src/assets/init/hooks/pre-push.sample new file mode 100755 index 000000000..8846fe8a1 --- /dev/null +++ b/vendor/gix/src/assets/init/hooks/pre-push.sample @@ -0,0 +1,46 @@ +#!/bin/sh +# Check for "DELME" in commit messages of about-to-be-pushed commits +#################################################################### +# This hook script is triggered by `git push` right after a connection to the remote +# was established and its initial response was received, and right before generating +# and pushing a pack-file. +# The operation will be aborted when exiting with a non-zero status. +# +# The following arguments are provided: +# +# $1 - The symbolic name of the remote to push to, like "origin" or the URL like "https://github.com/Byron/gitoxide" if there is no such name. +# $2 - The URL of the remote to push to, like "https://github.com/Byron/gitoxide". +# +# The hook should then read from standard input in a line-by-line fashion and split the following space-separated fields: +# +# * local ref - the left side of a ref-spec, i.e. "local" of the "local:refs/heads/remote" ref-spec +# * local hash - the hash of the commit pointed to by `local ref` +# * remote ref - the right side of a ref-spec, i.e. "refs/heads/remote" of the "local:refs/heads/remote" ref-spec +# * remote hash - the hash of the commit pointed to by `remote ref` +# +# In this example, we abort the push if any of the about-to-be-pushed commits have "DELME" in their commit message. +# +# To enable this hook remove the `.sample` suffix from this file entirely. + +remote="$1" +url="$2" + +# Check each commit being pushed +while read _local_ref local_hash _remote_ref _remote_hash; do + # Skip if the local hash is all zeroes (deletion) + zero_sha=$(printf "%0${#local_hash}d" 0) + if [ "$local_hash" = "$zero_sha" ]; then + continue + fi + # Get the commit message + commit_msg=$(git log --format=%s -n 1 "$local_hash") + + # Check if the commit message contains "DELME" + if echo "$commit_msg" | grep -iq "DELME"; then + echo "Error: Found commit with 'DELME' in message. Push aborted to $remote ($url) aborted." 1>&2 + exit 1 + fi +done + +# If no commit with "DELME" found, allow the push +exit 0 diff --git a/vendor/gix/src/assets/init/hooks/pre-rebase.sample b/vendor/gix/src/assets/init/hooks/pre-rebase.sample new file mode 100755 index 000000000..485012068 --- /dev/null +++ b/vendor/gix/src/assets/init/hooks/pre-rebase.sample @@ -0,0 +1,40 @@ +#!/bin/sh +# A sample hook to validate the branches involved in a rebase operation +####################################################################### +# +# This hook is invoked right before `git rebase` starts its work and +# prevents anything else to happen by returning a non-zero exit code. +# +# The following arguments are provided: +# +# $1 - the branch that contains the commit from which $2 was forked. +# $2 - the branch being rebased or no second argument at all if the rebase applies to `HEAD`. +# +# This example hook aborts the rebase operation if the branch being rebased is not up to date +# with the latest changes from the upstream branch, or if there are any uncommitted changes. +# +# To enable this hook remove the `.sample` suffix from this file entirely. + +upstream_branch=$1 +if [ "$#" -eq 2 ]; then + branch_being_rebased=$2 +else + branch_being_rebased=$(git symbolic-ref --quiet --short HEAD) || exit 0 # ignore rebases on detached heads +fi + +# Check if the branch being rebased is behind the upstream branch +if git log --oneline ${upstream_branch}..${branch_being_rebased} > /dev/null; then + echo "Warning: The branch being rebased (${branch_being_rebased}) is behind the upstream branch (${upstream_branch})." 1>&2 + echo "Please update your branch before rebasing." 1>&2 + exit 1 +fi + +# Check if there are any uncommitted changes +if ! git diff-index --quiet HEAD --; then + echo "Warning: There are uncommitted changes in your branch ${branch_being_rebased}." 1>&2 + echo "Please commit or stash your changes before rebasing." 1>&2 + exit 2 +fi + +# All good, let the rebase proceed. +exit 0 diff --git a/vendor/gix/src/assets/init/hooks/prepare-commit-msg.sample b/vendor/gix/src/assets/init/hooks/prepare-commit-msg.sample new file mode 100755 index 000000000..a38ff5a59 --- /dev/null +++ b/vendor/gix/src/assets/init/hooks/prepare-commit-msg.sample @@ -0,0 +1,54 @@ +#!/bin/sh +# A hook called by `git commit` to adjust the commit message right before the user sees it +########################################################################################## +# +# This script is called by `git commit` after commit message was initialized and right before +# an editor is launched. +# +# It receives one to three arguments: +# +# $1 - the path to the file containing the commit message. It can be edited to change the message. +# $2 - the kind of source of the message contained in $1. Possible values are +# "message" - a message was provided via `-m` or `-F` +# "commit" - `-c`, `-C` or `--amend` was given +# "squash" - the `.git/SQUASH_MSG` file exists +# "merge" - this is a merge or the `.git/MERGE` file exists +# "template" - `-t` was provided or `commit.template` was set +# $3 - If $2 is "commit" then this is the hash of the commit. +# It can also take other values, best understood by studying the source code at +# https://github.com/git/git/blob/aa9166bcc0ba654fc21f198a30647ec087f733ed/builtin/commit.c#L745 +# +# The following example +# +# To enable this hook remove the `.sample` suffix from this file entirely. + +COMMIT_MSG_FILE=$1 + +# Check if the commit message file is empty or already contains a message +if [ -s "$COMMIT_MSG_FILE" ]; then + # If the commit message is already provided, exit without making any changes. + # This can happen if the user provided a message via `-m` or a template. + exit 0 +fi + +# Retrieve the branch name from the current HEAD commit +BRANCH_NAME=$(git symbolic-ref --short HEAD) + +# Generate a default commit message based on the branch name +DEFAULT_MSG="" + +case "$BRANCH_NAME" in + "feature/*") + DEFAULT_MSG="feat: " + ;; + "bugfix/*") + DEFAULT_MSG="fix: " + ;; + *) + DEFAULT_MSG="chore: " + ;; +esac + +# Set the commit message that will be presented to the user. +echo "$DEFAULT_MSG" > "$COMMIT_MSG_FILE" + |