Skip to content

Commit

Permalink
Fix Gradle 5 lockfiles not overriding manifests (#1462)
Browse files Browse the repository at this point in the history
This fixes an issue where Gradle 5 lockfiles would not override manifest
files in the same directory since the lockfiles themselves are stored in
a subdirectory.
  • Loading branch information
cd-work authored Jun 27, 2024
1 parent 979ee4b commit 4509464
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## Unreleased

### Fixed

- Gradle 5 lockfiles not overriding manifest files in the same project

## 6.6.3 - 2024-06-26

### Fixed
Expand Down
11 changes: 10 additions & 1 deletion lockfile/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,16 @@ pub fn find_depfiles_at(root: impl AsRef<Path>) -> Vec<(PathBuf, LockfileFormat)
// the manifest.
let mut lockfile_dirs =
depfiles.lockfiles.iter().filter_map(|(path, format)| Some((path.parent()?, format)));
remove |= lockfile_dirs.any(|(lockfile_dir, lockfile_format)| {
remove |= lockfile_dirs.any(|(mut lockfile_dir, lockfile_format)| {
// Gradle 5 lockfiles are in a subdirectory, so we truncate these directories to
// get the effective directory these lockfiles were created for.
let dir_str = lockfile_dir.to_string_lossy();
if lockfile_format == &LockfileFormat::Gradle
&& dir_str.ends_with("/gradle/dependency-locks")
{
lockfile_dir = lockfile_dir.parent().unwrap().parent().unwrap();
}

lockfile_format.parser().is_path_manifest(manifest_path)
&& manifest_path.starts_with(lockfile_dir)
});
Expand Down

0 comments on commit 4509464

Please sign in to comment.