unit gitupdateunit; {$mode objfpc}{$H+} interface uses Classes, SysUtils; implementation uses process, systemunit, lowlevelunit, refreshExecutableUnit; var updated: boolean; output: string; args,gitDirs: tStringArray; i: longint; initialization updated:=false; setLength(gitDirs,2); gitDirs[0]:=extractFilePath(paramstr(0)); gitDirs[1]:=extractFilePath(leftStr(gitDirs[0],length(gitDirs[0])-1))+'units/'; output:=''; for i:=0 to length(gitDirs)-1 do begin updated:=updated or (sourceSha512Sum(gitDirs[i])<>binarySha512Sum(i)); setLength(args,3); args[0]:='status'; args[1]:='-sb'; args[2]:='--porcelain'; if not runCommandInDir(gitDirs[i],'git',args,output) then continue; output:=trim(output); if pos(' [behind ',output)=0 then continue; setLength(args,2); args[0]:='pull'; args[1]:='--all'; if not runCommandInDir(gitDirs[i],'git',args,output) then continue; updated:=true; end; if updated then refreshExecutable(gitDirs); setLength(args,0); end.