Skip to content

Instantly share code, notes, and snippets.

@dixudx
Last active April 19, 2021 09:31
Show Gist options
  • Select an option

  • Save dixudx/7d7edea35b4d91e1a2a8fbf41d0954fa to your computer and use it in GitHub Desktop.

Select an option

Save dixudx/7d7edea35b4d91e1a2a8fbf41d0954fa to your computer and use it in GitHub Desktop.

Revisions

  1. dixudx revised this gist Apr 19, 2021. No changes.
  2. dixudx revised this gist Apr 19, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion prepare-commit-msg
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    # usage:
    # run command
    # $ cd your-repo
    # $ wget > .git/hooks/prepare-commit-msg
    # $ curl -Ls https://gist.github.com/dixudx/7d7edea35b4d91e1a2a8fbf41d0954fa/raw/prepare-commit-msg -o .git/hooks/prepare-commit-msg
    # $ chmod +x .git/hooks/prepare-commit-msg

    NAME=$(git config user.name)
  3. dixudx renamed this gist Apr 19, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gistfile1.txt → prepare-commit-msg
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,7 @@
    # run command
    # $ cd your-repo
    # $ wget > .git/hooks/prepare-commit-msg
    # $ chmod +x .git/hooks/prepare-commit-msg

    NAME=$(git config user.name)
    EMAIL=$(git config user.email)
  4. dixudx renamed this gist Apr 19, 2021. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. dixudx created this gist Apr 19, 2021.
    23 changes: 23 additions & 0 deletions prepare-commit-msg
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    #!/bin/sh

    # usage:
    # run command
    # $ cd your-repo
    # $ wget > .git/hooks/prepare-commit-msg

    NAME=$(git config user.name)
    EMAIL=$(git config user.email)

    if [ -z "$NAME" ]; then
    echo "empty git config user.name"
    exit 1
    fi

    if [ -z "$EMAIL" ]; then
    echo "empty git config user.email"
    exit 1
    fi

    git interpret-trailers --if-exists doNothing --trailer \
    "Signed-off-by: $NAME <$EMAIL>" \
    --in-place "$1"