Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the order of haxelib git submodule installation #638

Merged
merged 22 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
fad7a32
submodule stuff in progress
ninjamuffin99 Jul 30, 2024
cd3bbe3
perhaps a submodule fix?
ninjamuffin99 Jul 31, 2024
65cf568
revert the dipshit logging
ninjamuffin99 Jul 31, 2024
25987e2
update run.n
ninjamuffin99 Jul 31, 2024
a336575
we dont need to spit out every log, but we should use the threads?
ninjamuffin99 Jul 31, 2024
b95e11c
comment out the unneeded git fetch
ninjamuffin99 Jul 31, 2024
ad1f05a
small reorder / remove redundant `git submodule init`
ninjamuffin99 Aug 16, 2024
6936c80
uncomment the lib deletion, since we've ran into issues related
ninjamuffin99 Aug 16, 2024
e3545f0
fix for stderr/stdout related hangs on non-windows when installing gi…
ninjamuffin99 Aug 16, 2024
3380e59
remove git progress code
ninjamuffin99 Aug 17, 2024
5c488cd
run.n
ninjamuffin99 Aug 17, 2024
b46b12d
remove whitespace
ninjamuffin99 Aug 17, 2024
f2d6be1
Merge branch 'development' of github.com:HaxeFoundation/haxelib into …
ninjamuffin99 Aug 26, 2024
0ea4cc9
proper non-cli coupled logging
ninjamuffin99 Aug 31, 2024
4469b97
remove unneeded logging/git --quiet flag code for the time being
ninjamuffin99 Aug 31, 2024
75a56a6
run.n
ninjamuffin99 Aug 31, 2024
3f15935
remove unneeded FsUtils.deleteRec()
ninjamuffin99 Aug 31, 2024
491c72d
run.n
ninjamuffin99 Aug 31, 2024
cdc4cbd
remove testing print
ninjamuffin99 Aug 31, 2024
9b6ce51
run.n
ninjamuffin99 Aug 31, 2024
984fa6b
removed unused import and throw an exception on submodule error
ninjamuffin99 Aug 31, 2024
0fdf946
add message for SubmoduleError
ninjamuffin99 Aug 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified run.n
Binary file not shown.
4 changes: 3 additions & 1 deletion src/haxelib/api/Installer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ class Installer {
userInterface.log('Installing $library from $url' + (branch != null ? " branch: " + branch : ""));
final tag = vcsData.tag;
try {
vcs.clone(libPath, url, branch, tag, userInterface.log.bind(_, Debug));
vcs.clone(libPath, url, branch, tag, userInterface.log.bind(_, Debug), userInterface.log.bind(_, Optional));
} catch (error:VcsError) {
FsUtils.deleteRec(libPath);
switch (error) {
Expand All @@ -779,6 +779,8 @@ class Installer {
throw 'Could not checkout branch, tag or path "$branch": ' + stderr;
case CantCheckoutVersion(_, version, stderr):
throw 'Could not checkout tag "$version": ' + stderr;
case SubmoduleError(_, repo, stderr):
throw 'Could not clone submodule(s) from $repo: ' + stderr;
case CommandFailed(_, code, stdout, stderr):
throw new VcsCommandFailed(id, code, stdout, stderr);
};
Expand Down
38 changes: 31 additions & 7 deletions src/haxelib/api/Vcs.hx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ interface IVcs {

`debugLog` will be used to log executable output.
**/
function clone(libPath:String, vcsPath:String, ?branch:String, ?version:String, ?debugLog:(msg:String)->Void):Void;
function clone(libPath:String, vcsPath:String, ?branch:String, ?version:String, ?debugLog:(msg:String)->Void, ?optionalLog:(msg:String)->Void):Void;

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

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

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

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

Expand Down Expand Up @@ -320,33 +321,56 @@ class Git extends Vcs {
return true;
}

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

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

if (!Vcs.flat)
vcsArgs.push('--recursive');
inline function printOptional(msg)
if (optionalLog != null && msg != "")
optionalLog(msg);

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

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

Sys.setCwd(libPath);

if (version != null && version != "") {
printOptional('Checking out tag/version ${version} of ${name}');

final ret = run(["checkout", "tags/" + version], debugLog);
if (ret.code != 0) {
Sys.setCwd(oldCwd);
throw VcsError.CantCheckoutVersion(this, version, ret.out);
}
} else if (branch != null) {
printOptional('Checking out branch/commit ${branch} of ${libPath}');

final ret = run(["checkout", branch], debugLog);
if (ret.code != 0){
Sys.setCwd(oldCwd);
throw VcsError.CantCheckoutBranch(this, branch, ret.out);
}
}

if (!Vcs.flat)
{
printOptional('Syncing submodules for ${name}');
run(["submodule", "sync", "--recursive"], debugLog);

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

printOptional('Downloading/updating submodules for ${name}');
final ret = run(submoduleArgs, debugLog);
if (ret.code != 0)
{
Sys.setCwd(oldCwd);
throw VcsError.SubmoduleError(this, url, ret.out);
}
ninjamuffin99 marked this conversation as resolved.
Show resolved Hide resolved
}

// return prev. cwd:
Sys.setCwd(oldCwd);
}
Expand Down Expand Up @@ -421,7 +445,7 @@ class Mercurial extends Vcs {
return changed;
}

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

if (branch != null && version != null) {
Expand Down
Loading