Skip to content

Commit 4820514

Browse files
committed
Change the order of haxelib git submodule installation (HaxeFoundation#638)
* submodule stuff in progress * perhaps a submodule fix? * revert the dipshit logging * update run.n * we dont need to spit out every log, but we should use the threads? * comment out the unneeded git fetch * small reorder / remove redundant `git submodule init` * uncomment the lib deletion, since we've ran into issues related * fix for stderr/stdout related hangs on non-windows when installing git submodules * remove git progress code * run.n * remove whitespace * proper non-cli coupled logging * remove unneeded logging/git --quiet flag code for the time being * run.n * remove unneeded FsUtils.deleteRec() * run.n * remove testing print * run.n * removed unused import and throw an exception on submodule error * add message for SubmoduleError
1 parent 846dcf8 commit 4820514

File tree

3 files changed

+34
-8
lines changed

3 files changed

+34
-8
lines changed

run.n

1.21 KB
Binary file not shown.

src/haxelib/api/Installer.hx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -767,7 +767,7 @@ class Installer {
767767
userInterface.log('Installing $library from $url' + (branch != null ? " branch: " + branch : ""));
768768
final tag = vcsData.tag;
769769
try {
770-
vcs.clone(libPath, url, branch, tag, userInterface.log.bind(_, Debug));
770+
vcs.clone(libPath, url, branch, tag, userInterface.log.bind(_, Debug), userInterface.log.bind(_, Optional));
771771
} catch (error:VcsError) {
772772
FsUtils.deleteRec(libPath);
773773
switch (error) {
@@ -779,6 +779,8 @@ class Installer {
779779
throw 'Could not checkout branch, tag or path "$branch": ' + stderr;
780780
case CantCheckoutVersion(_, version, stderr):
781781
throw 'Could not checkout tag "$version": ' + stderr;
782+
case SubmoduleError(_, repo, stderr):
783+
throw 'Could not clone submodule(s) from $repo: ' + stderr;
782784
case CommandFailed(_, code, stdout, stderr):
783785
throw new VcsCommandFailed(id, code, stdout, stderr);
784786
};

src/haxelib/api/Vcs.hx

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ interface IVcs {
4848
4949
`debugLog` will be used to log executable output.
5050
**/
51-
function clone(libPath:String, vcsPath:String, ?branch:String, ?version:String, ?debugLog:(msg:String)->Void):Void;
51+
function clone(libPath:String, vcsPath:String, ?branch:String, ?version:String, ?debugLog:(msg:String)->Void, ?optionalLog:(msg:String)->Void):Void;
5252

5353
/**
5454
Updates repository in CWD or CWD/`Vcs.directory` to HEAD.
@@ -74,6 +74,7 @@ enum VcsError {
7474
CantCheckoutBranch(vcs:Vcs, branch:String, stderr:String);
7575
CantCheckoutVersion(vcs:Vcs, version:String, stderr:String);
7676
CommandFailed(vcs:Vcs, code:Int, stdout:String, stderr:String);
77+
SubmoduleError(vcs:Vcs, repo:String, stderr:String);
7778
}
7879

7980
/** Exception thrown when a vcs update is cancelled. **/
@@ -230,7 +231,7 @@ abstract class Vcs implements IVcs {
230231
return ret;
231232
}
232233

233-
public abstract function clone(libPath:String, vcsPath:String, ?branch:String, ?version:String, ?debugLog:(msg:String)->Void):Void;
234+
public abstract function clone(libPath:String, vcsPath:String, ?branch:String, ?version:String, ?debugLog:(msg:String)->Void, ?optionalLog:(msg:String)->Void):Void;
234235

235236
public abstract function update(?confirm:() -> Bool, ?debugLog:(msg:String) -> Void, ?summaryLog:(msg:String) -> Void):Bool;
236237

@@ -320,33 +321,56 @@ class Git extends Vcs {
320321
return true;
321322
}
322323

323-
public function clone(libPath:String, url:String, ?branch:String, ?version:String, ?debugLog:(msg:String)->Void):Void {
324+
public function clone(libPath:String, url:String, ?branch:String, ?version:String, ?debugLog:(msg:String)->Void, ?optionalLog:(msg:String)->Void):Void {
324325
final oldCwd = Sys.getCwd();
325326

326-
final vcsArgs = ["clone", url, libPath];
327+
var vcsArgs = ["clone", url, libPath];
327328

328-
if (!Vcs.flat)
329-
vcsArgs.push('--recursive');
329+
inline function printOptional(msg)
330+
if (optionalLog != null && msg != "")
331+
optionalLog(msg);
332+
333+
printOptional('Cloning ${name} from ${url}');
330334

331335
if (run(vcsArgs, debugLog).code != 0)
332336
throw VcsError.CantCloneRepo(this, url/*, ret.out*/);
333337

334338
Sys.setCwd(libPath);
335339

336340
if (version != null && version != "") {
341+
printOptional('Checking out tag/version ${version} of ${name}');
342+
337343
final ret = run(["checkout", "tags/" + version], debugLog);
338344
if (ret.code != 0) {
339345
Sys.setCwd(oldCwd);
340346
throw VcsError.CantCheckoutVersion(this, version, ret.out);
341347
}
342348
} else if (branch != null) {
349+
printOptional('Checking out branch/commit ${branch} of ${libPath}');
350+
343351
final ret = run(["checkout", branch], debugLog);
344352
if (ret.code != 0){
345353
Sys.setCwd(oldCwd);
346354
throw VcsError.CantCheckoutBranch(this, branch, ret.out);
347355
}
348356
}
349357

358+
if (!Vcs.flat)
359+
{
360+
printOptional('Syncing submodules for ${name}');
361+
run(["submodule", "sync", "--recursive"], debugLog);
362+
363+
var submoduleArgs = ["submodule", "update", "--init", "--recursive"];
364+
365+
printOptional('Downloading/updating submodules for ${name}');
366+
final ret = run(submoduleArgs, debugLog);
367+
if (ret.code != 0)
368+
{
369+
Sys.setCwd(oldCwd);
370+
throw VcsError.SubmoduleError(this, url, ret.out);
371+
}
372+
}
373+
350374
// return prev. cwd:
351375
Sys.setCwd(oldCwd);
352376
}
@@ -425,7 +449,7 @@ class Mercurial extends Vcs {
425449
return changed;
426450
}
427451

428-
public function clone(libPath:String, url:String, ?branch:String, ?version:String, ?debugLog:(msg:String)->Void):Void {
452+
public function clone(libPath:String, url:String, ?branch:String, ?version:String, ?debugLog:(msg:String)->Void, ?optionalLog:(msg:String)->Void):Void {
429453
final vcsArgs = ["clone", url, libPath];
430454

431455
if (branch != null && version != null) {

0 commit comments

Comments
 (0)