mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-20 10:19:23 +02:00
svn2revisioninc: added support for git from Mario Bonati (issue #18156)
git-svn-id: trunk@28661 -
This commit is contained in:
parent
42ff964f3b
commit
115ae7a5c3
@ -40,6 +40,9 @@
|
||||
will leave the file as is. Otherwise it will create a new revision.inc,
|
||||
indicating that the revision number is unknown.
|
||||
|
||||
If the source directory don't contains a .svn subdirectory, it search for
|
||||
a .git directory. If i exist, it tries to execute git to get the revision
|
||||
number.
|
||||
}
|
||||
program Svn2RevisionInc;
|
||||
|
||||
@ -87,6 +90,42 @@ const
|
||||
function TSvn2RevisionApplication.FindRevision: boolean;
|
||||
var
|
||||
SvnDir: string;
|
||||
GitDir: string;
|
||||
|
||||
function GetRevisionFromGitVersion : boolean;
|
||||
var
|
||||
GitVersionProcess: TProcessUTF8;
|
||||
Buffer: string;
|
||||
n: LongInt;
|
||||
begin
|
||||
Result:=false;
|
||||
GitVersionProcess := TProcessUTF8.Create(nil);
|
||||
try
|
||||
with GitVersionProcess do begin
|
||||
CommandLine := 'git log -1 --pretty=format:"%b"';
|
||||
Options := [poUsePipes, poWaitOnExit];
|
||||
try
|
||||
CurrentDirectory:=GitDir;
|
||||
Execute;
|
||||
SetLength(Buffer, 80);
|
||||
n:=OutPut.Read(Buffer[1], 80);
|
||||
|
||||
if (Pos('git-svn-id:', Buffer) > 0) then begin
|
||||
//Read version is OK
|
||||
Result:=true;
|
||||
RevisionStr := Copy(Buffer, 1, n);
|
||||
System.Delete(RevisionStr, 1, Pos('@', RevisionStr));
|
||||
System.Delete(RevisionStr, Pos(' ', RevisionStr), Length(RevisionStr));
|
||||
end;
|
||||
except
|
||||
// ignore error, default result is false
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
GitVersionProcess.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
function GetRevisionFromSvnVersion : boolean;
|
||||
var
|
||||
SvnVersionProcess: TProcessUTF8;
|
||||
@ -185,9 +224,14 @@ var
|
||||
begin
|
||||
Result:=false;
|
||||
SvnDir:= AppendPathDelim(SourceDirectory)+'.svn';
|
||||
if DirectoryExistsUTF8(SvnDir) then
|
||||
Result := GetRevisionFromSvnVersion or GetRevisionFromEntriesTxt
|
||||
or GetRevisionFromEntriesXml;
|
||||
if DirectoryExistsUTF8(SvnDir) then begin
|
||||
Result := GetRevisionFromSvnVersion or GetRevisionFromEntriesTxt or
|
||||
GetRevisionFromEntriesXml;
|
||||
end else begin
|
||||
GitDir:= AppendPathDelim(SourceDirectory) + '.git';
|
||||
if DirectoryExistsUTF8(GitDir) then
|
||||
Result:=GetRevisionFromGitVersion;
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TSvn2RevisionApplication.Create(TheOwner: TComponent);
|
||||
|
Loading…
Reference in New Issue
Block a user