diff --git a/run.n b/run.n index 2b281c0c..c9b8d138 100644 Binary files a/run.n and b/run.n differ diff --git a/src/haxelib/api/Installer.hx b/src/haxelib/api/Installer.hx index d2e20428..577f127b 100644 --- a/src/haxelib/api/Installer.hx +++ b/src/haxelib/api/Installer.hx @@ -795,8 +795,14 @@ class Installer { final currentBranch = vcsBranchesByLibraryName[library]; - // TODO check different urls as well - if (branch != null && (!wasUpdated || currentBranch != branch)) { + var libUrl = vcs.getReproducibleVersion(libPath).url; + + if (url != null && libUrl != null && url != libUrl) + { + FsUtils.deleteRec(libPath); + doVcsClone(); + } + else if (branch != null && (!wasUpdated || currentBranch != branch)) { final currentBranchStr = currentBranch != null ? currentBranch : ""; if (!userInterface.confirm('Overwrite branch: "$currentBranchStr" with "$branch"')) { userInterface.log('Library $library $id repository remains at "$currentBranchStr"'); diff --git a/src/haxelib/api/Vcs.hx b/src/haxelib/api/Vcs.hx index 8fda1e35..378aa8ac 100644 --- a/src/haxelib/api/Vcs.hx +++ b/src/haxelib/api/Vcs.hx @@ -380,14 +380,18 @@ class Git extends Vcs { Sys.setCwd(libPath); final ret: VcsData = { + // `git config --get remote.remoteName.url` will get the original url of the remote + // for usecases where someone has something like `url."git@github.com:".insteadOf 'https://github.com/'` set + // could the remote's name not be "origin"? - url: run(["remote", "get-url", "origin"], true).out.trim(), + url: run(["config", "--get", "remote.origin.url"], true).out.trim(), ref: run(["rev-parse", "HEAD"], true).out.trim(), }; Sys.setCwd(oldCwd); return ret; } + } /** Class wrapping `hg` operations. **/ diff --git a/test/libraries/InstallDeps/git-deps-url-new.hxml b/test/libraries/InstallDeps/git-deps-url-new.hxml new file mode 100644 index 00000000..756d3857 --- /dev/null +++ b/test/libraries/InstallDeps/git-deps-url-new.hxml @@ -0,0 +1 @@ +-lib flixel:git:https://github.com/geokureli/flixel.git#4.5.0 diff --git a/test/libraries/InstallDeps/git-deps-url-old.hxml b/test/libraries/InstallDeps/git-deps-url-old.hxml new file mode 100644 index 00000000..5827ef3d --- /dev/null +++ b/test/libraries/InstallDeps/git-deps-url-old.hxml @@ -0,0 +1 @@ +-lib flixel:git:https://github.com/HaxeFlixel/flixel.git#4.5.0 diff --git a/test/tests/TestInstaller.hx b/test/tests/TestInstaller.hx index 80425524..48a39cbb 100644 --- a/test/tests/TestInstaller.hx +++ b/test/tests/TestInstaller.hx @@ -1,5 +1,6 @@ package tests; +import haxelib.VersionData.VcsID; import sys.FileSystem; import sys.io.File; import haxe.io.Path; @@ -105,6 +106,19 @@ class TestInstaller extends TestBase { assertTrue(scope.isLibraryInstalled(ProjectName.ofString("hx.signal"))); } + public function testInstallUrlChanges() { + installer.installFromHxml("git-deps-url-old.hxml"); + + assertTrue(scope.isLibraryInstalled(ProjectName.ofString("flixel"))); + assertEquals(scope.repository.getVcsData(ProjectName.ofString("flixel"), VcsID.Git).url, "https://github.com/HaxeFlixel/flixel.git"); + + + installer.installFromHxml("git-deps-url-new.hxml"); + + assertTrue(scope.isLibraryInstalled(ProjectName.ofString("flixel"))); + assertEquals(scope.repository.getVcsData(ProjectName.ofString("flixel"), VcsID.Git).url, "https://github.com/geokureli/flixel.git"); + } + function getLibraryName():String { final haxelibFile = File.read("haxelib.json", false); final details = Data.readData(haxelibFile.readAll().toString(), NoCheck);