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

Fix svn add/rm commands for release tool #27886

Merged
merged 3 commits into from
Dec 29, 2020
Merged
Show file tree
Hide file tree
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: 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