Can I have more than one CommitRequirement element under the CommitRequirements element?
I'd like to do something like this but only the first requirement is validated:
<CommitRequirements>
<CommitRequirement Description="Any Text" Regex="\w" FailureMsg="\n\nYou cannot commit code with no comments!\nPlease add a comment indicating what changed."/>
<CommitRequirement Description="TargetProcessID" Regex="#(\d+)" FailureMsg="\n\r\n\rA TargetProcess ID was not specified.\nPlease add a TargetProcess ID in the format "#9999 - User story, task, bug title" to the commit comments" />
</CommitRequirements>
Once the first CommitRequirement passes, the next is ignored.
I'd also like to be able to show a message (example: FailureMessage="") for each CommitRequirement.
I can't see how to do this from the documentation. Is there a way?
Thanks.
Great utility, by the way!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Terry,
You can have more than one CommitRequirement element, however, once one of them is satisfied, the commit does go through. In your example, as you've seen the very lenient case would always pass as long as they put in some comment.
The way I've worked it, is if there are different parts of the repo that have different requirements for the commit pre-check, I've broken down using separate RepoPathConfig elements with different ControlledPaths values. Alternatively, you can use the "SecondaryRegex" check as a "if you have this, then you also need to have that" type of commit message check.
For your second question about a specific failure message per CommitRequirement element, you can use the "RegexFailureMsg" attribute of that element to show a specific message for that check.
I hope this helps and thanks for the kind words on the tool .
Mike
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ahh, thank you. The RegexFailureMsg attribute is not included in the v2.0.7 documentation.
Don't you think that the CommitRequirements should be AND requirements and not OR requirements? If I specify multiple requirements, I expect them all to be met. Hmm..I guess there may be occasions where I may want OR functionality as well....
Either way, I can make it work for my needs right now. When I actually have a scenario that the product doesn't fit, I'll mention it ;)
Thanks again for your efforts. It's a great utility!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Can I have more than one CommitRequirement element under the CommitRequirements element?
I'd like to do something like this but only the first requirement is validated:
<CommitRequirements>
<CommitRequirement Description="Any Text" Regex="\w" FailureMsg="\n\nYou cannot commit code with no comments!\nPlease add a comment indicating what changed."/>
<CommitRequirement Description="TargetProcessID" Regex="#(\d+)" FailureMsg="\n\r\n\rA TargetProcess ID was not specified.\nPlease add a TargetProcess ID in the format "#9999 - User story, task, bug title" to the commit comments" />
</CommitRequirements>
Once the first CommitRequirement passes, the next is ignored.
I'd also like to be able to show a message (example: FailureMessage="") for each CommitRequirement.
I can't see how to do this from the documentation. Is there a way?
Thanks.
Great utility, by the way!
Terry,
You can have more than one CommitRequirement element, however, once one of them is satisfied, the commit does go through. In your example, as you've seen the very lenient case would always pass as long as they put in some comment.
The way I've worked it, is if there are different parts of the repo that have different requirements for the commit pre-check, I've broken down using separate RepoPathConfig elements with different ControlledPaths values. Alternatively, you can use the "SecondaryRegex" check as a "if you have this, then you also need to have that" type of commit message check.
For your second question about a specific failure message per CommitRequirement element, you can use the "RegexFailureMsg" attribute of that element to show a specific message for that check.
I hope this helps and thanks for the kind words on the tool .
Mike
Ahh, thank you. The RegexFailureMsg attribute is not included in the v2.0.7 documentation.
Don't you think that the CommitRequirements should be AND requirements and not OR requirements? If I specify multiple requirements, I expect them all to be met. Hmm..I guess there may be occasions where I may want OR functionality as well....
Either way, I can make it work for my needs right now. When I actually have a scenario that the product doesn't fit, I'll mention it ;)
Thanks again for your efforts. It's a great utility!