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

Parse/autoinstall hg dependency #367

Closed
Closed
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
34 changes: 25 additions & 9 deletions src/haxelib/Data.hx
Original file line number Diff line number Diff line change
Expand Up @@ -81,35 +81,51 @@ abstract Dependencies(Dynamic<DependencyVersion>) from Dynamic<DependencyVersion
var value:String = Reflect.field(this, f);

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

if ( !isGit )
if ( isGit )
{
value = value.substr(4);
var urlParts = value.split("#");
var url = urlParts[0];
var branch = urlParts.length > 1 ? urlParts[1] : null;

result.push ({
name: f,
type: (DependencyType.Haxelib : DependencyType),
version: (cast value : DependencyVersion),
url: (null : String),
type: (DependencyType.Git : DependencyType),
version: (DependencyVersion.DEFAULT : DependencyVersion),
url: (url : String),
subDir: (null : String),
branch: (null : String),
branch: (branch : String),
});
}
else
else if ( isHg )
{
value = value.substr(4);
value = value.substr(3);
var urlParts = value.split("#");
var url = urlParts[0];
var branch = urlParts.length > 1 ? urlParts[1] : null;

result.push ({
name: f,
type: (DependencyType.Git : DependencyType),
type: (DependencyType.Mercurial : DependencyType),
version: (DependencyVersion.DEFAULT : DependencyVersion),
url: (url : String),
subDir: (null : String),
branch: (branch : String),
});
}

else
{
result.push ({
name: f,
type: (DependencyType.Haxelib : DependencyType),
version: (cast value : DependencyVersion),
url: (null : String),
subDir: (null : String),
branch: (null : String),
});
}

}

Expand Down
12 changes: 9 additions & 3 deletions src/haxelib/client/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -699,12 +699,18 @@ class Main {
{
if ( parts[1].startsWith("git:") )
{

type = "git";
var urlParts = parts[1].substr(4).split("#");
url = urlParts[0];
branch = urlParts.length > 1 ? urlParts[1] : null;
}
else if ( parts[1].startsWith("hg:") )
{
type = "hg";
var urlParts = parts[1].substr(3).split("#");
url = urlParts[0];
branch = urlParts.length > 1 ? urlParts[1] : null;
}
else
{
type = "haxelib";
Expand Down Expand Up @@ -737,9 +743,9 @@ class Main {
print("Loading info about the required libraries");
for (l in libsToInstall)
{
if ( l.type == "git" )
if ( l.type == "git" || l.type == "hg" )
{
// Do not check git repository infos
// Do not check git/hg repository infos
continue;
}
var inf = site.infos(l.name);
Expand Down
13 changes: 13 additions & 0 deletions test/libraries/UseGitDep/hg.haxelib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "Foo",
"url" : "http://example.org",
"license": "GPL",
"tags": ["foo", "test"],
"description": "This project is an example of an haxelib project",
"version": "0.1.0-alpha.0",
"releasenote": "Initial release, everything is working correctly",
"dependencies": {
"signal": "hg:https://bitbucket.org/fzzr/hx.signal"
},
"contributors": ["Foo"]
}
13 changes: 13 additions & 0 deletions test/libraries/UseGitDep/hg.tag_haxelib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "Foo",
"url" : "http://example.org",
"license": "GPL",
"tags": ["foo", "test"],
"description": "This project is an example of an haxelib project",
"version": "0.1.0-alpha.0",
"releasenote": "Initial release, everything is working correctly",
"dependencies": {
"signal": "hg:https://bitbucket.org/fzzr/hx.signal#develop"
},
"contributors": ["Foo"]
}
24 changes: 22 additions & 2 deletions test/tests/TestInstall.hx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ class TestInstall extends TestBase

checkLibrary(getLibraryName());
}

public function testInstallHaxelibHgParameter():Void
{
var r = runHaxelib(["--debug", "install", "hg.haxelib.json"]);
assertTrue(r.exitCode == 0);

checkLibrary(getLibraryName(), "hg");
}

public function testInstallHaxelibDependencyWithTag():Void
{
Expand All @@ -76,6 +84,18 @@ class TestInstall extends TestBase
// if that repo "README.md" was added in tag/rev.: "0.9.3"
assertFalse(FileSystem.exists(Path.join([lib, "git", "README.md"])));
}

public function testInstallHaxelibHgDependencyWithTag():Void
{
var r = runHaxelib(["install", "hg.tag_haxelib.json"]);
assertTrue(r.exitCode == 0);

var lib = getLibraryName();
checkLibrary(lib, "hg");

// if that repo "README.md" was added in tag/rev.: "0.9.2"
assertFalse(FileSystem.exists(Path.join([lib, "hg", "README.md"])));
}

function getLibraryName():String
{
Expand All @@ -85,7 +105,7 @@ class TestInstall extends TestBase
return details.dependencies.toArray()[0].name;
}

function checkLibrary(lib:String):Void
function checkLibrary(lib:String, type = "git"):Void
{
// Library folder exists
var libFolder = Path.join([repo, lib]);
Expand All @@ -94,7 +114,7 @@ class TestInstall extends TestBase

// Library version is set to git
var current = File.read(Path.join([libFolder, ".current"]), false);
assertTrue(current.readAll().toString() == "git");
assertTrue(current.readAll().toString() == type);
current.close();
}

Expand Down