unit gitupdateunit; {$mode objfpc}{$H+} interface uses Classes, SysUtils; implementation uses process, systemunit, lowlevelunit, refreshExecutableUnit; var updated: boolean; myDir,baseDir, output,tmpDir: string; args: array of string; initialization updated:=false; myDir:=extractFilePath(paramstr(0)); baseDir:=extractFilePath(leftStr(myDir,length(myDir)-1)); tmpDir:=''; output:=''; setlength(args,2); args[0]:='pull'; args[1]:='--all'; if runCommandInDir(myDir,'git',args,output) then begin updated:=updated or (output<>'Already up-to-date.'#10); if runCommandInDir(baseDir+'units','git',args,output) then begin updated:=updated or (output<>'Already up-to-date.'#10); if updated then refreshExecutable(myDir); end; end; if (tmpDir<>'') and directoryexists(tmpDir) then begin setlength(args,2); args[0]:='-rf'; args[1]:=tmpDir; runCommand('rm',args,output); end; setlength(args,0); end.