Skip to content

Commit

Permalink
proper non-cli coupled logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ninjamuffin99 committed Aug 31, 2024
1 parent f2d6be1 commit 0ea4cc9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
Binary file modified run.n
Binary file not shown.
2 changes: 1 addition & 1 deletion src/haxelib/api/Installer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ class Installer {
final tag = vcsData.tag;
try {
FsUtils.deleteRec(libPath);
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 Down
22 changes: 13 additions & 9 deletions src/haxelib/api/Vcs.hx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,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 Down Expand Up @@ -231,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 @@ -321,28 +321,32 @@ 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();

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

Cli.printOptional('Cloning ${name} from ${url}');
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 != "") {
Cli.printOptional('Checking out tag/version ${version} of ${name}');
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) {
Cli.printOptional('Checking out branch/commit ${branch} of ${libPath}');
printOptional('Checking out branch/commit ${branch} of ${libPath}');

final ret = run(["checkout", branch], debugLog);
if (ret.code != 0){
Expand All @@ -353,15 +357,15 @@ class Git extends Vcs {

if (!Vcs.flat)
{
Cli.printOptional('Syncing submodules for ${name}');
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}');
printOptional('Downloading/updating submodules for ${name}');
final ret = run(submoduleArgs, debugLog);
if (ret.code != 0)
{
Expand Down Expand Up @@ -443,7 +447,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

0 comments on commit 0ea4cc9

Please sign in to comment.