Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commit message appends comment output of hooks/prepare-commit-msg #213

Open
raabf opened this issue Sep 12, 2017 · 0 comments
Open

Commit message appends comment output of hooks/prepare-commit-msg #213

raabf opened this issue Sep 12, 2017 · 0 comments

Comments

@raabf
Copy link

raabf commented Sep 12, 2017

Brief

Commit messages of automated comments appends the full output of .git/hooks/prepare-commit-msg including comment lines, which must be ignored.

Observed behaviour

Blackbox sometimes do automated comments, such as when files are added/removed to blackbox.

.git/hooks/prepare-commit-msg is a script which modifies the commit message file before it is opened with the users configured editor when just git commit is called.

In my case I append the last five commit messages to remember what I have done before when writing the current message, therefore .git/hooks/prepare-commit-msg is in my case:

#!/bin/bash
# shows last 5 commit messages as comment when doing a commit
BRANCH_NAME=$(git branch | grep '*' | sed 's/* //')
if [ $BRANCH_NAME != '(no branch)' ]; then
    echo "#" >> $1
    echo "# Last 5 commit messages" >> $1
    echo "# ----------------------" >> $1
    COMMITS=`git log --pretty=format:"# %h %s [%an]" -5`
    echo "${COMMITS}" >> $1
 fi

.git/hooks/prepare-commit-msg is allowed to add lines which are then later part of the commit message, but all lines in commit message file starting with a # (comment lines) must be ignored.

For some reason the automated blackbox comments include the entire output of .git/hooks/prepare-commit-msg, also comment lines!

Such a comment message created by blackbox here when removing the file foo.txt, then looks like:

Author:     Fabian Raab <fabian@raab.link>
AuthorDate: Mon Sep 11 21:45:27 2017 +0200
Commit:     Fabian Raab <fabian@raab.link>
CommitDate: Mon Sep 11 21:45:27 2017 +0200

    Removing from blackbox: foo.txt
    #
    # Last 5 commit messages
    # ----------------------
    # ce7d0e7 registered in blackbox: foo.txt # # Last 5 commit mess
    # 713d8cd NEW ADMIN: fabian@raab.link # # Last 5 commit messages
    # edad623 INITIALIZE BLACKBOX # # Last 5 commit messages # -----
    # 21604d5 fooo [Fabian Raab]
    # 063f19a fooo [Fabian Raab]

Expected behaviour

blackbox must fulfil the rules of git hooks and the commit message file. That the hooks are called, also for blackbox automated commits, is correct and non-comment lines must part of the commit message, but all comment lines must be ignored.

Tested with current blackbox master (commit 0626efa) on a Linux machine and git 2.7.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant