OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Compare Revisions

Regard whitespace Rev 150 → Rev 151

/trunk/OpenConcerto/src/org/openconcerto/utils/prog/SVNUtils.java
50,20 → 50,23
}
 
// match placeholder $Rev$ fixed length $Rev:: $ and of course with value $Rev: 12 $
private static final Pattern KEYWORD_PATTERN = Pattern.compile("^\\$\\p{Alpha}+:{0,2}\\p{Blank}*(.*?)\\p{Blank}*\\$$");
// don't require to match to the end to allow callers to only know the start of the substitute
// and to not bother with the pattern
private static final Pattern KEYWORD_PATTERN = Pattern.compile("^\\$\\p{Alpha}+:{0,2}\\p{Blank}*(.*?)\\p{Blank}*\\$");
 
/**
* Return the value of the svn keyword. E.g. use with
* Return the value of the subversion keyword. E.g. use with
* <code>private static final String REV = getKeywordValue("$Rev$")</code> (don't forget to
* <code>svn propset svn:keywords</code>).
*
* @param substitute the svn substitute, e.g. "$Rev: 12 $".
* @param substitute the svn substitute, trailing characters not part of the keyword will be
* ignored, e.g. "$Rev: 12 $ other chars".
* @return the value, empty string if none, e.g. "12".
* @throws IllegalArgumentException if substitute is not valid.
*/
public static String getKeywordValue(String substitute) throws IllegalArgumentException {
final Matcher matcher = KEYWORD_PATTERN.matcher(substitute);
if (!matcher.matches())
if (!matcher.find())
throw new IllegalArgumentException("SVN format not recognized");
 
return matcher.group(1);