Skip to content

Commit

Permalink
fix for stderr/stdout related hangs on non-windows when installing gi…
Browse files Browse the repository at this point in the history
…t submodules
  • Loading branch information
ninjamuffin99 committed Aug 16, 2024
1 parent 6936c80 commit e3545f0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
Binary file modified run.n
Binary file not shown.
31 changes: 25 additions & 6 deletions src/haxelib/api/Vcs.hx
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,19 @@ abstract class Vcs implements IVcs {
// just in case process hangs waiting for stdin
p.stdin.close();

final ret = if (true) {
// In certain cases of git clones, it will hang on reading from stderr
// if we don't read from it. So we will always try to read from it.
try {
while (true) {
Sys.stdout().writeByte(p.stderr.readByte());
Sys.stdout().flush();
}
}
catch (e:haxe.io.Eof) {
// We're done reading this processes stderr
}

final ret = if (Sys.systemName() == "Windows") {
final streamsLock = new sys.thread.Lock();
function readFrom(stream:haxe.io.Input, to:{value:String}) {
to.value = stream.readAll().toString();
Expand All @@ -220,7 +232,7 @@ abstract class Vcs implements IVcs {
} else {
final out = p.stdout.readAll().toString();
final err = p.stderr.readAll().toString();



final code = p.exitCode();
Expand All @@ -230,7 +242,7 @@ abstract class Vcs implements IVcs {
err: err
};
};

p.close();
return ret;
}
Expand Down Expand Up @@ -329,7 +341,10 @@ class Git extends Vcs {

final oldCwd = Sys.getCwd();

final vcsArgs = ["clone", url, libPath];
var vcsArgs = ["clone", url, libPath];

if (Cli.mode != Quiet)
vcsArgs.push("--progress");

Cli.printOptional('Cloning ${name} from ${url}');

Expand Down Expand Up @@ -364,12 +379,16 @@ class Git extends Vcs {
Cli.printOptional('Syncing submodules for ${name}');
run(["submodule", "sync", "--recursive"], debugLog);

var submoduleArgs = ["submodule", "update", "--init", "--recursive"];

if (Cli.mode == Quiet)
submoduleArgs.push("--quiet");

Cli.printOptional('Downloading/updating submodules for ${name}');
final ret = run(["submodule", "update", "--init", "--recursive", "--force"], debugLog);
final ret = run(submoduleArgs, debugLog);
if (ret.code != 0)
{
Sys.setCwd(oldCwd);
trace("erm trolled?");
}
}

Expand Down

0 comments on commit e3545f0

Please sign in to comment.