Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9079777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:54:58+00:00 2026-06-16T19:54:58+00:00

I want to restrict the people whoever commits to have a specific commit message

  • 0

I want to restrict the people whoever commits to have a specific commit message format, how do I do that?

For example: Pair_Name|Story_Number|Commit_Message

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T19:55:00+00:00Added an answer on June 16, 2026 at 7:55 pm

    There is a pre-commit-msg or commit-msg hook, that you could use:

    • http://www.kernel.org/pub/software/scm/git/docs/githooks.html

    Git repos come with sample hooks, e.g. the sample commit-msg hook under git/hooks/commit-msg.sample catches duplicate Signed-off-by lines.

    # This example catches duplicate Signed-off-by lines.
    
    test "" = "$(grep '^Signed-off-by: ' "$1" |
        sort | uniq -c | sed -e '/^[   ]*1[    ]/d')" || {
        echo >&2 Duplicate Signed-off-by lines.
        exit 1
    }
    

    To enable a hook, don’t forget to make it executable.


     

    Here’s some fictional example, which would only accept commit messages of the london|120|something ... and the like:

    #!/usr/bin/env ruby
    message_file = ARGV[0]
    message = File.read(message_file)
    
    # $regex = /\[ref: (\d+)\]/
    
    PAIRS = ["london", "paris", "moscow"] # only these names allowed
    STORIES = "\d{2,4}"                   # story must be a 2, 3 or 4 digit number
    MESSAGE = ".{5,}"                     # message must be at least 5 chars long
    
    $regex = "( (#{PAIRS.join('|')})\|#{STORIES}\|#{MESSAGE} )"
    
    if !$regex.match(message)
      puts "[POLICY] Your message is not formatted correctly"
      exit 1
    end
    

    In usage:

    $ git ci -m "berlin|120"
    [POLICY] Your message is not formatted correctly
    $ git ci -m "london|120|XX"    
    [POLICY] Your message is not formatted correctly
    $ git ci -m "london|120|Looks good."    
    [master 853e622] london|120|Looks good.
     1 file changed, 1 insertion(+)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a server application that we want to restrict non-users from triggerring it
I want to restrict my web app so that .txt files can not be
If I have a model with a ManyToManyField and I want to restrict it
My backend is PHP I have a service that I want to put out
I want to restrict special numbers for input, so far I have restricted just
I want to restrict video and photo displays per session. For example, visitor watches
I want to restrict few file types format and allow all others in regular
I want to restrict user input so that a provided N obeys N >0
I have a PHP page that allows people to run htpasswd to update their
I want to restrict creating object using default constructor. Because I have a desing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.