| Summary: | Create git update and pre-commit hook to prevent Groups.io e-mail in commit messages | ||
|---|---|---|---|
| Product: | [Infrastructure] Infrastructure General | Reporter: | Michael Halstead <mhalstead> |
| Component: | infrastructure-general | Assignee: | Richard Purdie <richard.purdie> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | High | CC: | akuster808, randy.macleod |
| Version: | 3.1 | ||
| Target Milestone: | 3.1 M3 | ||
| Hardware: | x86 | ||
| OS: | Multiple | ||
| Whiteboard: | |||
| OS type for building Yocto: | --- | Type of Regression: | --- |
| Verified: | Documentation change: | Don't know | |
|
Description
Michael Halstead
2019-12-12 17:26:57 UTC
I'm going to try to create these starting with the hooks below. https://raw.githubusercontent.com/asadana/Git-Check-Author/master/pre-commit https://raw.githubusercontent.com/asadana/Git-Check-Author/master/pre-receive I don't know how to get git to reject local commits with incorrect addresses in as the git committer name isn't passed to any of the suitable hooks. I did have more success with the server side blocking. The poky repo now has a pre-receive hook that successfully prevents 'bad' user names from being pushed. Locally the best I've been able to come up with is a post-applypatch which does:
#!/bin/bash
authorName=$(git log -1 --pretty=format:%an HEAD)
if [[ "$authorName" == *"Openembedded-core"* ]]; then
echo "####################################################################"
echo "####################################################################"
echo "Invalid Author $authorName"
echo "####################################################################"
echo "####################################################################"
git reset HEAD~1 --hard
fi
Richard's pre-receive hook is deployed on the OpenEmbeddeded and Yocto Project servers now. When applying patches I'm finding the easiest fix when hitting the warning is to swap the From and Reply-To: headers and git-am will then process the emails correctly. Ultimately I'll script that. I just tried pushing to stable/zeus-nut and got this error. The offending commit is already in mainline zeus. akuster@akuster-ThinkPad-T460s:~/oss/stable/poky$ git push -f ssh://git@git.yoctoproject.org/poky-contrib.git stable/zeus-nut:stable/zeus-nut Counting objects: 399, done. Delta compression using up to 4 threads. Compressing objects: 100% (187/187), done. Writing objects: 100% (399/399), 77.11 KiB | 12.85 MiB/s, done. Total 399 (delta 296), reused 284 (delta 206) remote: Resolving deltas: 100% (296/296), completed with 100 local objects. remote: ############################################## remote: Invalid author Taras Kondratiuk via Openembedded-core remote: ############################################## To ssh://git.yoctoproject.org/poky-contrib.git ! [remote rejected] stable/zeus-nut -> stable/zeus-nut (pre-receive hook declined) Armin, are you confirming this is working as expected or reporting a problem? Separately you need to update your remote to ssh://git@push.yoctoproject.org/poky-contrib.git to ensure reliable pushes in the future. (In reply to comment #7) > Armin, are you confirming this is working as expected or reporting a problem? > > Separately you need to update your remote to > ssh://git@push.yoctoproject.org/poky-contrib.git to ensure reliable pushes > in the future. I reported a problem. Richard fixed it and things are good now. thanks. I think given the hooks installed and updated workflow tweaks people can use we've resolved this as best we can now. |