Comments (10)
Fixed and released with version 5.18.3
Thanks for reporting it :)
from captainhook.
Thank you for the quick fix
from captainhook.
I found the issue, it was actually my fault, i have put it under "commit-msg" instead of "prepare-commit-msg". Somehow the application did not throw any errors + even recognized it as a valid action under "commit-msg" and even composed the correct message :D
from captainhook.
I will have a look and see if I can reproduce the issue.
from captainhook.
Ok I found the issue.
The default commit message templates includes a lot of comment lines.
Within those comment lines the branch name is present.
The action checks if the issue key is already in the prepared commit messages and if so it does nothing.
The problem being that I'm not making a difference between comment lins and actual message text.
In the new version I'll release in a bit (still thinking about some edge cases) this should be fixed.
from captainhook.
I have looked it up again, either the error is now from my side or there are still issues.
For debug: i did this in the InjectIssueKEyFromranch.php
file:
echo var_dump($this->createNewCommitMessage($options, $msg, $issueID));
and output was again correct but somehow again githu did not recognize
from captainhook.
Are you committing via an external tool like PHPStorm or Kraken, or on the terminal?
from captainhook.
How it should work.
- The captain prepare commit message hook is triggered.
- In case you provide a message via -m or use for example PHPStorm to commit. The message you provided will be used.
- In case no message is provided git will load a default commit message from a template.
- A file with your commit message is created
.git/COMMIT_EDITMSG
- The Cap'n reads that file and appends the issue key and writes the new version back to disk
- Only if you are on the terminal and you did not provide a
-m
option the.git/COMMIT_EDITMSG
file is loaded into your default editor (vi vim nano...) - If you close the editor
git
uses the file to create the final commit message
If you use PHPStorm or the -m
option you will never see the added issue number while committing. You should see it using git log
though.
If you run git commit
in your terminal you should see the added issueID in your editor.
from captainhook.
I tested it via git commit now (without -m) and got exactly the same results as i have done with -m.
- The echo var dump at line 80 i wrote printed the wanted commit message but github still somehow did not adapt (got git log)
from captainhook.
It works on my machine :/
Here is my prepare-commit-msg
config
"prepare-commit-msg": {
"enabled": true,
"actions": [
{
"action": "\\CaptainHook\\App\\Hook\\Message\\Action\\InjectIssueKeyFromBranch",
"options": {
"regex": "#([A-Z]+\\-[0-9]+)#i",
"into": "body",
"mode": "append",
"prefix": "\nissue: ",
"force": false
}
}
]
}
I'm on branch feature/captain-12345
git commit -m"My Commit Message"
pre-commit:
- \CaptainHook\App\Hook\PHP\Action\Linting : done
- \CaptainHook\App\Hook\File\Action\DoesNotContainRegex : done
- \CaptainHook\App\Hook\File\Action\IsNotEmpty : done
- Max size check : done
- tools/phpunit --no-coverage --testsuite UnitTests : done
- tools/phpcs --colors --standard=psr12 {$STAGED_FILES|of-type:p... : skipped
- \CaptainHook\App\Hook\Composer\Action\CheckLockFile : done
prepare-commit-msg:
- \CaptainHook\App\Hook\Message\Action\InjectIssueKeyFromBranch : done
- \CaptainHook\App\Hook\Message\Action\PrepareFromFile : done
commit-msg:
- Verify commit message format : done
- Fake regex validation : done
- Store commit message on failure : done
post-commit:
- hook is disabled
[feature/captain-12345 038612e] My Commit Message
1 file changed, 2 insertions(+)
Then my git log looks like this
git log HEAD^..HEAD
commit 038612e1cce66898fd544f0da09667446a4ed900 (HEAD -> feature/captain-12345)
Author: Sebastian Feldmann <[email protected]>
Date: Sat Nov 11 17:33:53 2023 +0100
My Commit Message
issue: captain-12345
How do you execute the Captain
? Locally installed PHP or a Docker container?
from captainhook.
Related Issues (20)
- Support for Relative Path to CaptainHook Executable in Generated Hooks HOT 5
- Allow Staged and Changed files condition to define diff-filter HOT 1
- PHP Fatal error: Argument #2 ($filter) must be of type array HOT 7
- http://captainhook.info is not available anymore? HOT 1
- Support Symfony 7 HOT 2
- $CHANGED_FILES placeholder is empty for first push HOT 1
- [FEATURE-REQUEST] New placeholder `ALL_CHANGED_FILES` HOT 17
- Docker mode not working? HOT 9
- Linting fails when it shouldn't? HOT 3
- Default config file does not work HOT 3
- Error 'The "--input" option does not exist' when rerunning the hooks HOT 1
- captainhook/captainhook-phar failing, prefer captainhook/captainhook in README HOT 3
- Running Hooks in Subrepositories fails HOT 10
- Execute PHAR hook installation without an autoloader HOT 9
- [Feature] Parallel execution of actions HOT 1
- [Bug?] Pre-push hook failing with ddev/docker HOT 4
- Installation not working behind a proxy
- Install fails with a missing class HOT 13
- Hello HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from captainhook.