Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Copilot Lvl 2
Message 1 of 4

How to read latest git commit message using python?

Hi Team,

 

     We need to implement a python script to read the git commit message when the user commits with the following syntax (e.g: ABC-123: + commit message) ABC-123 is the Jira issue Id. And also we need to check Jira issue id is valid in Jira server. Could you please help on how to implement this requirement.

 

Regards,
Hemanth.

3 Replies
Commander Lvl 3
Message 2 of 4

Re: How to read latest git commit message using python?

You could use something like GitPython (https://gitpython.readthedocs.io/en/stable/intro.html)  to extract the commit message and then parse it using RegEx.


- Mark
Copilot Lvl 2
Message 3 of 4

Re: How to read latest git commit message using python?

How do we check for the Jira Id Is Valid during the git push?

Commander Lvl 3
Message 4 of 4

Re: How to read latest git commit message using python?

You can't. You might be able to integrate with the GitHub API to automatically reject checks on a PR that has an invalid name, but you are not able to prevent people from pushing branches with invalid ID's.


- Mark