![]() ![]() Line 64: when the file name contains any non-alphabetic characters or numerics, the validation fails.Line 62: verify if the file name matches to the pattern.Line 60: the regular expression to accept only letters and numbers is created.Lines 53-57: isolate the file name from path and extension. ![]() Line 51: we are reading the file name in method’s argument.That was easy! As you can see, nothing in this method is exotic or hard to understand. Throw new PreCommitException("The file name must use only letters and numbers " + fileName + " is not valid.") Pattern to accept only letters and numbers It’s not a big challenge, right? Indeed! To do this task we coded the file void validate(String args) throws PreCommitExceptionįileName = fileName.substring((fileName.lastIndexOf("/") + 1), fileName.length()) įileName = fileName.substring(0, fileName.indexOf(".")) The first validation will check if the file name contains only letters and number. A pattern to make it easyįirst things first, we need to prepare the following dependencies in pom.xml: therefore, in case of break of rules, the commit will not be concluded. To achieve this goal we must create two hooks (could be only one, but for educational purposes will be two), which will be executed in pre-commit step. In this case, we want to stop the commit before the bad file turns part of the repository. Also, we need to be sure that no unacceptable word is going to be used in our artefacts contents. Let’s create a hypothetical scenario where we need to validate the name of files submitted by the team. TortoiseSVN 1.9.7+ (or your favourite SVN clients flavour).Microsoft Windows (just because of shell scripts).VisualSVN Server 3.7.1 (including SVN 1.9.7).So, this could be the source of power over all bad artefacts submitted by users and prevent the lack of documentation in your application source code. ![]() SVN hooks can be used for almost everything, but commonly they do notification, validation, or replication over each operation. Each hook will be executed in a specific step of the process start-commit, pre-commit, pre-lock, pre-unlock, post-commit, etc. Despite that as standard installation the application has no way to validate anything committed by users, SVN is very flexible to accept externals applications which are referred as hooks. Apache Subversion (SVN) is one of most popular solution for software versioning and release control. In the How IT of today we create a SVN pre-commit’ hook coded in Java language □įrom small teams to really big teams counting more than 100 heads, the source control is almost mandatory. ![]()
0 Comments
Leave a Reply. |