mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 23:16:26 +00:00
refactor(git): log deleted files (#11561)
This commit is contained in:
parent
9cd9246808
commit
6606e4117b
1 changed files with 15 additions and 13 deletions
|
@ -740,11 +740,20 @@ export async function commitFiles({
|
|||
await git.raw(['clean', '-fd']);
|
||||
await git.checkout(['-B', branchName, 'origin/' + config.currentBranch]);
|
||||
const fileNames: string[] = [];
|
||||
const deleted: string[] = [];
|
||||
const deletedFiles: string[] = [];
|
||||
const ignoredFiles: string[] = [];
|
||||
for (const file of files) {
|
||||
// istanbul ignore if
|
||||
if (file.name === '|delete|') {
|
||||
deleted.push(file.contents as string);
|
||||
const fileName = file.contents as string;
|
||||
try {
|
||||
await git.rm([fileName]);
|
||||
deletedFiles.push(fileName);
|
||||
} catch (err) /* istanbul ignore next */ {
|
||||
checkForPlatformFailure(err);
|
||||
logger.warn({ err, fileName }, 'Cannot delete file');
|
||||
ignoredFiles.push(fileName);
|
||||
}
|
||||
} else if (await isDirectory(join(localDir, file.name))) {
|
||||
fileNames.push(file.name);
|
||||
await gitAdd(file.name);
|
||||
|
@ -767,16 +776,6 @@ export async function commitFiles({
|
|||
if (fileNames.length) {
|
||||
await gitAdd(fileNames);
|
||||
}
|
||||
if (deleted.length) {
|
||||
for (const f of deleted) {
|
||||
try {
|
||||
await git.rm([f]);
|
||||
} catch (err) /* istanbul ignore next */ {
|
||||
checkForPlatformFailure(err);
|
||||
logger.debug({ err }, 'Cannot delete ' + f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const commitOptions: Options = {};
|
||||
if (getNoVerify().includes(GitNoVerifyOption.Commit)) {
|
||||
|
@ -793,7 +792,10 @@ export async function commitFiles({
|
|||
logger.warn({ commitRes }, 'Detected empty commit - aborting git push');
|
||||
return null;
|
||||
}
|
||||
logger.debug({ result: commitRes }, `git commit`);
|
||||
logger.debug(
|
||||
{ deletedFiles, ignoredFiles, result: commitRes },
|
||||
`git commit`
|
||||
);
|
||||
const commit = commitRes?.commit || 'unknown';
|
||||
if (!force && !(await hasDiff(`origin/${branchName}`))) {
|
||||
logger.debug(
|
||||
|
|
Loading…
Reference in a new issue