100 days of devops - git hook problem

What did I do wrong here :

Try this solution for the problem; see if it helps.

Does not work
I get the same error

It is not so clear to tell where youโ€™ve made the mistake.
I would advice you to check if youโ€™ve created the hook in the bare repository and also make sure that a tag is created once you push changes.

What do you mean create the hook in de bare repo ?

oke here I do things step by step

  • make the hook file

fill it in the hook

  • solve a problem with git

  • here the outcome of the tests after pushing

and the same error :

When you are pushing itโ€™s not detecting any changes.

Your task failed because the required tag was not created. you didnโ€™t assign the date to the $tag variable and used the wrong hook (post-update).
The correct hook script should be:

#!/bin/bash
tag=$(date +"%Y-%m-%d")
git tag "$tag"

Save it in .git/hooks/post-merge (or post-commit) and make it executable with:

chmod +x .git/hooks/post-merge

After that, the tag will be created automatically on merge/commit.

refer to my repo for solution

also remember to use sudo

@rwobben I see the issue. Itโ€™s with how you are creating the tag.
Git supports two types of tags: lightweight and annotated. check details here

Here you are creating annotated tag which expects user email and name. You could set those values prior to pushing changes to master like:
git config --global user.email "<email_address>"
git config --global user.name "<user_name>".
Once you have these values set your post-update script should work as expected.

If you want a easier approach, you could create a lightweight tag instead.
update your post-update script with the following content and it should work.

#!/bin/bash
TAG=release-$(date '+%Y-%m-%d')
git tag $TAG

all other steps seem fine

  • in your bare repo (origin repo) create post-update file and make it executable
  • in your cloned repo location, switch to master
  • merge feature branch
  • push to origin

Thanks,

Now im almost ready with the solutions till day 36