For the task (details below). I made a copy of the post-update.sample file and name as post-update.
The post-update file content (details below). I executed manually to see if it will create a tag and it did. Then checkout master branch (git checkout master) and merge the feature branch (git merge feature) at the end I push all my changes (git push --all).
I get the below error and I have no idea why.
seems like ‘post-update’ hook is not working
FAILED git_hooks.py::test_git_hooks - AssertionError: - seems like 'post-upda…
Task details
The Nautilus application development team was working on a git repository /opt/blog.git which is cloned under /usr/src/kodekloudrepos directory present on Storage server in Stratos DC. The team want to setup a hook on this repository, please find below more details:
Merge the feature branch into the master branch`, but before pushing your changes complete below point.
Create a post-update hook in this git repository so that whenever any changes are pushed to the master branch, it creates a release tag with name release-2023-06-15, where 2023-06-15 is supposed to be the current date. For example if today is 20th June, 2023 then the release tag must be release-2023-06-20. Make sure you test the hook at least once and create a release tag for today’s release.
Hi @tsanghan
Thank you for your respond. I set up my git hooks on the cloned repo /usr/src/kodekloudrepos and I should set it up in the bare repo /opt/blog.git.
I have this hook set up in remote repo location. /opt/ecommerce.git/
cat post-update
#!/bin/bash
Get the current date
DATE=$(date +“%Y-%m-%d”)
Create the release tag
exec git tag “release-$DATE”
exec git push origin “release-$DATE”
but still i dont see push triggering commit and creating tag.
I am seeing this error message.
seems like release tag was not created from the ‘master’ branch
what did you do it differently ?
The Nautilus application development team was working
on a git repository /opt/media.git which is cloned under
/usr/src/kodekloudrepos directory present on Storage server
in Stratos DC. The team want to setup a hook on this repository,
please find below more details:
Merge the feature branch into the master branch`, but before
pushing your changes complete below point.
Create a post-update hook in this git repository so that whenever
any changes are pushed to the master branch, it creates a release
tag with name release-2023-06-15, where 2023-06-15 is supposed to
be the current date. For example if today is 20th June, 2023 then the
release tag must be release-2023-06-20. Make sure you test the hook
at least once and create a release tag for today's release.
Finally remember to push your changes.
I did the following and even confirmed that the tag exists in the bare repo. I don’t know why I keep getting marked wrong. Please I need help.
[root@ststor01 hooks]# chmod +x post-update
[root@ststor01 hooks]# cd /usr/src/kodekloudrepos/media/
[root@ststor01 media]# git branch
* feature
master
[root@ststor01 media]# git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
[root@ststor01 media]# git merge origin master
merge: origin - not something we can merge
[root@ststor01 media]# git merge feature
Updating 241846a..ed2b928
Fast-forward
feature.txt | 1 +
1 file changed, 1 insertion(+)
create mode 100644 feature.txt
[root@ststor01 media]# git push origin master
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Creating tag release-2025-08-10
To /opt/media.git
241846a..ed2b928 master -> master
[root@ststor01 media]#
content of my post-update file, if that helps:
[root@ststor01 media]# cat /opt/media.git/hooks/post-update
#!/usr/bin/sh
# Arguments to post-update
DATE=$(date +%F) # YYYY-MM-DD
GIT_DIR=$(pwd)
for ref in "$@"
do
if [ "$ref" = "refs/heads/master" ]; then
echo "Creating tag release-$DATE"
git --git-dir="$GIT_DIR" tag -f "release-$DATE" master
fi
done