mirror of https://gitlab.com/basile.b/dexed.git
libman, upstream fix for 82bc48a16a
when the package list is not downloaded use the old method to get ver. + fix: latest tag (=stable) doesn't always match to latest version (beta, alpha...) + fix: source root detection didn't filter obj, a and lib
This commit is contained in:
parent
f9f25f4603
commit
dfd7bbf633
|
|
@ -17,8 +17,8 @@ type
|
||||||
TDubPackageQueryForm = class(TForm)
|
TDubPackageQueryForm = class(TForm)
|
||||||
private
|
private
|
||||||
class var fList: TJSONData;
|
class var fList: TJSONData;
|
||||||
|
class var fGetLatestTag: boolean;
|
||||||
cbb: TComboBox;
|
cbb: TComboBox;
|
||||||
fGetLatestTag: boolean;
|
|
||||||
function getPackageName: string;
|
function getPackageName: string;
|
||||||
function getPackageVersion: string;
|
function getPackageVersion: string;
|
||||||
procedure getList(sender: TObject);
|
procedure getList(sender: TObject);
|
||||||
|
|
@ -231,6 +231,7 @@ begin
|
||||||
bsv.GroupIndex := 1;
|
bsv.GroupIndex := 1;
|
||||||
bsv.Layout:= blGlyphTop;
|
bsv.Layout:= blGlyphTop;
|
||||||
bsv.Spacing:= 2;
|
bsv.Spacing:= 2;
|
||||||
|
bsv.Down:=fGetLatestTag;
|
||||||
AssignPng(bsv, 'TAG_PURPLE');
|
AssignPng(bsv, 'TAG_PURPLE');
|
||||||
|
|
||||||
bww := TBitBtn.Create(self);
|
bww := TBitBtn.Create(self);
|
||||||
|
|
@ -333,13 +334,32 @@ var
|
||||||
jsn: TJSONData;
|
jsn: TJSONData;
|
||||||
begin
|
begin
|
||||||
result := 'master';
|
result := 'master';
|
||||||
if fGetLatestTag and (cbb.ItemIndex <> -1) and
|
if fGetLatestTag then
|
||||||
|
begin
|
||||||
|
// list is updated
|
||||||
|
if fList.isNotNil and (cbb.ItemIndex <> -1) and
|
||||||
cbb.Items.Objects[cbb.ItemIndex].isNotNil then
|
cbb.Items.Objects[cbb.ItemIndex].isNotNil then
|
||||||
try
|
begin
|
||||||
jsn := TJSONData(cbb.Items.Objects[cbb.ItemIndex]);
|
jsn := TJSONData(cbb.Items.Objects[cbb.ItemIndex]);
|
||||||
jsn := jsn.FindPath('version');
|
jsn := jsn.FindPath('version');
|
||||||
result := jsn.AsString;
|
result := jsn.AsString;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
// use API
|
||||||
|
begin
|
||||||
|
with TFPHTTPClient.Create(nil) do
|
||||||
|
try
|
||||||
|
try
|
||||||
|
result := Get('https://code.dlang.org/api/packages/' + packageName + '/latest');
|
||||||
except
|
except
|
||||||
|
result := 'master';
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
if (result.length >= 7) and (result[2] in ['0'..'9']) then
|
||||||
|
result := result[2..result.length-1]
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
@ -351,6 +371,7 @@ begin
|
||||||
try
|
try
|
||||||
jsn := TJSONData(cbb.Items.Objects[cbb.ItemIndex]);
|
jsn := TJSONData(cbb.Items.Objects[cbb.ItemIndex]);
|
||||||
jsn := jsn.FindPath('description');
|
jsn := jsn.FindPath('description');
|
||||||
|
if jsn.isNotNil then
|
||||||
cbb.Hint:= jsn.AsString;
|
cbb.Hint:= jsn.AsString;
|
||||||
except
|
except
|
||||||
end;
|
end;
|
||||||
|
|
@ -420,7 +441,9 @@ begin
|
||||||
dub.Parameters.Add('fetch');
|
dub.Parameters.Add('fetch');
|
||||||
dub.Parameters.Add(nme);
|
dub.Parameters.Add(nme);
|
||||||
if ver = 'master' then
|
if ver = 'master' then
|
||||||
dub.Parameters.Add('--version=~master');
|
dub.Parameters.Add('--version=~master')
|
||||||
|
else
|
||||||
|
dub.Parameters.Add('--version=' + ver);
|
||||||
dub.Execute;
|
dub.Execute;
|
||||||
while dub.Running do sleep(10);
|
while dub.Running do sleep(10);
|
||||||
err := dub.ExitStatus;
|
err := dub.ExitStatus;
|
||||||
|
|
@ -832,60 +855,61 @@ function TCELibManEditorWidget.sourceRoot(project: ICECommonProject): string;
|
||||||
var
|
var
|
||||||
i, j: integer;
|
i, j: integer;
|
||||||
mnme: string;
|
mnme: string;
|
||||||
fold: string;
|
path: string;
|
||||||
modn: TStringList;
|
|
||||||
modf: TStringList;
|
|
||||||
toks: TLexTokenList;
|
|
||||||
base: string;
|
base: string;
|
||||||
|
lst: TStringList;
|
||||||
|
srcc: TStringList;
|
||||||
|
toks: TLexTokenList;
|
||||||
begin
|
begin
|
||||||
base := project.basePath;
|
|
||||||
|
|
||||||
// 1 source, same folder
|
// 1 source, same folder
|
||||||
if project.sourcesCount = 1 then
|
if project.sourcesCount = 1 then
|
||||||
begin
|
begin
|
||||||
mnme := project.sourceAbsolute(0);
|
base := project.basePath;
|
||||||
if mnme.extractFilePath = base then
|
path := project.sourceAbsolute(0);
|
||||||
|
if path.extractFilePath = base then
|
||||||
exit(base);
|
exit(base);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
modn := TStringList.Create;
|
lst := TStringList.Create;
|
||||||
modf := TStringList.Create;
|
srcc := TStringList.Create;
|
||||||
toks := TLexTokenList.Create;
|
toks := TLexTokenList.Create;
|
||||||
|
lst.Duplicates:= dupIgnore;
|
||||||
try
|
try
|
||||||
// get module name and store the parent.parent.parent... dir
|
// get module name and store the parent.parent.parent... dir
|
||||||
for i := 0 to project.sourcesCount-1 do
|
for i := 0 to project.sourcesCount-1 do
|
||||||
begin
|
begin
|
||||||
fModStart := false;
|
path := project.sourceAbsolute(i);
|
||||||
fold := project.sourceAbsolute(i);
|
if not hasDlangSyntax(path.extractFileExt) then
|
||||||
modf.LoadFromFile(fold);
|
|
||||||
lex(modf.Text, toks, @lexFindToken, [lxoNoComments]);
|
|
||||||
mnme := getModuleName(toks);
|
|
||||||
for j := 0 to WordCount(mnme, ['.'])-1 do
|
|
||||||
fold := extractFileDir(fold);
|
|
||||||
modn.Add(fold);
|
|
||||||
toks.Clear;
|
|
||||||
end;
|
|
||||||
result := modn[0];
|
|
||||||
// no error possible if 1 module
|
|
||||||
if project.sourcesCount > 1 then
|
|
||||||
begin
|
|
||||||
for i := 1 to modn.Count-1 do
|
|
||||||
begin
|
|
||||||
// expect same folder
|
|
||||||
if modn[i] = modn[i-1] then
|
|
||||||
continue;
|
continue;
|
||||||
// if not use common directory.
|
fModStart := false;
|
||||||
modf.Clear;
|
srcc.LoadFromFile(path);
|
||||||
for j := 0 to project.sourcesCount-1 do
|
lex(srcc.Text, toks, @lexFindToken, [lxoNoComments]);
|
||||||
modf.Add(project.sourceAbsolute(j));
|
mnme := getModuleName(toks);
|
||||||
result := commonFolder(modf);
|
toks.Clear;
|
||||||
result := result.extractFileDir;
|
for j := 0 to WordCount(mnme, ['.'])-1 do
|
||||||
break;
|
path := path.extractFileDir;
|
||||||
|
lst.Add(path);
|
||||||
end;
|
end;
|
||||||
|
if project.sourcesCount = 0 then
|
||||||
|
result := ''
|
||||||
|
else
|
||||||
|
result := lst[0];
|
||||||
|
if (project.sourcesCount > 1) and (lst.Count > 1) then
|
||||||
|
begin
|
||||||
|
lst.Clear;
|
||||||
|
for j := 0 to project.sourcesCount-1 do
|
||||||
|
begin
|
||||||
|
path := project.sourceAbsolute(j);
|
||||||
|
if hasDlangSyntax(path.extractFileExt) then
|
||||||
|
lst.Add(path);
|
||||||
|
end;
|
||||||
|
result := commonFolder(lst);
|
||||||
|
result := result.extractFileDir;
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
modf.Free;
|
srcc.Free;
|
||||||
modn.Free;
|
lst.Free;
|
||||||
toks.Free;
|
toks.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue