public PackageManager(Repository repo, IAbsoluteDirectoryPath workDir, StatusRepo statusRepo,
bool createWhenNotExisting = false,
string remote = null) {
Contract.Requires<ArgumentNullException>(repo != null);
Contract.Requires<ArgumentNullException>(workDir != null);
WorkDir = workDir;
StatusRepo = statusRepo;
Repo = repo;
Settings = new PackageManagerSettings();
Repository.Factory.HandlePathRequirements(WorkDir, Repo);
if (!WorkDir.Exists) {
if (!createWhenNotExisting)
throw new Exception("Workdir doesnt exist");
WorkDir.MakeSurePathExists();
}
if (!string.IsNullOrWhiteSpace(remote)) {
var config =
Repository.DeserializeJson<RepositoryConfigDto>(
FetchString(Tools.Transfer.JoinUri(new Uri(remote), "config.json")));
if (config.Uuid == Guid.Empty)
throw new Exception("Invalid remote, does not contain an UUID");
Repo.AddRemote(config.Uuid, remote);
Repo.Save();
}
Repository.Log("Opening repository at: {0}. Working directory at: {1}", Repo.RootPath, WorkDir);
_remote = remote;
}