mirror of https://gitlab.com/basile.b/dexed.git
fix #118 - add support for the new DUB package naming scheme
This commit is contained in:
parent
63fff3f001
commit
bd2a5d16df
|
@ -30,6 +30,7 @@ type
|
||||||
strict private
|
strict private
|
||||||
fName : string;
|
fName : string;
|
||||||
fVersions: TSemVerList;
|
fVersions: TSemVerList;
|
||||||
|
fNewNamingScheme: boolean;
|
||||||
public
|
public
|
||||||
constructor create;
|
constructor create;
|
||||||
destructor destroy; override;
|
destructor destroy; override;
|
||||||
|
@ -38,6 +39,7 @@ type
|
||||||
function highestInInterval(constref lo, hi: TSemVer): PSemVer;
|
function highestInInterval(constref lo, hi: TSemVer): PSemVer;
|
||||||
function highest: PSemVer;
|
function highest: PSemVer;
|
||||||
property name: string read fName write fName;
|
property name: string read fName write fName;
|
||||||
|
property newNamingScheme: boolean read fNewNamingScheme write fNewNamingScheme;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TDubLocalPackages = class
|
TDubLocalPackages = class
|
||||||
|
@ -359,10 +361,12 @@ begin
|
||||||
begin
|
begin
|
||||||
v := fVersions[i]^;
|
v := fVersions[i]^;
|
||||||
if v < lo then
|
if v < lo then
|
||||||
continue;
|
continue
|
||||||
if v < hi then
|
else if (v > lo) or (v = lo) then
|
||||||
result := fVersions[i];
|
result := fVersions[i]
|
||||||
if v > hi then
|
else if (v < hi) and ((assigned(result) and (v > result^)) or (not assigned(result))) then
|
||||||
|
result := fVersions[i]
|
||||||
|
else if v > hi then
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -395,6 +399,23 @@ begin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TDubLocalPackages.update;
|
class procedure TDubLocalPackages.update;
|
||||||
|
|
||||||
|
procedure addPackageOrVersion(name, semVer: string; newNamingScheme: Boolean);
|
||||||
|
var
|
||||||
|
d: PDubLocalPackage = nil;
|
||||||
|
begin
|
||||||
|
if not find(name, d) then
|
||||||
|
begin
|
||||||
|
setLength(fLocalPackages, length(fLocalPackages) + 1);
|
||||||
|
fLocalPackages[high(fLocalPackages)] := TDubLocalPackage.create;
|
||||||
|
d := @fLocalPackages[high(fLocalPackages)];
|
||||||
|
d^.name := name;
|
||||||
|
d^.newNamingScheme := newNamingScheme;
|
||||||
|
end;
|
||||||
|
d^.addVersion(semVer);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
var
|
var
|
||||||
p: TStringList;
|
p: TStringList;
|
||||||
r: TStringList;
|
r: TStringList;
|
||||||
|
@ -404,9 +425,10 @@ var
|
||||||
i: integer;
|
i: integer;
|
||||||
j: integer = 0;
|
j: integer = 0;
|
||||||
k: integer;
|
k: integer;
|
||||||
d: PDubLocalPackage = nil;
|
|
||||||
h: TStringRange = (ptr: nil; pos: 0; len: 0);
|
h: TStringRange = (ptr: nil; pos: 0; len: 0);
|
||||||
x: string;
|
x: string;
|
||||||
|
u: TStringList;
|
||||||
|
g: string;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
|
||||||
|
@ -441,6 +463,23 @@ begin
|
||||||
j := 0;
|
j := 0;
|
||||||
s := p[i];
|
s := p[i];
|
||||||
h.init(s);
|
h.init(s);
|
||||||
|
// after 2.104 <cachePath>/<package>/<version>/<package>
|
||||||
|
// new naming scheme can be distinguished because '.' is not a legal char in a package name
|
||||||
|
v := s.extractFileName;
|
||||||
|
if (Pos('.', v) < 1) and (Pos('master', v) < 1) then
|
||||||
|
begin
|
||||||
|
u := TStringList.Create;
|
||||||
|
try
|
||||||
|
listFolders(u, s + DirectorySeparator);
|
||||||
|
for g in u do
|
||||||
|
addPackageOrVersion(v, 'v' + g.extractFileName, true);
|
||||||
|
finally
|
||||||
|
u.free;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
// before 2.104 <cachePath>/<package>-<version>/<package>
|
||||||
|
else
|
||||||
|
begin
|
||||||
while true do
|
while true do
|
||||||
begin
|
begin
|
||||||
h.popUntil('-');
|
h.popUntil('-');
|
||||||
|
@ -453,21 +492,13 @@ begin
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if j.equals(0) then
|
if not j.equals(0) then
|
||||||
continue;
|
begin
|
||||||
|
|
||||||
n := s[1..j-1];
|
n := s[1..j-1];
|
||||||
n := n.extractFileName;
|
n := n.extractFileName;
|
||||||
if not find(n, d) then
|
addPackageOrVersion(n, 'v' + s[j+1 .. length(s)], false);
|
||||||
begin
|
end;
|
||||||
setLength(fLocalPackages, length(fLocalPackages) + 1);
|
|
||||||
fLocalPackages[high(fLocalPackages)] := TDubLocalPackage.create;
|
|
||||||
d := @fLocalPackages[high(fLocalPackages)];
|
|
||||||
d^.name := n;
|
|
||||||
end;
|
end;
|
||||||
v := 'v' + s[j+1 .. length(s)];
|
|
||||||
d^.addVersion(v);
|
|
||||||
|
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
p.Free;
|
p.Free;
|
||||||
|
@ -509,7 +540,6 @@ begin
|
||||||
hi.patch := 0;
|
hi.patch := 0;
|
||||||
hi.additional :='';
|
hi.additional :='';
|
||||||
result := package^.highestInInterval(opVer, hi);
|
result := package^.highestInInterval(opVer, hi);
|
||||||
result := result;
|
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else if op = '=' then
|
else if op = '=' then
|
||||||
|
@ -1743,14 +1773,18 @@ procedure TDubProject.updateImportPathsFromJson;
|
||||||
begin
|
begin
|
||||||
s := b[k] + n;
|
s := b[k] + n;
|
||||||
p := s + '-' + u^.asString + DirectorySeparator + n + DirectorySeparator;
|
p := s + '-' + u^.asString + DirectorySeparator + n + DirectorySeparator;
|
||||||
// e.g vibe-d:http -> <registrypath>/vibed-<sember>/http
|
// new naming scheme
|
||||||
|
if not p.dirExists then
|
||||||
|
p := s + DirectorySeparator + u^.asString + DirectorySeparator + n + DirectorySeparator;
|
||||||
|
// e.g vibe-d:http -> <registrypath>/vibed/<semver>/vibed/http
|
||||||
|
// e.g ae:sys-wininet -> <registrypath>/ae/<semver>/ae/sys/wininet
|
||||||
if length(w) <> 0 then
|
if length(w) <> 0 then
|
||||||
p += w;
|
p += strutils.ReplaceText(w, '-', DirectorySeparator);
|
||||||
if not p.dirExists then
|
if not p.dirExists then
|
||||||
continue;
|
continue;
|
||||||
if (p + 'source').dirExists then
|
if (p + 'source').dirExists then
|
||||||
begin
|
begin
|
||||||
fImportPaths.Add(p + 'source') ;
|
fImportPaths.Add(p + 'source');
|
||||||
break;
|
break;
|
||||||
end
|
end
|
||||||
else if (p + 'src').dirExists then
|
else if (p + 'src').dirExists then
|
||||||
|
|
Loading…
Reference in New Issue