Skip to content
Open
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.
10 changes: 8 additions & 2 deletions src/haxelib/api/Installer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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 : "<unspecified>";
if (!userInterface.confirm('Overwrite branch: "$currentBranchStr" with "$branch"')) {
userInterface.log('Library $library $id repository remains at "$currentBranchStr"');
Expand Down
6 changes: 5 additions & 1 deletion src/haxelib/api/Vcs.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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."[email protected]:".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. **/
Expand Down
1 change: 1 addition & 0 deletions test/libraries/InstallDeps/git-deps-url-new.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-lib flixel:git:https://github.com/geokureli/flixel.git#4.5.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be possible to set up a url that is just a path to a local directory. There is a util function for setting up a git repository, and there is a test/libraries folder with some existing libraries that could be pointed to.

function makeGitRepo(libPath:String) {

final vcsLibPath = "libraries/libBar";
final vcsLibNoHaxelibJson = "libraries/libNoHaxelibJson";
final vcsBrokenDependency = "libraries/libBrokenDep";

External repositories may change ownership or move (and they rely on the network to clone), so it is more reliable to clone from local repositories in tests, especially the unit tests.

1 change: 1 addition & 0 deletions test/libraries/InstallDeps/git-deps-url-old.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-lib flixel:git:https://github.com/HaxeFlixel/flixel.git#4.5.0
14 changes: 14 additions & 0 deletions test/tests/TestInstaller.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package tests;

import haxelib.VersionData.VcsID;
import sys.FileSystem;
import sys.io.File;
import haxe.io.Path;
Expand Down Expand Up @@ -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");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this test, we should run installVcsLibrary rather than installFromHxml, since we are only testing the git functionality


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);
Expand Down