Coder Social home page Coder Social logo

Comments (5)

dantleech avatar dantleech commented on August 30, 2024 1

Empty commiy message (completely deleting ALL content from the file buffer including comments):

======== Execute hook: commit-msg ==============================================

Action: \CaptainHook\App\Hook\Message\Action\Beams
--------------------------------------------------------------------------------
CAPTAINHOOK FOUND 1 PROBLEM IN YOUR COMMIT MESSAGE
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
  Subject line has to start with an upper case letter
--------------------------------------------------------------------------------

In PHP.php line 51:
                                                                               
  Execution failed:                                                            
  Commit message validation failed in /home/daniel/www/dantleech/maestro/vend  
  or/captainhook/captainhook/src/Hook/Message/Action/Book.php line 63          

Having an empty line:

======== Execute hook: commit-msg ==============================================

Action: \CaptainHook\App\Hook\Message\Action\Beams
All rules passed
Aborting commit due to empty commit message.

Just exiting:

======== Execute hook: commit-msg ==============================================

Action: \CaptainHook\App\Hook\Message\Action\Beams
--------------------------------------------------------------------------------
CAPTAINHOOK FOUND 1 PROBLEM IN YOUR COMMIT MESSAGE
--------------------------------------------------------------------------------

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch master
# Your branch is up to date with 'origin/master'.
#
# Changes to be committed:
#       modified:   lib/Task/Task.php
#
# Changes not staged for commit:
#       modified:   captainhook.json
#
# Untracked files:
#       .php_cs.cache
#       .phpunit.result.cache
#       STDERR
#       dot
#       dot.dot
#       example/
#       lsp-client.log
#       maestro.log
#       out
#       out.png
#       out.ps
#       phpactor.log
#       replay.json
#
# ------------------------ >8 ------------------------
# Do not modify or remove the line above.
# Everything below it will be ignored.
diff --git a/lib/Task/Task.php b/lib/Task/Task.php
index 279ba80..d9c6628 100644
--- a/lib/Task/Task.php
+++ b/lib/Task/Task.php
@@ -1,5 +1,6 @@
 <?php
 
+
 namespace Maestro\Task;
 
 interface Task
--------------------------------------------------------------------------------
  Subject line has to start with an upper case letter
--------------------------------------------------------------------------------

In PHP.php line 51:
                                                                               
  Execution failed:                                                            
  Commit message validation failed in /home/daniel/www/dantleech/maestro/vend  
  or/captainhook/captainhook/src/Hook/Message/Action/Book.php line 63          

from captainhook.

dantleech avatar dantleech commented on August 30, 2024

The diff can also cause a false positive on the body length:

--------------------------------------------------------------------------------
  Body lines should not exceed 72 characters
    Line 15 of your body exceeds the max line length
  Subject and body have to be separated by a blank line
--------------------------------------------------------------------------------

from captainhook.

sebastianfeldmann avatar sebastianfeldmann commented on August 30, 2024

Yes the Cap'n removes comment lines from your commit message before validating it.
Since they will be removed by git that's seemed like a reasonable thing to do.

Somehow this line

# ------------------------ >8 ------------------------

makes git ignore all lines below.
I have to check the syntax for this and make the message parser a lot smarter, because right now it thinks that the diff is part of the commit message. That's why it fails.

from captainhook.

sebastianfeldmann avatar sebastianfeldmann commented on August 30, 2024

This is fixed in sebastianfeldmann/git version 2.2.2.
If you run composer update you should get the latest version including the scissors (--- >8 ---) fix.

The odd thing I noticed.
If I use

git commit 
# exit with empty commit message
Aborting commit due to empty commit message.

everything works now.
If I use

git commit -v
# exit with empty message
# the hooks run and fail due to the empty commit message

But if I add a space or an empty line to the commit message it fails like the version without - v.
Can you verify this or is it just my machine?

from captainhook.

sebastianfeldmann avatar sebastianfeldmann commented on August 30, 2024

I don't want to scream "wolf" too fast, but this seems to be a git issue.
If you run git commit -v somehow the commit is not aborted if the message is empty.
But if the message contains a whitespace git will cancel the commit.
Seems strange but so far all experiments confirm my suspicions.

For some reason the commit-message hook gets triggered even if the commit message is empty and the whole commit should be canceled by git.

from captainhook.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.