Themes pre-commit hook update

Report: https://wordpress.slack.com/archives/C02QB8GMM/p1773343027847289

The themes pre-commit version-check branch is not properly anchored to the Version headerHeader The header of your site is typically the first thing people will experience. The masthead or header art located across the top of your page is part of the look and feel of your website. It can influence a visitor’s opinion about your content and you/ your organization’s brand. It may also look different on different screen sizes., matching Other Version: as well. As a result, it matches https://themes.trac.wordpress.org/browser/blocksy/2.1.35/style.css?marks=15 and fails the commit.

themedropbox can bypass the checks, as it’s targeting direct theme-author SVNSVN Apache Subversion (often abbreviated SVN, after its command name svn) is a software versioning and revision control system. Software developers use Subversion to maintain current and historical versions of files such as source code, web pages, and documentation. Its goal is to be a mostly compatible successor to the widely used Concurrent Versions System (CVS). WordPress core and the wordpress.org released code are all centrally managed through SVN. https://subversion.apache.org/. commits.

(edit: The code is broken here, something is eating characters. See https://gist.github.com/dd32/0902af28065c1e28df4397dcc8efae54 for source)

The Regex on line 118 for STYLECSS_VERSION needs to be changed:

- grep -iEo 'version:.+' | awk -F '[: ]+' '{print $2}'
+ grep -iEo '^[/<em>#@[:blank:]]</em>version:.+' | awk -F ':[\t ]+' '{print $2}'

This matches enough of the get_file_data() regex in core: https://github.com/WordPress/wordpress-develop/blob/202a1f3309de780b826b3d68593698616eeeffd2/src/wp-includes/functions.php#L6976
I don’t see the need to support the pre and post <?php & ?> in there.

If you want full support, this will probably work:

grep -iEo '^([ \t]<em><\?php)?[/</em>#@[:blank:]]<em>version:[[:blank:]]</em>[^[:blank:]]+' | awk -F ':[[:blank:]]*' '{print $2}'

Worst case scenario headers:

<?php //*#    @Version:  1.0.0 ?>
@Other Version: 2.0

(The original regex is Props me)

#prio3 #svn