Skip to content

Commit

Permalink
Merge pull request #2865 from dlang/fix_issue_2691_reboot
Browse files Browse the repository at this point in the history
Properly fix issue #2691 by reverting to the original scanning behavior
  • Loading branch information
Geod24 authored Feb 17, 2024
2 parents fa560ac + ce4b38c commit c0029d0
Show file tree
Hide file tree
Showing 33 changed files with 56 additions and 30 deletions.
51 changes: 31 additions & 20 deletions source/dub/packagemanager.d
Original file line number Diff line number Diff line change
Expand Up @@ -1438,30 +1438,41 @@ package struct Location {
logDebug("iterating dir %s entry %s", path.toNativeString(), pdir.name);
if (!pdir.isDirectory) continue;

// Old / flat directory structure, used in non-standard path
// Packages are stored in $ROOT/$SOMETHING/`
const pack_path = path ~ (pdir.name ~ "/");
auto packageFile = Package.findPackageFile(pack_path);
if (!packageFile.empty) {
// Deprecated unmanaged directory structure
logWarn("Package at path '%s' should be under '%s'",
pack_path.toNativeString().color(Mode.bold),
(pack_path ~ "$VERSION" ~ pdir.name).toNativeString().color(Mode.bold));
logWarn("The package will no longer be detected starting from v1.42.0");
loadInternal(pack_path, packageFile);
}

// Managed structure: $ROOT/$NAME/$VERSION/$NAME
// This is the most common code path
else {
// Iterate over versions of a package
foreach (versdir; mgr.iterateDirectory(pack_path)) {
if (!versdir.isDirectory) continue;
auto vers_path = pack_path ~ versdir.name ~ (pdir.name ~ "/");
if (!mgr.existsDirectory(vers_path)) continue;
packageFile = Package.findPackageFile(vers_path);
loadInternal(vers_path, packageFile);
if (isManaged(path)) {
// Old / flat directory structure, used in non-standard path
// Packages are stored in $ROOT/$SOMETHING/`
if (!packageFile.empty) {
// Deprecated flat managed directory structure
logWarn("Package at path '%s' should be under '%s'",
pack_path.toNativeString().color(Mode.bold),
(pack_path ~ "$VERSION" ~ pdir.name).toNativeString().color(Mode.bold));
logWarn("The package will no longer be detected starting from v1.42.0");
loadInternal(pack_path, packageFile);
} else {
// New managed structure: $ROOT/$NAME/$VERSION/$NAME
// This is the most common code path

// Iterate over versions of a package
foreach (versdir; mgr.iterateDirectory(pack_path)) {
if (!versdir.isDirectory) continue;
auto vers_path = pack_path ~ versdir.name ~ (pdir.name ~ "/");
if (!mgr.existsDirectory(vers_path)) continue;
packageFile = Package.findPackageFile(vers_path);
loadInternal(vers_path, packageFile);
}
}
} else {
// Unmanaged directories (dub add-path) are always stored as a
// flat list of packages, as these are the working copies managed
// by the user. The nested structure should not be supported,
// even optionally, because that would lead to bogus "no package
// file found" errors in case the internal directory structure
// accidentally matches the $NAME/$VERSION/$NAME scheme
if (!packageFile.empty)
loadInternal(pack_path, packageFile);
}
}
catch (Exception e)
Expand Down
8 changes: 4 additions & 4 deletions test/issue1024-selective-upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

. $(dirname "${BASH_SOURCE[0]}")/common.sh
cd ${CURR_DIR}/issue1024-selective-upgrade
echo "{\"fileVersion\": 1,\"versions\": {\"a\": \"1.0.0\", \"b\": \"1.0.0\"}}" > main/~master/main/dub.selections.json
$DUB upgrade --bare --root=main/~master/main/ a
echo "{\"fileVersion\": 1,\"versions\": {\"a\": \"1.0.0\", \"b\": \"1.0.0\"}}" > main/dub.selections.json
$DUB upgrade --bare --root=main a

if ! grep -c -e "\"a\": \"1.0.1\"" main/~master/main/dub.selections.json; then
if ! grep -c -e "\"a\": \"1.0.1\"" main/dub.selections.json; then
die $LINENO "Specified dependency was not upgraded."
fi

if grep -c -e "\"b\": \"1.0.1\"" main/~master/main/dub.selections.json; then
if grep -c -e "\"b\": \"1.0.1\"" main/dub.selections.json; then
die $LINENO "Non-specified dependency got upgraded."
fi
5 changes: 4 additions & 1 deletion test/issue564-invalid-upgrade-dependency.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@

. $(dirname "${BASH_SOURCE[0]}")/common.sh
cd ${CURR_DIR}/issue564-invalid-upgrade-dependency
${DUB} build -f --bare --compiler=${DC} main
rm -rf a-1.0.0/.dub
rm -rf a-1.1.0/.dub
rm -rf main/.dub
${DUB} build --bare --compiler=${DC} main
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"fileVersion": 1,
"versions": {
"a": "1.0.0"
}
}
7 changes: 5 additions & 2 deletions test/issue813-pure-sub-dependency.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@

. $(dirname "${BASH_SOURCE[0]}")/common.sh
cd ${CURR_DIR}/issue813-pure-sub-dependency
rm -f main/~master/main/dub.selections.json
${DUB} build -f --bare --compiler=${DC} main
rm -rf main/.dub
rm -rf sub/.dub
rm -rf sub/sub/.dub
rm -f main/dub.selections.json
${DUB} build --bare --compiler=${DC} main
9 changes: 6 additions & 3 deletions test/issue923-subpackage-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

. $(dirname "${BASH_SOURCE[0]}")/common.sh
cd ${CURR_DIR}/issue923-subpackage-deps
rm -f main/~master/main/dub.selections.json
${DUB} build -f --bare --compiler=${DC} main
rm -rf main/.dub
rm -rf a/.dub
rm -rf b/.dub
rm -f main/dub.selections.json
${DUB} build --bare --compiler=${DC} main


if ! grep -c -e \"b\" main/~master/main/dub.selections.json; then
if ! grep -c -e \"b\" main/dub.selections.json; then
die $LINENO 'Dependency b not resolved.'
fi
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit c0029d0

Please sign in to comment.