Skip to content

Commit

Permalink
Merge pull request civicrm#11397 from totten/master-wpver
Browse files Browse the repository at this point in the history
CRM-16241 - distmaker - Set version in WP zip files
  • Loading branch information
colemanw authored and sluc23 committed Jan 10, 2018
2 parents 5f1baf5 + f971546 commit 8c0a10d
Showing 1 changed file with 12 additions and 7 deletions.
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);'
}

0 comments on commit 8c0a10d

Please sign in to comment.