fix(commits): handle failing git command correctly and show meaningful error
Closes #83
This commit is contained in:
		
							parent
							
								
									a3f561d1d1
								
							
						
					
					
						commit
						cb3992595e
					
				| @ -12,10 +12,11 @@ module.exports = function ({lastRelease, options}, cb) { | ||||
|   if (!from) return extract() | ||||
| 
 | ||||
|   exec(`git branch --contains ${from}`, (err, stdout) => { | ||||
|     if (err) return cb(err) | ||||
|     let inHistory = false | ||||
|     let branches | ||||
| 
 | ||||
|     const branches = stdout.split('\n') | ||||
|     if (!err && stdout) { | ||||
|       branches = stdout.split('\n') | ||||
|       .map((result) => { | ||||
|         if (branch === result.replace('*', '').trim()) { | ||||
|           inHistory = true | ||||
| @ -24,15 +25,14 @@ module.exports = function ({lastRelease, options}, cb) { | ||||
|         return result.trim() | ||||
|       }) | ||||
|       .filter(branch => !!branch) | ||||
|     } | ||||
| 
 | ||||
|     if (!inHistory) { | ||||
|       log.error('commits', | ||||
| `The commit the last release of this package was derived from is no longer
 | ||||
| in the direct history of the "${branch}" branch. | ||||
| `The commit the last release of this package was derived from is not in the direct history of the "${branch}" branch.
 | ||||
| This means semantic-release can not extract the commits between now and then. | ||||
| This is usually caused by force pushing or releasing from an unrelated branch. | ||||
| You can recover from this error by publishing manually or restoring | ||||
| the commit "${from}".` + (branches.length ?
 | ||||
| This is usually caused by force pushing, releasing from an unrelated branch, or using an already existing package name. | ||||
| You can recover from this error by publishing manually or restoring the commit "${from}".` + (branches && branches.length ?
 | ||||
|         `\nHere is a list of branches that still contain the commit in question: \n * ${branches.join('\n * ')}` : | ||||
|         '' | ||||
|       )) | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user