Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-16421 - distmaker - Set version in WP zip files #11397

Merged
merged 2 commits into from
Dec 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions distmaker/dists/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,7 @@ function dm_install_drupal() {
# Set full version in .info files. See CRM-15768.
local MODULE_DIRS=`find "$to" -type f -name "*.info"`
for INFO in $MODULE_DIRS; do
if [ $(uname) = "Darwin" ]; then
## BSD sed
sed -i '' "s/version = \([0-9]*\.x-\)[1-9.]*/version = \1$DM_VERSION/g" $INFO
else
## GNU sed
sed -i'' "s/version = \([0-9]*\.x-\)[1-9.]*/version = \1$DM_VERSION/g" $INFO
fi
dm_preg_edit '/version = ([0-9]*\.x)-[1-9.]*/m' "version = \$1-$DM_VERSION" "$INFO"
done

for f in "$to/.gitignore" "$to/.toxic.json" ; do
Expand Down Expand Up @@ -193,6 +187,8 @@ function dm_install_wordpress() {
--exclude=civicrm \
"$repo/./" "$to/./"
## Need --exclude=civicrm for self-building on WP site

dm_preg_edit '/^Version: [0-9\.]+/m' "Version: $DM_VERSION" "$to/civicrm.php"
}


Expand Down Expand Up @@ -239,3 +235,12 @@ function dm_git_checkout() {
git checkout "$2"
popd
}

## Edit a file by applying a regular expression.
## Note: We'd rather just call "sed", but it differs on GNU+BSD.
## usage: dm_preg_edit <search-pattern> <replacement-pattern> <file>
## example: '/version = \([0-9]*\.x-\)[1-9.]*/' 'version = \1$DM_VERSION'
function dm_preg_edit() {
env RPAT="$1" RREPL="$2" RFILE="$3" \
php -r '$c = file_get_contents(getenv("RFILE")); $c = preg_replace(getenv("RPAT"), getenv("RREPL"), $c); file_put_contents(getenv("RFILE"), $c);'
}