beachball
Advanced tools
Comparing version 1.11.1 to 1.11.2
@@ -5,3 +5,17 @@ { | ||
{ | ||
"date": "Wed, 31 Jul 2019 21:59:54 GMT", | ||
"date": "Sat, 03 Aug 2019 03:08:31 GMT", | ||
"tag": "beachball_v1.11.2", | ||
"version": "1.11.2", | ||
"comments": { | ||
"patch": [ | ||
{ | ||
"comment": "Beachball publish should error if git commands fail", | ||
"author": "acoates@microsoft.com", | ||
"commit": "23088348c2c82d9194ed49112a426579e215b935" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"date": "Wed, 31 Jul 2019 22:00:03 GMT", | ||
"tag": "beachball_v1.11.1", | ||
@@ -8,0 +22,0 @@ "version": "1.11.1", |
# Change Log - beachball | ||
This log was last generated on Wed, 31 Jul 2019 21:59:54 GMT and should not be manually modified. | ||
This log was last generated on Sat, 03 Aug 2019 03:08:31 GMT and should not be manually modified. | ||
## 1.11.2 | ||
Sat, 03 Aug 2019 03:08:31 GMT | ||
### Patches | ||
- Beachball publish should error if git commands fail (acoates@microsoft.com) | ||
## 1.11.1 | ||
Wed, 31 Jul 2019 21:59:54 GMT | ||
Wed, 31 Jul 2019 22:00:03 GMT | ||
@@ -8,0 +15,0 @@ ### Patches |
{ | ||
"name": "beachball", | ||
"version": "1.11.1", | ||
"version": "1.11.2", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -26,2 +26,11 @@ import { spawnSync } from 'child_process'; | ||
export function gitFailFast(args: string[], options?: { cwd: string }) { | ||
const gitResult = git(args, options); | ||
if (!gitResult.success) { | ||
console.error(`CRITICAL ERROR: running git command: git ${args.join(' ')}!`); | ||
console.error(gitResult.stderr); | ||
process.exit(1); | ||
} | ||
} | ||
export function getUncommittedChanges(cwd: string) { | ||
@@ -185,2 +194,3 @@ try { | ||
export function getParentBranch(cwd: string) { | ||
@@ -187,0 +197,0 @@ const branchName = getBranchName(cwd); |
import { bump, BumpInfo } from './bump'; | ||
import { CliOptions } from './CliOptions'; | ||
import { git, revertLocalChanges, parseRemoteBranch, getBranchName } from './git'; | ||
import { git, gitFailFast, revertLocalChanges, parseRemoteBranch, getBranchName } from './git'; | ||
import { packagePublish, listPackageVersions } from './packageManager'; | ||
@@ -40,3 +40,3 @@ import prompts from 'prompts'; | ||
const publishBranch = 'publish_' + String(new Date().getTime()); | ||
git(['checkout', '-b', publishBranch]); | ||
gitFailFast(['checkout', '-b', publishBranch]); | ||
@@ -83,3 +83,3 @@ // Step 1. Bump + npm publish | ||
revertLocalChanges(cwd); | ||
git(['fetch', remote], { cwd }); | ||
gitFailFast(['fetch', remote], { cwd }); | ||
const mergeResult = git(['merge', '-X', 'theirs', `${branch}`], { cwd }); | ||
@@ -112,3 +112,10 @@ if (!mergeResult.success) { | ||
console.log('git ' + pushArgs.join(' ')); | ||
git(pushArgs); | ||
const pushResult = git(pushArgs); | ||
if (!pushResult.success) { | ||
console.error(`CRITICAL ERROR: push to ${branch} has failed!`); | ||
console.error(pushResult.stderr); | ||
displayManualRecovery(bumpInfo); | ||
process.exit(1); | ||
} | ||
} | ||
@@ -118,3 +125,3 @@ | ||
console.log(`git checkout ${currentBranch}`); | ||
git(['checkout', currentBranch], { cwd }); | ||
gitFailFast(['checkout', currentBranch], { cwd }); | ||
} | ||
@@ -133,14 +140,30 @@ } | ||
function mergePublishBranch(publishBranch: string, branch: string, message: string, cwd: string) { | ||
git(['add', '.'], { cwd }); | ||
git(['commit', '-m', message], { cwd }); | ||
git(['checkout', branch], { cwd }); | ||
let result = git(['add', '.'], { cwd }); | ||
if (!result.success) { | ||
return result; | ||
} | ||
result = git(['commit', '-m', message], { cwd }); | ||
if (!result.success) { | ||
return result; | ||
} | ||
const mergePublishBranchResult = git(['merge', '-X', 'ours', publishBranch], { cwd }); | ||
if (mergePublishBranchResult.success) { | ||
git(['branch', '-D', publishBranch]); | ||
result = git(['checkout', branch], { cwd }); | ||
if (!result.success) { | ||
return result; | ||
} | ||
return mergePublishBranchResult; | ||
result = git(['merge', '-X', 'ours', publishBranch], { cwd }); | ||
if (!result.success) { | ||
return result; | ||
} | ||
result = git(['branch', '-D', publishBranch]); | ||
return result; | ||
} | ||
function createTag(tag: string, cwd: string) { | ||
gitFailFast(['tag', '-a', '-f', tag, '-m', tag], { cwd }); | ||
} | ||
function tagPackages(bumpInfo: BumpInfo, tag: string, cwd: string) { | ||
@@ -151,3 +174,3 @@ Object.keys(bumpInfo.packageChangeTypes).forEach(pkg => { | ||
const generatedTag = generateTag(packageInfo.name, packageInfo.version); | ||
git(['tag', '-a', generatedTag, '-f', '-m', generatedTag], { cwd }); | ||
createTag(generatedTag, cwd); | ||
}); | ||
@@ -157,3 +180,3 @@ | ||
if (tag !== 'latest') { | ||
git(['tag', '-a', '-f', tag, '-m', tag], { cwd }); | ||
createTag(tag, cwd); | ||
} | ||
@@ -160,0 +183,0 @@ } |
110690
2665