mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-16 01:26:24 +00:00
2a4de19c77
Co-Authored-By: Jamie Magee <JamieMagee@users.noreply.github.com>
29 lines
909 B
TypeScript
29 lines
909 B
TypeScript
import { logger } from '../../logger';
|
|
import { RenovateConfig } from '../../config';
|
|
import { platform } from '../../platform';
|
|
|
|
/** TODO: Proper return type */
|
|
export async function prAlreadyExisted(
|
|
config: RenovateConfig
|
|
): Promise<any | null> {
|
|
logger.trace({ config }, 'prAlreadyExisted');
|
|
if (config.recreateClosed) {
|
|
logger.debug('recreateClosed is true');
|
|
return null;
|
|
}
|
|
logger.debug('recreateClosed is false');
|
|
// Return if same PR already existed
|
|
const pr = await platform.findPr(config.branchName, config.prTitle, '!open');
|
|
if (pr) {
|
|
logger.debug('Found closed PR with current title');
|
|
const prDetails = await platform.getPr(pr.number);
|
|
// istanbul ignore if
|
|
if (prDetails.state === 'open') {
|
|
logger.debug('PR reopened');
|
|
throw new Error('repository-changed');
|
|
}
|
|
return pr;
|
|
}
|
|
logger.debug('prAlreadyExisted=false');
|
|
return null;
|
|
}
|