Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Commit Message check in Push Check

Hello,

I am try to control commit messages by enforcing developers to use particular JIRA ID in their commit message, but when I go to Hooks in settings and then push check plugin. The push is getting rejected as  the  commit message is not matching the given regular expression.

I want to commit message to have G1990 in it.

Can someone help me in this?

 

 

BB_Error.PNG

2 answers

1 accepted

0 votes
Answer accepted

Hi Sumit,

I guess you have to use .*G1990.* .

It is not contains check, it is must match check. So when we give (G1990) as regex, the commit which have only G1990 as message will be accepted and other commits will be rejected even when we added single character.

 

On the other hand, .*G1990.* , allow all the commits which contains G1990, because .(dot) means any character and *(asterisk) means anytime. Basically we are telling that commit message can have any char at n number of times before and after G1990.

 

Please let me know, if my answer helps you.

Thank you for your response Allen. I tried it below is the screenshot attached showing the errorBB_Error.PNG.

@Sumit , use .*G1990.* instead of *.G1990.*.

 

For more clear,

dot*G1990dot* (replace dot with .)

my bad. i tried to push it with commit messages, it gave me below error.

git commit -m "G1990"

git commit -m "G1990 Testing"

 

remote: [Syntax check]
remote: rejected. pls include Jira #

! [remote rejected] (pre-receive hook declined)

I guess, you have few more previous commits which is not matching.

 

Please run hg out or git log --branches --not --remotes=origin this command and make sure you have only one commit with "G1990 Testing" as message.

It worked, as a charm. Thank you so much Allen for your help.

Like Barry Allen likes this

Hello there,

 

you can also require commits to be associated with Jira issues using a simple shell script and external hooks add-on, check it there — example 

Thanks for the info.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Powering DevOps with Bitbucket Server & Data Center

Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster   ! While we’re all excited about the new improvements to Bitbucket ...

1,926 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you