The Nautilus application development team was working on a git repository /opt/demo.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.
Login into storage server and move into directory
sudo -i
cd /usr/src/kodekloudrepos/demo
Find the current branch and switch into master branch
git branch
git switch master
Merge the feature branch
git merge feature
Add the script in hooks
cp /opt/demo.git/hooks/post-update.sample /opt/demo.git/hooks/post-update
chmod +x /opt/demo.git/hooks/post-update
Update script to push tags
vi /opt/demo.git/hooks/post-update
Add these lines
day=$(date +"%Y-%m-%d")
TAG="release-$day"
git tag -a $TAG -m "Released at: $day"
Finally, push the changes
git push
It will add a new tags and push it
We can verify using these commands:
git fetch --tags
git tag
.git/hooks/ directory