Skip to content

Commit

Permalink
More gitlab improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
LongDirtyAnimAlf committed Jul 21, 2021
1 parent 38c47eb commit 3095eca
Show file tree
Hide file tree
Showing 12 changed files with 374 additions and 157 deletions.
20 changes: 11 additions & 9 deletions fpcup.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
; ... and you can define your own, like below:

[fpcupinfo]
inifileversion=1.1.8.52
inifileversion=1.1.8.58

[ALIASfpcURL]
stable=https://svn.freepascal.org/svn/fpc/tags/release_3_2_2
Expand Down Expand Up @@ -133,8 +133,8 @@ fixes1.4=https://svn.freepascal.org/svn/lazarus/branches/fixes_1_4
0.9.4=https://svn.freepascal.org/svn/lazarus/tags/lazarus_0_9_4

[ALIASfpcTAG]
trunk=main
stable=release_3_2_2
3.2.3=svn/fixes_3_2
3.2.2=release_3_2_2
3.2.0=release_3_2_0
3.0.4=release_3_0_4
Expand All @@ -156,14 +156,13 @@ stable=release_3_2_2
2.0.0=release_2_0_0

[ALIASlazTAG]
trunk=trunk
stable=lazarus_2_0_12
2.3.0=trunk
2.3=trunk-2_3
fixes=fixes-2_2
fixes2.2=fixes-2_2
fixes2.0=fixes-2_0
2.0.13=fixes-2_0
; 2.3.0=trunk
; 2.3=trunk-2_3
; fixes=fixes-2_2
; fixes2.2=fixes-2_2
; fixes2.0=fixes-2_0
; 2.0.13=fixes-2_0
2.0.12=lazarus_2_0_12
2.0.10=lazarus_2_0_10
2.0.8=lazarus_2_0_8
Expand Down Expand Up @@ -202,12 +201,15 @@ fixes2.0=fixes-2_0

[ALIASfpcBRANCH]
trunk=main
2.2.0=svn/fixes_3_2
2.0.13=svn/fixes_3_0
fixes=svn/fixes_3_2
fixes3.2=svn/fixes_3_2
fixes3.0=svn/fixes_3_0

[ALIASlazBRANCH]
trunk=trunk
2.3.0=trunk
fixes=fixes_2_2
fixes2.2=fixes_2_2
fixes2.0=fixes_2_0
Expand Down
9 changes: 9 additions & 0 deletions fpcupdefines.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{.$define FORCELAZBUILD}
{.$define DISABLELAZBUILDJOBS}

{.$define crosssimple}

{$ifdef WINDOWS}
{.$define buildnative}
{$endif WINDOWS}

Binary file modified fpcupdeluxe.res
Binary file not shown.
87 changes: 56 additions & 31 deletions fpcupdeluxemainform.pas
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ implementation

//{$I message.inc}

function NaturalCompare(aList: TStringList; aIndex1, aIndex2: Integer): Integer;
begin
Result := NaturalCompareText(aList[aIndex2], aList[aIndex1]);
end;

procedure TSynEditHelper.SetFiltered(line: string);
begin
Expand Down Expand Up @@ -3952,8 +3956,8 @@ procedure TForm1.PrepareRun;
FPCupManager.FPCDesiredRevision:='';
FPCupManager.LazarusDesiredRevision:='';

FPCupManager.FPCDesiredBranch:='';
FPCupManager.LazarusDesiredBranch:='';
FPCupManager.FPCBranch:='';
FPCupManager.LazarusBranch:='';

FPCupManager.FPCTag:='';
FPCupManager.LazarusTag:='';
Expand Down Expand Up @@ -4090,29 +4094,29 @@ function TForm1.RealRun:boolean;
FPCupManager.LazarusURL:=LazarusTarget;

// for https://github.com/graemeg (FPC/Lazarus mirrors of GitHub) ... always get the right branch
if (Pos('github.com/graemeg',FPCupManager.FPCURL)>0) then FPCupManager.FPCDesiredBranch:='master';
if (Pos('github.com/graemeg',FPCupManager.LazarusURL)>0) then FPCupManager.LazarusDesiredBranch:='upstream';
if (Pos('github.com/graemeg',FPCupManager.FPCURL)>0) then FPCupManager.FPCBranch:='master';
if (Pos('github.com/graemeg',FPCupManager.LazarusURL)>0) then FPCupManager.LazarusBranch:='upstream';

// for https://github.com/newpascal (FPC/Lazarus NP mirrors of GitHub) ... always get the right branch
if (Pos('github.com/newpascal',FPCupManager.FPCURL)>0) then FPCupManager.FPCDesiredBranch:='release';
if (Pos('github.com/newpascal',FPCupManager.LazarusURL)>0) then FPCupManager.LazarusDesiredBranch:='release';
//if (Pos('github.com/newpascal',FPCupManager.FPCURL>0) then FPCupManager.FPCDesiredBranch:='freepascal';
//if (Pos('github.com/newpascal',FPCupManager.LazarusURL)>0) then FPCupManager.LazarusDesiredBranch:='lazarus';
if (Pos('github.com/LongDirtyAnimAlf',FPCupManager.FPCURL)>0) then FPCupManager.FPCDesiredBranch:='master';
if (Pos('github.com/LongDirtyAnimAlf',FPCupManager.LazarusURL)>0) then FPCupManager.LazarusDesiredBranch:='upstream';
if (Pos('github.com/LongDirtyAnimAlf/lazarussource',FPCupManager.LazarusURL)>0) then FPCupManager.LazarusDesiredBranch:='master';
if (Pos('github.com/newpascal',FPCupManager.FPCURL)>0) then FPCupManager.FPCBranch:='release';
if (Pos('github.com/newpascal',FPCupManager.LazarusURL)>0) then FPCupManager.LazarusBranch:='release';
//if (Pos('github.com/newpascal',FPCupManager.FPCURL>0) then FPCupManager.FPCBranch:='freepascal';
//if (Pos('github.com/newpascal',FPCupManager.LazarusURL)>0) then FPCupManager.LazarusBranch:='lazarus';
if (Pos('github.com/LongDirtyAnimAlf',FPCupManager.FPCURL)>0) then FPCupManager.FPCBranch:='master';
if (Pos('github.com/LongDirtyAnimAlf',FPCupManager.LazarusURL)>0) then FPCupManager.LazarusBranch:='upstream';
if (Pos('github.com/LongDirtyAnimAlf/lazarussource',FPCupManager.LazarusURL)>0) then FPCupManager.LazarusBranch:='master';
end;

// branch and revision overrides from setup+
s:=Form2.FPCRevision;
if Length(s)>0 then FPCupManager.FPCDesiredRevision:=s;
s:=Form2.FPCBranch;
if Length(s)>0 then FPCupManager.FPCDesiredBranch:=s;
if Length(s)>0 then FPCupManager.FPCBranch:=s;

s:=Form2.LazarusRevision;
if Length(s)>0 then FPCupManager.LazarusDesiredRevision:=s;
s:=Form2.LazarusBranch;
if Length(s)>0 then FPCupManager.LazarusDesiredBranch:=s;
if Length(s)>0 then FPCupManager.LazarusBranch:=s;

// overrides for old versions of Lazarus
aLazarusVersion:=CalculateNumericalVersion(LazarusTarget);
Expand Down Expand Up @@ -4855,34 +4859,57 @@ procedure TForm1.SetCmdFontSize(aValue:integer);
procedure TForm1.FillSourceListboxes;
var
aFPCKeyword,aLazarusKeyword:string;
aList:TStringList;
i:integer;
begin
if (ListBoxFPCTarget.SelCount=1)
then aFPCKeyword:=ListBoxFPCTarget.GetSelectedText
else
aFPCKeyword:=FPCTarget;

ListBoxFPCTarget.Items.Clear;
if ListBoxFPCTarget.Count=0 then
begin
if chkGitlab.Checked then
ListBoxFPCTarget.Items.CommaText:=installerUniversal.GetAlias('fpcTAG','list')
else
ListBoxFPCTarget.Items.CommaText:=installerUniversal.GetAlias('fpcURL','list');
end;

if (ListBoxLazarusTarget.SelCount=1)
then aLazarusKeyword:=ListBoxLazarusTarget.GetSelectedText
else
aLazarusKeyword:=LazarusTarget;

ListBoxLazarusTarget.Items.Clear;
if ListBoxLazarusTarget.Count=0 then
begin
if chkGitlab.Checked then
ListBoxLazarusTarget.Items.CommaText:=installerUniversal.GetAlias('lazTAG','list')
else
ListBoxLazarusTarget.Items.CommaText:=installerUniversal.GetAlias('lazURL','list');
aList:=TStringList.Create;
try
aList.Clear;

ListBoxFPCTarget.Items.BeginUpdate;
ListBoxFPCTarget.Items.Clear;
if ListBoxFPCTarget.Count=0 then
begin
if chkGitlab.Checked then
begin
aList.CommaText:=installerUniversal.GetAlias('fpcTAG','list')+','+installerUniversal.GetAlias('fpcBRANCH','list');
end
else
aList.CommaText:=installerUniversal.GetAlias('fpcURL','list');
if chkGitlab.Checked then aList.CustomSort(@NaturalCompare);
ListBoxFPCTarget.Items.AddStrings(aList);
end;
ListBoxFPCTarget.Items.EndUpdate;

aList.Clear;

ListBoxLazarusTarget.Items.BeginUpdate;
ListBoxLazarusTarget.Items.Clear;
if ListBoxLazarusTarget.Count=0 then
begin
if chkGitlab.Checked then
begin
aList.CommaText:=installerUniversal.GetAlias('lazTAG','list')+','+installerUniversal.GetAlias('lazBRANCH','list');
end
else
aList.CommaText:=installerUniversal.GetAlias('lazURL','list');
if chkGitlab.Checked then aList.CustomSort(@NaturalCompare);
ListBoxLazarusTarget.Items.AddStrings(aList);
end;
ListBoxLazarusTarget.Items.EndUpdate;

finally
aList.Free;
end;

if ((Length(aFPCKeyword)>0) AND (ListBoxFPCTarget.Items.Count>0)) then
Expand All @@ -4898,9 +4925,7 @@ procedure TForm1.FillSourceListboxes;
if (i<>-1) then
LazarusTarget:=aLazarusKeyword;
end;

end;


end.

2 changes: 2 additions & 0 deletions fpcuputil.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1287,6 +1287,7 @@ function CompilerRevision(CompilerPath: string): string;
if Length(Output)>0 then
begin
i:=Pos('-r',Output);
if (i=0) then i:=Pos('-',Output);
if (i>0) then
begin
Delete(Output,1,i+1);
Expand Down Expand Up @@ -2226,6 +2227,7 @@ function GetGitLabTags(aURL:string;taglist:TStringList):boolean;
begin
result:=false;
if RunCommand('git',['ls-remote','--tags','--sort=-refname',aURL,'refs/tags/release*'], Output,[poUsePipes, poStderrToOutPut]{$IF DEFINED(FPC_FULLVERSION) AND (FPC_FULLVERSION >= 30200)}{$IF DEFINED(FPC_FULLVERSION) AND (FPC_FULLVERSION >= 30200)},swoHide{$ENDIF}{$ENDIF}) then
//if RunCommand('git',['ls-remote','--tags','--abbrev=0','--sort=-refname',aURL], Output,[poUsePipes, poStderrToOutPut]{$IF DEFINED(FPC_FULLVERSION) AND (FPC_FULLVERSION >= 30200)}{$IF DEFINED(FPC_FULLVERSION) AND (FPC_FULLVERSION >= 30200)},swoHide{$ENDIF}{$ENDIF}) then
begin
if (Output<>'') then
begin
Expand Down
44 changes: 43 additions & 1 deletion gitclient.pas
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ TGitClient = class(TRepoClient)
implementation

uses
Process,
StrUtils,
installerCore,
processutils,
Expand Down Expand Up @@ -330,7 +331,11 @@ procedure TGitClient.Update;
var
Command: string;
Output: string = '';
Tags: string = '';
bSwitch: boolean;
aCurrentTag,aCurrentBranch:string;
aNewTag,aNewBranch:string;
i:integer;
begin
FReturnCode := 0;
if ExportOnly then exit;
Expand All @@ -340,9 +345,29 @@ procedure TGitClient.Update;
FLocalRevision := FRET_UNKNOWN_REVISION;
bSwitch:=false;

{
//FReturnCode := TInstaller(Parent).ExecuteCommandInDir(FRepoExecutable,['tag'], LocalRepository, Tags, '', Verbose);
FReturnCode := TInstaller(Parent).ExecuteCommandInDir(FRepoExecutable,['show','--no-color','--oneline','-s'], LocalRepository, Output, '', Verbose);
//FReturnCode := TInstaller(Parent).ExecuteCommand(FRepoExecutable,['show','--no-color','--oneline','-s',LocalRepository], Output, Verbose);
//RunCommandInDir(LocalRepository,FRepoExecutable,['show','--no-color','--oneline','-s'], Output,FReturnCode,[poUsePipes, poStderrToOutPut]{$IF DEFINED(FPC_FULLVERSION) AND (FPC_FULLVERSION >= 30200)},swoHide{$ENDIF});
if FReturnCode = 0 then
begin
i:=Pos('tag: ',Output);
if (i>0) then
begin
aCurrentTag:=Copy(Output,i+5,MaxInt);
i:=Pos(')',aCurrentTag);
if (i>0) then
begin
SetLength(aCurrentTag,i-1);
end;
end;
end;
}

if (Length(DesiredTag)>0) then
begin
Command := ' describe --tags --exact-match';
Command := ' describe --tags --abbrev=0';
FReturnCode := TInstaller(Parent).ExecuteCommandInDir(DoubleQuoteIfNeeded(FRepoExecutable) + command, LocalRepository, Output, Verbose);
if FReturnCode = 0 then
begin
Expand All @@ -356,6 +381,23 @@ procedure TGitClient.Update;
end;
end;

if (Length(DesiredBranch)>0) then
begin
Command := ' rev-parse --abbrev-ref HEAD';
//Command := ' symbolic-ref --short HEAD';
FReturnCode := TInstaller(Parent).ExecuteCommandInDir(DoubleQuoteIfNeeded(FRepoExecutable) + command, LocalRepository, Output, Verbose);
if FReturnCode = 0 then
begin
if (DesiredBranch<>Trim(Output)) then
begin
Command := ' checkout '+DesiredBranch;
FReturnCode := TInstaller(Parent).ExecuteCommandInDir(DoubleQuoteIfNeeded(FRepoExecutable) + command, LocalRepository, Output, Verbose);
FReturnOutput := Output;
bSwitch:=true;
end;
end;
end;

if (NOT bSwitch) then
begin
// Get updates (equivalent to git fetch and git merge)
Expand Down
15 changes: 11 additions & 4 deletions installercore.pas
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ TInstaller = class(TObject)
FPreviousRevision: string;
FDesiredRevision: string;
FActualRevision: string;
FDesiredBranch: string;
FBranch: string;
// Stores tprocessex exception info:
FErrorLog: TStringList;
FHTTPProxyHost: string;
Expand Down Expand Up @@ -495,7 +495,7 @@ TInstaller = class(TObject)
property PreviousRevision: string read FPreviousRevision;
property DesiredRevision: string write FDesiredRevision;
property ActualRevision: string read FActualRevision;
property DesiredBranch: string write FDesiredBranch;
property Branch: string write FBranch;
// If using HTTP proxy: host
property HTTPProxyHost: string read FHTTPProxyHost write SetHTTPProxyHost;
// If using HTTP proxy: port (optional, default 8080)
Expand Down Expand Up @@ -1778,7 +1778,7 @@ function TInstaller.DownloadFromBase(aClient:TRepoClient; aModuleName: string; v
end;

aClient.DesiredRevision := FDesiredRevision; //We want to update to this specific revision
aClient.DesiredBranch := FDesiredBranch; //We want to update to this specific branch
aClient.DesiredBranch := FBranch; //We want to update to this specific branch
aClient.DesiredTag := FTAG; //We want to update to this specific branch

Output:=localinfotext+'Running '+UpperCase(aClient.RepoExecutableName)+' checkout or update';
Expand Down Expand Up @@ -3750,8 +3750,10 @@ function TInstaller.CreateRevision(ModuleName,aRevision:string): boolean;
begin
result:=false;

if (Pos(' ',aRevision)>0) then exit;

// Only handle Lazarus !
if (ModuleName<>_LAZARUS) then exit;
// if (ModuleName<>_LAZARUS) then exit;

//if TryStrToInt(aRevision,NumRevision) then
begin
Expand Down Expand Up @@ -3825,6 +3827,9 @@ function TInstaller.GetRevision(ModuleName:string): string;
end;
end;

result:=RevString;

{
if (Length(RevString)>0) then
begin
NumbersExtr := TRegExpr.Create;
Expand All @@ -3846,6 +3851,8 @@ function TInstaller.GetRevision(ModuleName:string): string;
NumbersExtr.Free;
end;
end;
}

end;
finally
RevisionStringList.Free;
Expand Down
Loading

0 comments on commit 3095eca

Please sign in to comment.