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

Fix git dependencies on haxelib path #482

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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.
24 changes: 14 additions & 10 deletions src/haxelib/Data.hx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/
package haxelib;

import haxe.CallStack;
import haxe.ds.Option;
import haxe.ds.*;
import haxe.zip.Reader;
Expand Down Expand Up @@ -63,27 +64,30 @@ abstract DependencyVersion(String) to String from SemVer {

@:to function toValidatable():Validatable
return
if (this == '') { validate: function () return None }
else @:privateAccess new SemVer(this);
if (this == '' || this == 'git' || (Std.is(this, String) && this.startsWith('git:')))
{ validate: function () return None }
else
@:privateAccess new SemVer(this);

static public function isValid(s:String)
return new DependencyVersion(s).toValidatable().validate() == None;

static public var DEFAULT(default, null) = new DependencyVersion('');
static public var GIT(default, null) = new DependencyVersion('git');
}

abstract Dependencies(Dynamic<DependencyVersion>) from Dynamic<DependencyVersion> {
@:to public function toArray():Array<Dependency> {
var fields = Reflect.fields(this);
fields.sort(Reflect.compare);

var result:Array<Dependency> = new Array<Dependency>();

for (f in fields) {
var value:String = Reflect.field(this, f);

var isGit = value != null && (value + "").startsWith("git:");
var isGit = value != null && (value + "").startsWith("git:");

if ( !isGit )
{
result.push ({
Expand All @@ -101,7 +105,7 @@ abstract Dependencies(Dynamic<DependencyVersion>) from Dynamic<DependencyVersion
var urlParts = value.split("#");
var url = urlParts[0];
var branch = urlParts.length > 1 ? urlParts[1] : null;

result.push ({
name: f,
type: (DependencyType.Git : DependencyType),
Expand All @@ -111,10 +115,10 @@ abstract Dependencies(Dynamic<DependencyVersion>) from Dynamic<DependencyVersion
branch: (branch : String),
});
}


}

return result;
}
public inline function iterator()
Expand Down
2 changes: 2 additions & 0 deletions test/tests/integration/TestPath.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package tests.integration;

import haxe.io.Path;
using IntegrationTests;
using StringTools;
using Lambda;

class TestPath extends IntegrationTests {
#if !system_haxelib
Expand Down