Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: only update lock files if necessary #13462

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions lib/workers/branch/get-updated.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,33 @@ describe('workers/branch/get-updated', () => {
],
});
});

it('reuse branch when update artifacts on update-lockfile strategy with no updateLockedDependency', async () => {
config.upgrades.push({
packageFile: 'pyproject.toml',
manager: 'poetry',
branchName: undefined,
isLockfileUpdate: true,
});
poetry.updateArtifacts.mockResolvedValueOnce([
{
file: {
type: 'addition',
path: 'poetry.lock',
contents: 'some contents',
},
},
]);
git.getFile.mockResolvedValueOnce('some contents');
const res = await getUpdatedPackageFiles(config);
expect(res).toEqual({
artifactErrors: [],
reuseExistingBranch: undefined,
updatedArtifacts: [],
updatedPackageFiles: [],
});
});

it('attempts updateLockedDependency and handles unsupported', async () => {
config.upgrades.push({
packageFile: 'package.json',
Expand Down
15 changes: 13 additions & 2 deletions lib/workers/branch/get-updated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,16 +264,27 @@ export async function getUpdatedPackageFiles(
config,
});
if (is.nonEmptyArray(results)) {
updatedPackageFiles.push(packageFile);
let updated = false;
for (const res of results) {
const { file, artifactError } = res;
// istanbul ignore else
if (file) {
if (
file?.type === 'addition' &&
file.contents !== '' && // only check if artifact is non-empty --> ignore git-submodule artifacts
(await getFile(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think we get into trouble when the file is the gradle wrapper jar. Which is binary.

file.path,
reuseExistingBranch ? config.branchName : config.baseBranch
)) !== file.contents.toString() // convert to string if defined as buffer
) {
updatedArtifacts.push(file);
updated = true;
} else if (artifactError) {
artifactErrors.push(artifactError);
}
}
if (updated) {
updatedPackageFiles.push(packageFile);
}
}
}
}
Expand Down