Browse Source

UPD: Show commit count and hash

Alexander Koblov 4 years ago
parent
commit
24f6ba7247

+ 1 - 1
src/doublecmd.lpr

@@ -158,7 +158,7 @@ begin
 
   DCDebug('Double Commander ' + dcVersion);
   DCDebug('Revision: ' + dcRevision);
-  DCDebug('Commit: ' + GetCommitTime);
+  DCDebug('Commit: ' + dcCommit);
   DCDebug('Build: ' + dcBuildDate);
   DCDebug('Lazarus: ' + GetLazarusVersion);
   DCDebug('Free Pascal: ' + fpcVersion);

+ 2 - 5
src/fAbout.pas

@@ -161,7 +161,7 @@ begin
                     'FPC: %s' + LineEnding +
                     'Platform: %s' + LineEnding +
                     'OS version: %s' + LineEnding,
-                    [dcVersion, dcRevision, GetCommitTime, dcBuildDate,
+                    [dcVersion, dcRevision, dcCommit, dcBuildDate,
                     GetLazarusVersion, fpcVersion,
                     TargetCPU + '-' + TargetOS + '-' + TargetWS,
                     OSVersion]);
@@ -184,16 +184,13 @@ begin
 
   lblVersion.Caption         := lblVersion.Caption + #32 + dcVersion;
   lblRevision.Caption        := lblRevision.Caption + #32 + dcRevision;
-  lblCommit.Caption          := lblCommit.Caption + #32 + GetCommitTime;
+  lblCommit.Caption          := lblCommit.Caption + #32 + dcCommit;
   lblBuild.Caption           := lblBuild.Caption + #32 + dcBuildDate;
   lblLazarusVer.Caption      := lblLazarusVer.Caption + #32 + GetLazarusVersion;
   lblFreePascalVer.Caption   := lblFreePascalVer.Caption + #32 + fpcVersion;
   lblPlatform.Caption        := TargetCPU + '-' + TargetOS + '-' + TargetWS;
   lblOperatingSystem.Caption := OSVersion;
   lblWidgetsetVer.Caption    := WSVersion;
-
-  lblBuild.Visible           := (dcCommit = 0);
-  lblCommit.Visible          := (dcCommit > 0);
 end;
 
 end.

+ 1 - 4
src/fstartingsplash.pas

@@ -49,16 +49,13 @@ procedure TfrmStartingSplash.FormCreate(Sender: TObject);
 begin
   lblVersion.Caption         := lblVersion.Caption + #32 + dcVersion;
   lblRevision.Caption        := lblRevision.Caption + #32 + dcRevision;
-  lblCommit.Caption          := lblCommit.Caption + #32 + GetCommitTime;
+  lblCommit.Caption          := lblCommit.Caption + #32 + dcCommit;
   lblBuild.Caption           := lblBuild.Caption + #32 + dcBuildDate;
   lblLazarusVer.Caption      := lblLazarusVer.Caption + #32 + GetLazarusVersion;
   lblFreePascalVer.Caption   := lblFreePascalVer.Caption + #32 + fpcVersion;
   lblPlatform.Caption        := TargetCPU + '-' + TargetOS + '-' + TargetWS;
   lblOperatingSystem.Caption := OSVersion;
   lblWidgetsetVer.Caption    := WSVersion;
-
-  lblBuild.Visible           := (dcCommit = 0);
-  lblCommit.Visible          := (dcCommit > 0);
 end;
 
 end.

+ 3 - 3
src/platform/git2revisioninc.cmd

@@ -7,14 +7,14 @@ export REVISION_INC=$1/dcrevision.inc
 rm -f $REVISION_INC
 cp ../units/dcrevision.inc $REVISION_INC
 
-export REVISION=$(git -C $1 show -s --format="%h" HEAD)
-export COMMIT=$(git -C $1 show -s --format="%ct" HEAD)
+export REVISION=$(git -C $1 rev-list --count HEAD)
+export COMMIT=$(git -C $1 rev-parse --short HEAD)
 
 if [ $REVISION ] && [ $COMMIT ]; then
 
   echo "// Created by Git2RevisionInc"   >  $REVISION_INC
   echo "const dcRevision = '$REVISION';" >> $REVISION_INC
-  echo "const dcCommit = $COMMIT;"       >> $REVISION_INC
+  echo "const dcCommit = '$COMMIT';"     >> $REVISION_INC
 
 fi
 

+ 11 - 8
src/platform/git2revisioninc.exe.cmd

@@ -9,7 +9,7 @@ del /Q %REVISION_TXT% 2> nul
 del /Q %REVISION_INC% 2> nul
 copy ..\units\dcrevision.inc %REVISION_INC% > nul
 
-git -C %1 show -s --format="%%h %%ct" HEAD > %REVISION_TXT%
+git -C %1 rev-list --count HEAD > %REVISION_TXT%
 
 IF ERRORLEVEL 1 goto EXIT
 
@@ -19,13 +19,16 @@ echo %REVISION% | find "fatal:" > nul
 
 IF NOT ERRORLEVEL 1 goto EXIT
 
-rem Get package version and architecture
-for /f "tokens=1,2" %%a in ("%REVISION%") do (
-  echo // Created by Git2RevisionInc> %REVISION_INC%
-  echo const dcRevision = '%%a';>> %REVISION_INC%
-  echo const dcCommit = %%b;>> %REVISION_INC%
-)
+git -C %1 rev-parse --short HEAD > %REVISION_TXT%
+
+IF ERRORLEVEL 1 goto EXIT
+
+set /P COMMIT=<%REVISION_TXT%
+
+echo // Created by Git2RevisionInc> %REVISION_INC%
+echo const dcRevision = '%REVISION%';>> %REVISION_INC%
+echo const dcCommit = '%COMMIT%';>> %REVISION_INC%
 
 :EXIT
 
-echo Git revision %REVISION%
+echo Git revision %REVISION% %COMMIT%

+ 1 - 7
src/platform/udcversion.pas

@@ -50,12 +50,11 @@ var
 
 procedure InitializeVersionInfo;
 function GetLazarusVersion: String;
-function GetCommitTime: String;
 
 implementation
 
 uses
-  InterfaceBase, DateUtils
+  InterfaceBase
   {$IF DEFINED(UNIX)}
   , BaseUnix, DCOSUtils, uDCUtils, DCClassesUtf8
     {$IFDEF DARWIN}
@@ -467,11 +466,6 @@ begin
   end;
 end;
 
-function GetCommitTime: String;
-begin
-  Result:= FormatDateTime('yymmdd hhnnss', UnixToDateTime(dcCommit));
-end;
-
 procedure Initialize;
 begin
   LCLPlatformDirNames[lpQT]:= 'qt4';

+ 1 - 1
units/dcrevision.inc

@@ -1,3 +1,3 @@
 // Created by Git2RevisionInc
 const dcRevision = 'Unknown';
-const dcCommit = 0;
+const dcCommit = 'Unknown';