Skip to content

Commit

Permalink
Updates to improve support for patch releases
Browse files Browse the repository at this point in the history
- prepare-platform-release-branch add options:
  - [-b <platform branch name>]
  - [--js <cordova-js branch or tag name>]

- copy-js add option:
  - [--js <cordova-js branch or tag name>]
  • Loading branch information
Christopher J. Brody committed Jul 6, 2018
1 parent 3e55e28 commit 9368992
Showing 1 changed file with 43 additions and 25 deletions.
68 changes: 43 additions & 25 deletions src/platform-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function * updateCDVAvailabilityFile (version) {
fs.writeFileSync(iosFile, iosFileContents.join('\n'));
}

function * updateJsSnapshot (repo, version, commit) {
function * updateJsSnapshot (repo, version, commit, branch) {
function * ensureJsIsBuilt () {
var cordovaJsRepo = repoutil.getRepoById('js');
if (repo.id === 'blackberry') {
Expand All @@ -139,9 +139,12 @@ function * updateJsSnapshot (repo, version, commit) {
if (hasBuiltJs !== version) {
yield repoutil.forEachRepo([cordovaJsRepo], function * () {
yield gitutil.stashAndPop(cordovaJsRepo, function * () {
// git fetch and update master for cordovajs
yield repoupdate.updateRepos([cordovaJsRepo], ['master'], false);
yield gitutil.gitCheckout('master');
// git fetch and update master (or fetch other branch) for cordova-js
if (branch === 'master') {
yield repoupdate.updateRepos([cordovaJsRepo], [branch], false);
}
yield executil.execHelper(executil.ARGS('git checkout -q ' + branch));
yield gitutil.gitCheckout(branch);
yield executil.execHelper(executil.ARGS('npm install'), false, true); // WORKAROUND PART 1 for local grunt issue in cordova-js
yield executil.execHelper(executil.ARGS('grunt compile:' + repo.id + ' --platformVersion=' + version), false, true);
shelljs.rm('-fr', 'node_modules'); // WORKAROUND PART 2 for local grunt issue in cordova-js
Expand Down Expand Up @@ -177,13 +180,16 @@ exports.createAndCopyCordovaJSCommand = function * () {
' 1. Generates a new cordova.js.\n' +
' 2. Replaces platform\'s cordova.js file.\n' +
'\n' +
'Usage: $0 copy-js -r platform')
'Usage: $0 copy-js -r platform [--js <cordova-js branch or tag name>]')
);

var repos = flagutil.computeReposFromFlag(argv.r);

var jsBranchName = argv.js ? argv.js : 'master';

yield repoutil.forEachRepo(repos, function * (repo) {
var version = yield handleVersion(repo, argv.version, false);
yield updateJsSnapshot(repo, version, false);
yield updateJsSnapshot(repo, version, false, jsBranchName);
});
};

Expand All @@ -199,62 +205,74 @@ exports.prepareReleaseBranchCommand = function * () {
'Command can also be used to update the JS snapshot after release \n' +
'branches have been created.\n' +
'\n' +
'Usage: $0 prepare-platform-release-branch -r platform [--version=3.6.0]')
'Usage: $0 prepare-platform-release-branch -r platform [--version=3.6.0] [-b <platform branch name>] [--js <cordova-js branch or tag name>]')
);

var repos = flagutil.computeReposFromFlag(argv.r);

// XXX TBD ???:
var branchName = null;

var isOtherRepoBranch = !!argv.b;
var repoBranchName = isOtherRepoBranch ? argv.b : 'master';
var jsBranchName = argv.js ? argv.js : 'master';

// First - perform precondition checks.
yield repoupdate.updateRepos(repos, [], true);

yield repoutil.forEachRepo(repos, function * (repo) {
var platform = repo.id;
var version = yield handleVersion(repo, argv.version, true);
var branchName = versionutil.getReleaseBranchNameFromVersion(version);
var releaseBranchName = isOtherRepoBranch ? repoBranchName :
versionutil.getReleaseBranchNameFromVersion(version);

yield gitutil.stashAndPop(repo, function * () {
// git fetch + update master
yield repoupdate.updateRepos([repo], ['master'], false);
yield repoupdate.updateRepos([repo], [repoBranchName], false);

// Either create or pull down the branch.
if (yield gitutil.remoteBranchExists(repo, branchName)) {
if (yield gitutil.remoteBranchExists(repo, releaseBranchName)) {
print('Remote branch already exists for repo: ' + repo.repoName);
// Check out and rebase.
yield repoupdate.updateRepos([repo], [branchName], true);
yield gitutil.gitCheckout(branchName);
} else if (yield gitutil.localBranchExists(branchName)) {
yield executil.execHelper(executil.ARGS('git checkout ' + branchName));
yield repoupdate.updateRepos([repo], [releaseBranchName], true);
yield gitutil.gitCheckout(releaseBranchName);
} else if (yield gitutil.localBranchExists(releaseBranchName)) {
yield executil.execHelper(executil.ARGS('git checkout ' + releaseBranchName));
} else if (isOtherRepoBranch) {
yield executil.execHelper(executil.ARGS('git checkout ' + repoBranchName));
} else {
yield gitutil.gitCheckout('master');
yield executil.execHelper(executil.ARGS('git checkout -b ' + branchName));
yield executil.execHelper(executil.ARGS('git checkout -b ' + releaseBranchName));
}

print(repo.repoName + ': Update JS snapshot version for VERSION "' + version + '" on branch "' + branchName + '".');
yield updateJsSnapshot(repo, version, true);
yield updateJsSnapshot(repo, version, true, jsBranchName);

print(repo.repoName + ': Setting VERSION to "' + version + '" on branch "' + branchName + '".');
yield versionutil.updateRepoVersion(repo, version);

if (platform === 'ios') {
if (platform === 'ios' && /\d$/.test(version)) {
// Updates version in CDVAvailability.h file
print(repo.repoName + ': Update CDVAvailability.h for VERSION to "' + version + '" on branch "' + branchName + '".');
yield updateCDVAvailabilityFile(version);
// Git commit changes
if (yield gitutil.pendingChangesExist()) {
yield executil.execHelper(executil.ARGS('git commit -am', 'Added ' + version + ' to CDVAvailability.h (via coho).'));
}
}

print(repo.repoName + ': Setting VERSION to "' + version + '" on branch "' + releaseBranchName + '".');
yield versionutil.updateRepoVersion(repo, version);

// skip remaining steps for this repo if other repo branch was specified:
if (isOtherRepoBranch) return;

yield gitutil.gitCheckout('master');
var devVersion = createPlatformDevVersion(version);
print(repo.repoName + ': Setting VERSION to "' + devVersion + '" on branch "master".');
yield versionutil.updateRepoVersion(repo, devVersion);
yield updateJsSnapshot(repo, devVersion, true);
yield gitutil.gitCheckout(branchName);
yield updateJsSnapshot(repo, devVersion, true, jsBranchName);
yield gitutil.gitCheckout(releaseBranchName);
});
});
executil.reportGitPushResult(repos, ['master', branchName]);

// XXX TBD ???:
executil.reportGitPushResult(repos, [repoBranchName, branchName]);
};

function * tagJs (repo, version, pretend) {
Expand Down

0 comments on commit 9368992

Please sign in to comment.