diff --git a/CalculatorCInterface.dll b/CalculatorCInterface.dll index 4f2e819..baa9af2 100644 Binary files a/CalculatorCInterface.dll and b/CalculatorCInterface.dll differ diff --git a/deploy/CalculatorCInterface.dll b/deploy/CalculatorCInterface.dll index 4f2e819..baa9af2 100644 Binary files a/deploy/CalculatorCInterface.dll and b/deploy/CalculatorCInterface.dll differ diff --git a/deploy/helloworld.exe b/deploy/helloworld.exe index 7b6c969..5114fc5 100644 Binary files a/deploy/helloworld.exe and b/deploy/helloworld.exe differ diff --git a/helloworld.exe b/helloworld.exe index 7b6c969..5114fc5 100644 Binary files a/helloworld.exe and b/helloworld.exe differ diff --git a/helloworld.lpi b/helloworld.lpi new file mode 100644 index 0000000..ef82eec --- /dev/null +++ b/helloworld.lpi @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + <UseAppBundle Value="False"/> + <ResourceType Value="res"/> + </General> + <BuildModes> + <Item Name="Default" Default="True"/> + </BuildModes> + <PublishOptions> + <Version Value="2"/> + <UseFileFilters Value="True"/> + </PublishOptions> + <RunParams> + <FormatVersion Value="2"/> + </RunParams> + <RequiredPackages> + <Item> + <PackageName Value="LazUtils"/> + </Item> + </RequiredPackages> + <Units> + <Unit> + <Filename Value="helloworld.lpr"/> + <IsPartOfProject Value="True"/> + </Unit> + <Unit> + <Filename Value="unit1.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="Unit1"/> + </Unit> + <Unit> + <Filename Value="tariffcalculator.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="TariffCalculator"/> + </Unit> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <PathDelim Value="\"/> + <Target> + <Filename Value="helloworld"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + <Linking> + <Debugging> + <DebugInfoType Value="dsDwarf3"/> + </Debugging> + </Linking> + </CompilerOptions> + <Debugging> + <Exceptions> + <Item> + <Name Value="EAbort"/> + </Item> + <Item> + <Name Value="ECodetoolError"/> + </Item> + <Item> + <Name Value="EFOpenError"/> + </Item> + </Exceptions> + </Debugging> +</CONFIG> diff --git a/helloworld.lpr b/helloworld.lpr index bc7752b..6129a0e 100644 --- a/helloworld.lpr +++ b/helloworld.lpr @@ -6,29 +6,44 @@ program helloworld(output); uses - TariffCalculator, CTypes; + TariffCalculator, CTypes, LazUtils, LazFileUtils, LazUtf8; var - TariffCalc: TariffCalculatorHandle; + //TariffCalc: TariffCalculatorHandle; CustomerRepo: array[0..100] of char; LocalCustomerRepo: array[0..100] of char; + LocalBranchName: array[0..32] of char; + FileToCommit: array[0..128] of char; + CommitMessage: array[0..256] of char; begin -writeLn('Hello, World!') ; // TariffCalc := NewTariffCalculator; // DeleteTariffCalculator(TariffCalc); - if InitGitLibrary() > 0 then - begin - writeLn('init OK!') ; - CustomerRepo := 'https://git.mimbach49.de/GerhardHoffmann/customer_999.git'; - LocalCustomerRepo := 'C:\\tmp\\customer_999'; - CloneRepository(CustomerRepo, LocalCustomerRepo); - ShutdownGitLibrary(); + CustomerRepo := 'https://git.mimbach49.de/GerhardHoffmann/customer_999.git'; + LocalCustomerRepo := 'C:\\tmp\\customer_999'; + LocalBranchName := 'zg1/zone1'; + FileToCommit := 'etc/psa_tariff/tariff01.json'; + CommitMessage := 'TEST TEST'; + if not DirectoryExistsUTF8(ExpandFilenameUtf8(LocalCustomerRepo)) then + CreateDirUTF8(ExpandFilenameUtf8(LocalCustomerRepo)); + + if InitGitLibrary() > 0 then + Try + writeLn('initialized git library') ; + if not DirectoryExistsUTF8(ExpandFilenameUtf8(LocalCustomerRepo+'\\.git')) then + CloneRepository(CustomerRepo, LocalCustomerRepo); + if not CheckoutLocalBranch(LocalCustomerRepo, LocalBranchName) = 0 then + writeLn('cannot check out') ; + if not CommitFile(LocalCustomerRepo, LocalBranchName, FileToCommit, CommitMessage) = 0 then + writeLn('cannot check out') ; + Finally + if ShutdownGitLibrary() >= 0 then + writeLn('shutdown git library') ; end else begin - writeLn('init NOT OK!') ; + writeLn('initializing git library FAILED') ; Readln; end; end. diff --git a/tariffcalculator.pas b/tariffcalculator.pas index 0464ade..9e1658a 100644 --- a/tariffcalculator.pas +++ b/tariffcalculator.pas @@ -1,6 +1,6 @@ unit TariffCalculator; -{$mode ObjFPC}{$H-} +{$mode ObjFPC}{$H+} interface @@ -18,6 +18,9 @@ procedure DeleteTariffCalculator(handle: TariffCalculatorHandle); 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; implementation @@ -30,6 +33,9 @@ procedure DeleteTariffCalculator(handle: TariffCalculatorHandle); stdcall; exter 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; end.