Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function mergeReleaseIntoBranch (branchName) {
console.log(`Merging release branch into ${branchName}.`)
let mergeArgs = ['merge', 'release', '--squash']
let mergeDetails = await GitProcess.exec(mergeArgs, gitDir)
if (mergeDetails.exitCode === 0) {
return true
} else {
const error = GitProcess.parseError(mergeDetails.stderr)
if (error === GitError.MergeConflicts) {
console.log(`${fail} Could not merge release branch into ${branchName} ` +
`due to merge conflicts.`)
return false
} else {
console.log(`${fail} Could not merge release branch into ${branchName} ` +
`due to an error: ${mergeDetails.stderr}.`)
process.exit(1)
}
}
}
export async function merge(
repository: Repository,
branch: string
): Promise {
const { exitCode, stdout } = await git(
['merge', branch],
repository.path,
'merge',
{
expectedErrors: new Set([GitError.MergeConflicts]),
}
)
if (exitCode === 0 && stdout !== noopMergeMessage) {
return true
} else {
return false
}
}
const e = asErrorWithMetadata(error)
if (!e) {
return error
}
const gitError = asGitError(e.underlyingError)
if (!gitError) {
return error
}
const dugiteError = gitError.result.gitError
if (!dugiteError) {
return error
}
if (dugiteError !== DugiteError.MergeConflicts) {
return error
}
const { repository, gitContext } = e.metadata
if (repository == null) {
return error
}
if (!(repository instanceof Repository)) {
return error
}
if (gitContext == null) {
return error
}
switch (error) {
case DugiteError.SSHKeyAuditUnverified:
return 'The SSH key is unverified.'
case DugiteError.SSHAuthenticationFailed:
case DugiteError.SSHPermissionDenied:
case DugiteError.HTTPSAuthenticationFailed:
return `Authentication failed. You may not have permission to access the repository or the repository may have been archived. Open ${
__DARWIN__ ? 'preferences' : 'options'
} and verify that you're signed in with an account that has permission to access this repository.`
case DugiteError.RemoteDisconnection:
return 'The remote disconnected. Check your Internet connection and try again.'
case DugiteError.HostDown:
return 'The host is down. Check your Internet connection and try again.'
case DugiteError.RebaseConflicts:
return 'We found some conflicts while trying to rebase. Please resolve the conflicts before continuing.'
case DugiteError.MergeConflicts:
return 'We found some conflicts while trying to merge. Please resolve the conflicts and commit the changes.'
case DugiteError.HTTPSRepositoryNotFound:
case DugiteError.SSHRepositoryNotFound:
return 'The repository does not seem to exist anymore. You may not have access, or it may have been deleted or renamed.'
case DugiteError.PushNotFastForward:
return 'The repository has been updated since you last pulled. Try pulling before pushing.'
case DugiteError.BranchDeletionFailed:
return 'Could not delete the branch. It was probably already deleted.'
case DugiteError.DefaultBranchDeletionFailed:
return `The branch is the repository's default branch and cannot be deleted.`
case DugiteError.RevertConflicts:
return 'To finish reverting, please merge and commit the changes.'
case DugiteError.EmptyRebasePatch:
return 'There aren’t any changes left to apply.'
case DugiteError.NoMatchingRemoteBranch:
return 'There aren’t any remote branches that match the current branch.'