static void Main(string[] arguments) { string currentDirectory = Environment.CurrentDirectory; #if DEBUGGING currentDirectory = "c:\\Users/Jeff/Documents/Visual Studio 2012/Projects/Git/ActivityRecommender-WPhone"; if (arguments.Count() == 0) { arguments = new string[] { "updeps" }; //currentDirectory = Directory.GetParent(currentDirectory).Parent.Parent.Parent.Parent.FullName + "\\test"; } #endif XmlObjectParser objectParser = XmlObjectParser.Default; objectParser.RegisterClass("Project", new ProjectDTO()); objectParser.RegisterClass("GitRepo", new GitRepoDTO()); objectParser.RegisterClass("GitVersion", new GitRepoVersionProvider()); objectParser.RegisterClass("Url", new FileLocation()); objectParser.RegisterClass("DependencyList", new ParseableList <ProjectDescriptorDTO>()); objectParser.RegisterClass("Git", new GitSyncherDTO()); objectParser.RegisterClass("String", new ConstantValue_Provider <string>(null)); ProjectDatabase database = new ProjectDatabase(objectParser); ArgumentParser argumentParser = new ArgumentParser(new DependencyHandler(objectParser, database)); argumentParser.ProcessArguments(currentDirectory, arguments); }
// Gets the right version of each dependency project downloading public void FetchDependencies(ProjectDatabase projectDatabase) { // Download the dependency projects foreach (ProjectDescriptor dependency in this.dependencies) { Project childProject = this.ResolveDependency(dependency, projectDatabase); childProject.FetchAll(new Version(dependency.version.GetValue()), projectDatabase); } }
public void FetchAll(Version version, ProjectDatabase projectDatabase) { // Download the right version of the source code for this project this.source.GetValue().Checkout(version); // Update (actually implemented as by loading a new project) this project based on the code that we just downloaded Project project = this.parser.OpenProject(this.location.GetValue().path); project.dependencyCacheLocationRoot = this.dependencyCacheLocationRoot; projectDatabase.PutProject(project.location.GetValue(), project); project.FetchDependencies(projectDatabase); }
private Project ResolveDependency(ProjectDescriptor dependency, ProjectDatabase projectDatabase) { // tell the dependency where to put itself dependency.cacheLocation = this.Get_DependencyCacheLocation(dependency); // now fetch the dependency finally Project childProject = projectDatabase.GetProject(dependency); // tell the child to put any of its dependencies in the same directory as ours childProject.dependencyCacheLocationRoot = this.dependencyCacheLocationRoot; return(childProject); }
// returns whatever is currently downloaded for the dependencies of this project public IEnumerable <Project> GetCachedVersionOfDirectDependencies(ProjectDatabase projectDatabase) { HashSet <Project> projects = new HashSet <Project>(); foreach (ProjectDescriptor dependency in this.Dependencies) { Project childProject = projectDatabase.TryGetDownloadedProject(dependency); childProject.dependencyCacheLocationRoot = this.dependencyCacheLocationRoot; if (childProject != null) { projects.Add(childProject); } } return(projects); }
public Dictionary <Project, string> CheckStatus(ProjectDatabase projectDatabase) { Dictionary <Project, string> statuses = new Dictionary <Project, string>(); string thisStatus = this.source.GetValue().CheckStatus(); LinkedList <string> ourStatuses = new LinkedList <string>(); if (thisStatus != null) { ourStatuses.AddLast(thisStatus); } foreach (ProjectDescriptor dependency in this.dependencies) { Project childProject = this.ResolveDependency(dependency, projectDatabase); Version requested = new Version(dependency.version.GetValue()); Version actual = childProject.GetVersion(); if (!requested.Equals(actual)) { ourStatuses.AddLast("Requests " + childProject.name.GetValue() + " " + dependency.version.GetValue() + "; sees " + childProject.GetVersion().ToString()); } Dictionary <Project, string> childStatuses = childProject.CheckStatus(projectDatabase); foreach (Project project in childStatuses.Keys) { statuses[project] = childStatuses[project]; } } if (ourStatuses.Count > 0) { string ourStatus = ""; foreach (string status in ourStatuses) { ourStatus += status + "\r\n"; } statuses[this] = ourStatus; //Logger.Message("status for " + this.ToString() + ": " + ourStatus); } return(statuses); }
public DependencyHandler(XmlObjectParser objectParser, ProjectDatabase projectDatabase) { this.objectParser = objectParser; this.projectDatabase = projectDatabase; }