How to get commit message in gitlab server side pre-receive hooks

I am trying to develop a server side pre-receive hook on gitlab. where I should get the commit message from the new commits which are getting added.

I tried using the git log --pretty=%B -n 1 . This is returning the old committed message. How can I get the commit message form the new unaccepted changes ?

When I tried to get the refname or argument in to the script it did not hold any values. (thinking that might be of help)

echo $ref_name
echo $ref_name
echo "refname"
issue=`git log --pretty=%B -n 1`
echo $issue #this is printing old commit message


Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 306 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: refname