This commit is contained in:
Gerhard Hoffmann 2024-04-15 17:58:11 +02:00
parent 6336303e45
commit 0a8c56f0ad
4 changed files with 180 additions and 18 deletions

View File

@ -4,7 +4,7 @@ unit ATBGit;
interface
uses SysUtils, fpjson, jsonparser;
uses CTypes, SysUtils, fpjson, jsonparser;
//
// public interface
@ -13,14 +13,74 @@ uses SysUtils, fpjson, jsonparser;
function GetReposRootDirectory(): UTF8String;
function GetLocalRepositoryPath(const localrepo: UTF8String): UTF8String;
function InitGitLibrary(): Integer;
function ShutdownGitLibrary(): Integer;
function CloneRepository(const url, localRepo: UTF8String): Integer;
function CheckoutRepository(const url, localRepo, branchName: UTF8String): Integer;
function CommitFile(const localRepoName, branchName, fName, commitMessage: UTF8String): Integer;
// private c-interface
procedure SetReposRootDirectoryInternal(const rootDir: PChar); stdcall;
function GetReposRootDirectoryInternal(): PChar; stdcall;
function GetLocalRepositoryPathInternal(const localRepo: PChar): PChar; stdcall;
function CloneRepositoryInternal(const url, localRepo: PChar): cint32; stdcall;
function CheckoutRepositoryInternal(const url, localRepo, branchName: PChar): cint32; stdcall;
function CommitFileInternal(const localRepoName, branchName, fName, commitMessage: PChar): cint32; stdcall;
function PushRepositoryInternal(const localRepoName, branchName, user, password: PChar): cint32; stdcall;
function PullRepositoryInternal(const localRepoName, remoteRepoName: PChar): cint32; stdcall;
function InitGitLibraryInternal: cint32; stdcall;
function ShutdownGitLibraryInternal: cint32; stdcall;
implementation
const DLLName = 'CalculatorCInterface.dll';
function InitGitLibrary(): Integer;
begin
Result := InitGitLibraryInternal();
end;
function ShutdownGitLibrary(): Integer;
begin
Result := ShutdownGitLibraryInternal();
end;
function CloneRepository(const url, localRepo: UTF8String): Integer;
begin
Result := CloneRepositoryInternal(PChar(Utf8toAnsi(url)),
PChar(Utf8toAnsi(localRepo)));
end;
function CheckoutRepository(const url, localRepo, branchName: UTF8String): Integer;
begin
Result := CheckoutRepositoryInternal(PChar(Utf8toAnsi(url)),
PChar(Utf8toAnsi(localRepo)),
PChar(Utf8toAnsi(branchName)));
end;
function CommitFile(const localRepoName, branchName, fName, commitMessage: UTF8String): Integer;
begin
Result := CommitFileInternal(PChar(Utf8toAnsi(localRepoName)),
PChar(Utf8toAnsi(branchName)),
PChar(Utf8toAnsi(fName)),
PChar(Utf8toAnsi(commitMessage)));
end;
function PushRepository(const localRepoName, branchName, user, password: UTF8String): Integer;
begin
Result := PushRepositoryInternal(PChar(Utf8toAnsi(localRepoName)),
PChar(Utf8toAnsi(branchName)),
PChar(Utf8toAnsi(user)),
PChar(Utf8toAnsi(password)));
end;
function PullRepository(const localRepoName, remoteRepoName: UTF8String): Integer;
begin
Result := PullRepositoryInternal(PChar(Utf8toAnsi(localRepoName)),
PChar(Utf8toAnsi(remoteRepoName)));
end;
///
procedure SetReposRootDirectory(const rootDir: UTF8String);
begin
@ -59,5 +119,26 @@ implementation
function GetLocalRepositoryPathInternal(const localRepo: PChar): PChar; stdcall;
external DLLName;
function InitGitLibraryInternal: cint32; stdcall;
external DLLName;
function ShutdownGitLibraryInternal: cint32; stdcall;
external DLLName;
function CloneRepositoryInternal(const url, localRepo: PChar): cint32; stdcall;
external DLLName;
function CheckoutRepositoryInternal(const url, localRepo, branchName: PChar): cint32; stdcall;
external DLLName;
function CommitFileInternal(const localRepoName, branchName, fName, commitMessage: PChar): cint32; stdcall;
external DLLName;
function PushRepositoryInternal(const localRepoName, branchName, user, password: PChar): cint32; stdcall;
external DLLName;
function PullRepositoryInternal(const localRepoName, remoteRepoName: PChar): cint32; stdcall;
external DLLName;
end.

View File

@ -25,10 +25,10 @@ procedure DeleteTariffCalculator(handle: TariffCalculatorHandle); stdcall;
//function GetFileSize(const localRepository: PChar; const fileId: PChar): cint32; stdcall;
//function GetFile(const localRepository: PChar; const fileId: PChar): PChar; stdcall;
function InitGitLibrary: cint32; stdcall;
function ShutdownGitLibrary: cint32; stdcall;
function CloneRepository(var url; var local_path) : cint32; stdcall;
function CheckoutLocalBranch(var local_path; var branch_name) : cint32; stdcall;
//function InitGitLibrary: cint32; stdcall;
//function ShutdownGitLibrary: cint32; stdcall;
//function CloneRepository(var url; var local_path) : cint32; stdcall;
//function CheckoutLocalBranch(var local_path; var branch_name) : cint32; stdcall;
function CommitFile(var local_path; var branch_name;
var file_name; var comment) : cint32; stdcall;
function PushLocalRepository(var local_path; var branch_name;
@ -86,10 +86,10 @@ procedure DeleteTariffCalculator(handle: TariffCalculatorHandle); stdcall; exter
// const json: PChar;
// size: cint32): cbool; stdcall; external DLLName;
function InitGitLibrary: cint32; stdcall; external DLLName;
function ShutdownGitLibrary: cint32; stdcall; external DLLName;
function CloneRepository(var url; var local_path) : cint32; stdcall; external DLLName;
function CheckoutLocalBranch(var local_path; var branch_name) : cint32; stdcall; external DLLName;
//function InitGitLibrary: cint32; stdcall; external DLLName;
//function ShutdownGitLibrary: cint32; stdcall; external DLLName;
//function CloneRepository(var url; var local_path) : cint32; stdcall; external DLLName;
//function CheckoutLocalBranch(var local_path; var branch_name) : cint32; stdcall; external DLLName;
function CommitFile(var local_path; var branch_name;
var file_name; var comment) : cint32; stdcall; external DLLName;
function PushLocalRepository(var local_path; var branch_name;

View File

@ -4,7 +4,7 @@ unit ATBGit;
interface
uses SysUtils, fpjson, jsonparser;
uses CTypes, SysUtils, fpjson, jsonparser;
//
// public interface
@ -13,14 +13,74 @@ uses SysUtils, fpjson, jsonparser;
function GetReposRootDirectory(): UTF8String;
function GetLocalRepositoryPath(const localrepo: UTF8String): UTF8String;
function InitGitLibrary(): Integer;
function ShutdownGitLibrary(): Integer;
function CloneRepository(const url, localRepo: UTF8String): Integer;
function CheckoutRepository(const url, localRepo, branchName: UTF8String): Integer;
function CommitFile(const localRepoName, branchName, fName, commitMessage: UTF8String): Integer;
// private c-interface
procedure SetReposRootDirectoryInternal(const rootDir: PChar); stdcall;
function GetReposRootDirectoryInternal(): PChar; stdcall;
function GetLocalRepositoryPathInternal(const localRepo: PChar): PChar; stdcall;
function CloneRepositoryInternal(const url, localRepo: PChar): cint32; stdcall;
function CheckoutRepositoryInternal(const url, localRepo, branchName: PChar): cint32; stdcall;
function CommitFileInternal(const localRepoName, branchName, fName, commitMessage: PChar): cint32; stdcall;
function PushRepositoryInternal(const localRepoName, branchName, user, password: PChar): cint32; stdcall;
function PullRepositoryInternal(const localRepoName, remoteRepoName: PChar): cint32; stdcall;
function InitGitLibraryInternal: cint32; stdcall;
function ShutdownGitLibraryInternal: cint32; stdcall;
implementation
const DLLName = 'CalculatorCInterface.dll';
function InitGitLibrary(): Integer;
begin
Result := InitGitLibraryInternal();
end;
function ShutdownGitLibrary(): Integer;
begin
Result := ShutdownGitLibraryInternal();
end;
function CloneRepository(const url, localRepo: UTF8String): Integer;
begin
Result := CloneRepositoryInternal(PChar(Utf8toAnsi(url)),
PChar(Utf8toAnsi(localRepo)));
end;
function CheckoutRepository(const url, localRepo, branchName: UTF8String): Integer;
begin
Result := CheckoutRepositoryInternal(PChar(Utf8toAnsi(url)),
PChar(Utf8toAnsi(localRepo)),
PChar(Utf8toAnsi(branchName)));
end;
function CommitFile(const localRepoName, branchName, fName, commitMessage: UTF8String): Integer;
begin
Result := CommitFileInternal(PChar(Utf8toAnsi(localRepoName)),
PChar(Utf8toAnsi(branchName)),
PChar(Utf8toAnsi(fName)),
PChar(Utf8toAnsi(commitMessage)));
end;
function PushRepository(const localRepoName, branchName, user, password: UTF8String): Integer;
begin
Result := PushRepositoryInternal(PChar(Utf8toAnsi(localRepoName)),
PChar(Utf8toAnsi(branchName)),
PChar(Utf8toAnsi(user)),
PChar(Utf8toAnsi(password)));
end;
function PullRepository(const localRepoName, remoteRepoName: UTF8String): Integer;
begin
Result := PullRepositoryInternal(PChar(Utf8toAnsi(localRepoName)),
PChar(Utf8toAnsi(remoteRepoName)));
end;
///
procedure SetReposRootDirectory(const rootDir: UTF8String);
begin
@ -59,5 +119,26 @@ implementation
function GetLocalRepositoryPathInternal(const localRepo: PChar): PChar; stdcall;
external DLLName;
function InitGitLibraryInternal: cint32; stdcall;
external DLLName;
function ShutdownGitLibraryInternal: cint32; stdcall;
external DLLName;
function CloneRepositoryInternal(const url, localRepo: PChar): cint32; stdcall;
external DLLName;
function CheckoutRepositoryInternal(const url, localRepo, branchName: PChar): cint32; stdcall;
external DLLName;
function CommitFileInternal(const localRepoName, branchName, fName, commitMessage: PChar): cint32; stdcall;
external DLLName;
function PushRepositoryInternal(const localRepoName, branchName, user, password: PChar): cint32; stdcall;
external DLLName;
function PullRepositoryInternal(const localRepoName, remoteRepoName: PChar): cint32; stdcall;
external DLLName;
end.

View File

@ -25,10 +25,10 @@ procedure DeleteTariffCalculator(handle: TariffCalculatorHandle); stdcall;
//function GetFileSize(const localRepository: PChar; const fileId: PChar): cint32; stdcall;
//function GetFile(const localRepository: PChar; const fileId: PChar): PChar; stdcall;
function InitGitLibrary: cint32; stdcall;
function ShutdownGitLibrary: cint32; stdcall;
function CloneRepository(var url; var local_path) : cint32; stdcall;
function CheckoutLocalBranch(var local_path; var branch_name) : cint32; stdcall;
//function InitGitLibrary: cint32; stdcall;
//function ShutdownGitLibrary: cint32; stdcall;
//function CloneRepository(var url; var local_path) : cint32; stdcall;
//function CheckoutLocalBranch(var local_path; var branch_name) : cint32; stdcall;
function CommitFile(var local_path; var branch_name;
var file_name; var comment) : cint32; stdcall;
function PushLocalRepository(var local_path; var branch_name;
@ -86,10 +86,10 @@ procedure DeleteTariffCalculator(handle: TariffCalculatorHandle); stdcall; exter
// const json: PChar;
// size: cint32): cbool; stdcall; external DLLName;
function InitGitLibrary: cint32; stdcall; external DLLName;
function ShutdownGitLibrary: cint32; stdcall; external DLLName;
function CloneRepository(var url; var local_path) : cint32; stdcall; external DLLName;
function CheckoutLocalBranch(var local_path; var branch_name) : cint32; stdcall; external DLLName;
//function InitGitLibrary: cint32; stdcall; external DLLName;
//function ShutdownGitLibrary: cint32; stdcall; external DLLName;
//function CloneRepository(var url; var local_path) : cint32; stdcall; external DLLName;
//function CheckoutLocalBranch(var local_path; var branch_name) : cint32; stdcall; external DLLName;
function CommitFile(var local_path; var branch_name;
var file_name; var comment) : cint32; stdcall; external DLLName;
function PushLocalRepository(var local_path; var branch_name;