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

Allow better dependency injection on PackageManager's SCM operation #2848

Merged
merged 1 commit into from
Feb 12, 2024
Merged
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
22 changes: 18 additions & 4 deletions source/dub/packagemanager.d
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,6 @@ class PackageManager {

private Package loadGitPackage(in PackageName name, in Repository repo)
{
import dub.internal.git : cloneRepository;

if (!repo.ref_.startsWith("~") && !repo.ref_.isGitHash) {
return null;
}
Expand All @@ -455,13 +453,29 @@ class PackageManager {
}
}

if (!cloneRepository(repo.remote, gitReference, destination.toNativeString())) {
if (!this.gitClone(repo.remote, gitReference, destination))
return null;
}

return this.load(destination);
}

/**
* Perform a `git clone` operation at `dest` using `repo`
*
* Params:
* remote = The remote to clone from
* gitref = The git reference to use
* dest = Where the result of git clone operation is to be stored
*
* Returns:
* Whether or not the clone operation was successfull.
*/
protected bool gitClone(string remote, string gitref, in NativePath dest)
{
static import dub.internal.git;
return dub.internal.git.cloneRepository(remote, gitref, dest.toNativeString());
}

/**
* Get the final destination a specific package needs to be stored in.
*
Expand Down
Loading