Skip to content

Commit

Permalink
Always try to push upstream repos
Browse files Browse the repository at this point in the history
  • Loading branch information
SunSerega committed Aug 19, 2024
1 parent 72fd295 commit 3fd9cac
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 18 deletions.
43 changes: 27 additions & 16 deletions DataScraping/Reps/PullReps.pas
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
uses System.Diagnostics;

uses '../../POCGL_Utils';
uses '../../Utils/AOtp';
uses '../../Utils/AQueue';
uses '../../Utils/CLArgs';

uses '../../POCGL_Utils';

const remote_official = '0_official';
const remote_own = 'SunSerega';

var disable_push := false;
var branch_per_repo := new Dictionary<string, string>;

procedure ExecCommands(path, nick: string; kinds: array of string; params commands: array of string);
begin
Expand All @@ -31,15 +33,11 @@ procedure ExecCommands(path, nick: string; kinds: array of string; params comman
p.BeginErrorReadLine;

foreach var l in p_otp do
Otp(l.ConvStr(s->
begin
if 'https' in s then
disable_push := true;
Result := s
.Replace('github.com:','')
.Replace('https://github.com/','')
.RegexReplace('\s+', ' ')
end));
Otp(l.ConvStr(s->s
.Replace('github.com:','')
.Replace('https://github.com/','')
.RegexReplace('\s+', ' ')
));

if p.ExitCode<>0 then
Halt(p.ExitCode);
Expand All @@ -51,6 +49,12 @@ procedure PullRep(name, branch, nick: string);
var path := GetFullPathRTA(name);
System.IO.Directory.CreateDirectory(path);

if branch_per_repo.Get(name) is string(var branch_override) then
begin
Otp($'Branch override: {branch} => {branch_override}', 'console only');
branch := branch_override;
end;

if not FileExists(GetFullPath('.git', path)) then
ExecCommands(path, nick+'+init', |'console only'|
, $'echo [init] && git submodule update --init "." || cd .'
Expand All @@ -67,21 +71,28 @@ procedure PullRep(name, branch, nick: string);
, $'echo [merge-main] && git merge main'
);

if not disable_push then
ExecCommands(path, nick, |'console only'|
, $'echo [push main] && git push {remote_own} main || cd .'
, $'echo [push {branch}] && git push {remote_own} {branch} || cd .'
);
ExecCommands(path, nick, |'console only'|
, $'echo [push main] && git push {remote_own} main || cd .'
, $'echo [push {branch}] && git push {remote_own} {branch} || cd .'
);

Otp($'Done pulling {nick}');
end;

begin
try
foreach var arg in GetArgs('BranchOverride') do
begin
var (repo, branch) := arg.Split(|':'|, 2);
branch_per_repo.Add(repo, branch);
end;

Seq(
new class( nick := 'OpenCL', name := 'OpenCL-Docs', branch := 'custom' ),
new class( nick := 'OpenGL', name := 'OpenGL-Registry', branch := 'custom' )
).ForEach(r->PullRep(r.name, r.branch, r.nick));
//TODO Not parallel, because that would break git index

except
on e: Exception do ErrOtp(e);
end;
Expand Down
12 changes: 10 additions & 2 deletions PackAll.pas
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@
// === К примеру: "Stages= OpenCLABC + Compile + Test + Release"
// === Лишние пробелы по краям имён стадий допускаются, но "Stages=" должно быть слитно
//
// - "PullUpstreamBranch=Repo:Branch"
// === Настраивает стадию PullUpstream, чтобы использовать указанную ветку для указанного репозитория
//

uses System.Threading;
uses System.Threading.Tasks;
uses System.IO;

uses 'Utils/AOtp';
uses 'Utils/Timers';
uses 'Utils/ATask';
uses 'Utils/CLArgs';
uses 'Utils/Timers';
uses 'Utils/PathUtils';

{$region SpecialNames}
Expand Down Expand Up @@ -147,11 +151,15 @@

{$region UpdateReps}

var args := new List<string>;
foreach var arg in GetArgs('PullUpstreamBranch') do
args += $'BranchOverride={arg}';

var T_UpdateReps :=
TitleTask('Update Reps', '~')
+

ExecTask('DataScraping/Reps/PullReps.pas', 'SubReps Update')
ExecTask('DataScraping/Reps/PullReps.pas', 'SubReps Update', args.ToArray)

;

Expand Down

0 comments on commit 3fd9cac

Please sign in to comment.