diff --git a/src/haxelib/Data.hx b/src/haxelib/Data.hx index 6becc1d8b..35b0a0722 100644 --- a/src/haxelib/Data.hx +++ b/src/haxelib/Data.hx @@ -81,35 +81,51 @@ abstract Dependencies(Dynamic) from Dynamic 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), + }); + } } diff --git a/src/haxelib/client/Main.hx b/src/haxelib/client/Main.hx index 3801a15ae..71ba0f956 100644 --- a/src/haxelib/client/Main.hx +++ b/src/haxelib/client/Main.hx @@ -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"; @@ -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); diff --git a/test/libraries/UseGitDep/hg.haxelib.json b/test/libraries/UseGitDep/hg.haxelib.json new file mode 100644 index 000000000..6a1ccccd2 --- /dev/null +++ b/test/libraries/UseGitDep/hg.haxelib.json @@ -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"] +} \ No newline at end of file diff --git a/test/libraries/UseGitDep/hg.tag_haxelib.json b/test/libraries/UseGitDep/hg.tag_haxelib.json new file mode 100644 index 000000000..9dc6eea0f --- /dev/null +++ b/test/libraries/UseGitDep/hg.tag_haxelib.json @@ -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"] +} \ No newline at end of file diff --git a/test/tests/TestInstall.hx b/test/tests/TestInstall.hx index 9cb6bdd72..7578dda67 100644 --- a/test/tests/TestInstall.hx +++ b/test/tests/TestInstall.hx @@ -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 { @@ -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 { @@ -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]); @@ -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(); }