Skip to content

Commit

Permalink
Fix svn add/rm commands for release tool in linux OS (#27886)
Browse files Browse the repository at this point in the history
  • Loading branch information
nosolosw authored Dec 29, 2020
1 parent 9e21f78 commit b084ecd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
19 changes: 17 additions & 2 deletions bin/plugin/commands/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const fs = require( 'fs' );
const semver = require( 'semver' );
const Octokit = require( '@octokit/rest' );
const { sprintf } = require( 'sprintf-js' );
const os = require( 'os' );

/**
* Internal dependencies
Expand Down Expand Up @@ -518,13 +519,27 @@ async function runUpdateTrunkContentStep(
newReadmeFileContent.replace( STABLE_TAG_PLACEHOLDER, stableTag )
);

let xargsOpts = '';
if ( os.platform === 'linux' ) {
// When xargs receives no arguments, it behaves differently in macOS and linux:
// - macOS: doesn't run
// - linux: run without arguments
//
// In linux, the -r option teaches xargs not to run if it receives no arguments.
xargsOpts = '-r';
}

// Commit the content changes
runShellScript(
"svn st | grep '^?' | awk '{print $2}' | xargs svn add",
"svn st | grep '^?' | awk '{print $2}' | xargs " +
xargsOpts +
' svn add',
svnWorkingDirectoryPath
);
runShellScript(
"svn st | grep '^!' | awk '{print $2}' | xargs svn rm",
"svn st | grep '^!' | awk '{print $2}' | xargs " +
xargsOpts +
' svn rm',
svnWorkingDirectoryPath
);
await askForConfirmation(
Expand Down
4 changes: 2 additions & 2 deletions docs/contributors/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ You'll need to use Subversion to publish the plugin to WordPress.org.
6. Add new files/remove deleted files from the repository:
```bash
# Add new files:
svn st | grep '^\?' | awk '{print $2}' | xargs svn add
svn st | grep '^\?' | awk '{print $2}' | xargs svn add # add the -r option to xargs if you use a linux-based OS
# Delete old files:
svn st | grep '^!' | awk '{print $2}' | xargs svn rm
svn st | grep '^!' | awk '{print $2}' | xargs svn rm # add the -r option to xargs if you use a linux-based OS
```
7. Commit the new version:
```bash
Expand Down

0 comments on commit b084ecd

Please sign in to comment.