Skip to content

Examples

Markus Hastreiter edited this page Mar 23, 2019 · 2 revisions

Here a some examples that show common purposes for RepoCop. They should hopefully make it pretty clear and easy to grab the whole concept.

<!-- Enforce log messages with at least 10 characters -->
<FailInstruction Message="Log messages require at least 10 characters.">
  <LogMessageCondition LogMessageRegExPattern=".{10}" Negate="True" />
</FailInstruction>  
<!-- Allow checkin of bmp and png files only with special tag [override ressource rule] in commit log -->
<FailInstruction Message="To ensure that ressources of type *.bmp and *.png are not added by accident the tag [override ressource rule] must be included with the commit message.">
  <Conditions Type="And">
    <LogMessageCondition LogMessageRegExPattern="\[override ressource rule\]" Negate="True" />
    <ChangedPathCondition ChangedPathRegExPattern=".*\.(png|bmp)" Action="Add" />
  </Conditions>
</FailInstruction>
<!-- Locked repo paths -->
<FailInstruction Message="The path /branches/version_1.1 is locked and may no longer be modified.">
  <ChangedPathCondition ChangedPathRegExPattern=".*/branches/version_1\.1.*" />
</FailInstruction>
<!-- Send email reminder to user who modified "ImportantFile.txt" with further instructions -->
<MailInstruction FromMailAddress="svn@mydomain.com" ToMailAddresses="#author#@mydomain.com" Subject="ImportantFile.txt has been changed" BodyTemplateFile="ImportantFileChangedMailBody.txt">
  <ChangedPathCondition ChangedPathRegExPattern=".*/trunk/ImportantFile.txt" />      
</MailInstruction>
<!-- Notify project leader about every change -->
<MailInstruction FromMailAddress="#author#@mydomain.com" ToMailAddresses="projectleader@mydomain.com" Subject="Svn ##revision#" Body="#logmessage#"/>