logs: branch/branchName

This commit is contained in:
Rhys Arkins 2018-09-24 11:47:49 +02:00
parent 56ee66381b
commit 08cf55e81f
7 changed files with 30 additions and 21 deletions

View file

@ -230,7 +230,10 @@ async function getBranchStatus(branchName, requiredStatusChecks) {
);
const noOfFailures = statuses.filter(status => status.state === 'FAILED')
.length;
logger.debug({ branchName, sha, statuses }, 'branch status check result');
logger.debug(
{ branch: branchName, sha, statuses },
'branch status check result'
);
if (noOfFailures) {
return 'failed';
}

View file

@ -422,7 +422,7 @@ function mergeBranch(branchName) {
// istanbul ignore if
if (config.pushProtection) {
logger.info(
{ branchName },
{ branch: branchName },
'Branch protection: Attempting to merge branch when push protection is enabled'
);
}
@ -504,7 +504,7 @@ async function setBranchStatus(
if (existingStatus === state) {
return;
}
logger.info({ branchName, context, state }, 'Setting branch status');
logger.info({ branch: branchName, context, state }, 'Setting branch status');
const branchCommit = await config.storage.getBranchCommit(branchName);
const url = `repos/${config.repository}/statuses/${branchCommit}`;
const options = {
@ -836,7 +836,7 @@ async function createPr(
`repos/${config.parentRepo || config.repository}/pulls`,
options
)).body;
logger.debug({ branchName, pr: pr.number }, 'PR created');
logger.debug({ branch: branchName, pr: pr.number }, 'PR created');
pr.displayNumber = `Pull Request #${pr.number}`;
pr.branchName = branchName;
await addLabels(pr.number, labels);
@ -1200,7 +1200,7 @@ async function mergePr(prNo, branchName) {
// istanbul ignore if
if (config.pushProtection) {
logger.info(
{ branchName, prNo },
{ branch: branchName, prNo },
'Branch protection: Cannot automerge PR when push protection is enabled'
);
return false;
@ -1208,7 +1208,7 @@ async function mergePr(prNo, branchName) {
// istanbul ignore if
if (config.prReviewsRequired) {
logger.debug(
{ branchName, prNo },
{ branch: branchName, prNo },
'Branch protection: Attempting to merge PR when PR reviews are enabled'
);
const repository = config.parentRepo || config.repository;
@ -1216,7 +1216,7 @@ async function mergePr(prNo, branchName) {
const isApproved = reviews.body.some(review => review.state === 'APPROVED');
if (!isApproved) {
logger.info(
{ branchName, prNo },
{ branch: branchName, prNo },
'Branch protection: Cannot automerge PR until there is an approving review'
);
return false;

View file

@ -148,9 +148,12 @@ class Storage {
);
} catch (err) /* istanbul ignore next */ {
if (err.message.startsWith('Reference does not exist')) {
logger.info({ branchName }, 'Branch to delete does not exist');
logger.info(
{ branch: branchName },
'Branch to delete does not exist'
);
} else {
logger.warn({ err, branchName }, 'Error deleting branch');
logger.warn({ err, branch: branchName }, 'Error deleting branch');
}
}
}
@ -167,7 +170,7 @@ class Storage {
};
try {
await get.patch(url, options);
logger.debug({ branchName }, 'Branch merged');
logger.debug({ branch: branchName }, 'Branch merged');
} catch (err) {
logger.info({ err }, `Error pushing branch merge for ${branchName}`);
throw new Error('Branch automerge failed');
@ -205,7 +208,7 @@ class Storage {
} catch (error) {
if (error.statusCode === 404) {
// If file not found, then return null JSON
logger.info({ filePath, branchName }, 'getFile 404');
logger.info({ filePath, branch: branchName }, 'getFile 404');
return null;
}
if (
@ -281,11 +284,11 @@ class Storage {
try {
if (isBranchExisting) {
await updateBranch(branchName, commit);
logger.debug({ branchName }, 'Branch updated');
logger.debug({ branch: branchName }, 'Branch updated');
return 'updated';
}
await createBranch(branchName, commit);
logger.info({ branchName }, 'Branch created');
logger.info({ branch: branchName }, 'Branch created');
return 'created';
} catch (err) /* istanbul ignore next */ {
logger.debug({
@ -324,7 +327,7 @@ class Storage {
await deleteBranch(blockingBranch);
}
}
logger.debug({ options, branchName }, 'Creating branch');
logger.debug({ options, branch: branchName }, 'Creating branch');
await get.post(`repos/${config.repository}/git/refs`, options);
branchList.push(branchName);
logger.debug('Created branch');

View file

@ -19,7 +19,7 @@ async function tryBranchAutomerge(config) {
logger.debug(`Automerging branch`);
try {
await platform.mergeBranch(config.branchName);
logger.info({ branchName: config.branchName }, 'Branch automerged');
logger.info({ branch: config.branchName }, 'Branch automerged');
return 'automerged'; // Branch no longer exists
} catch (err) {
logger.info({ err }, `Failed to automerge branch`);

View file

@ -19,7 +19,7 @@ async function commitFilesToBranch(config) {
config.parentBranch || config.baseBranch || undefined
);
if (res) {
logger.info({ branchName: config.branchName }, `Branch ${res}`);
logger.info({ branch: config.branchName }, `Branch ${res}`);
}
} else {
logger.debug(`No files to commit`);

View file

@ -218,7 +218,7 @@ async function ensurePr(prConfig) {
);
return existingPr;
}
logger.debug({ branchName, prTitle }, `Creating PR`);
logger.debug({ branch: branchName, prTitle }, `Creating PR`);
// istanbul ignore if
if (config.updateType === 'rollback') {
logger.warn('Creating Rollback PR');
@ -233,16 +233,19 @@ async function ensurePr(prConfig) {
false,
config.statusCheckVerify
);
logger.info({ branchName, pr: pr.number }, 'PR created');
logger.info({ branch: branchName, pr: pr.number }, 'PR created');
} catch (err) {
logger.warn({ err }, `Failed to create PR`);
if (err.message === 'Validation Failed (422)') {
logger.info({ branchName }, 'Deleting invalid branch');
logger.info({ branch: branchName }, 'Deleting invalid branch');
await platform.deleteBranch(branchName);
}
// istanbul ignore if
if (err.statusCode === 502) {
logger.info({ branchName }, 'Deleting branch due to server error');
logger.info(
{ branch: branchName },
'Deleting branch due to server error'
);
await platform.deleteBranch(branchName);
}
return null;

View file

@ -21,7 +21,7 @@ async function getOnboardingConfig(config) {
renovateJson.labels = [String(label).replace('greenkeeper', 'renovate')];
}
if (branchName) {
logger.info({ branchName }, 'Migrating Greenkeeper branchName');
logger.info({ branch: branchName }, 'Migrating Greenkeeper branchName');
renovateJson.branchName = [
String(branchName).replace('greenkeeper', 'renovate'),
];