Example #1
0
 private void Initialize()
 {
     this.uuid         = Guid.NewGuid();
     this.currentState = new ModuleState();
     this.states       = new Dictionary <BranchVersion, ModuleState>();
     this.InitializeBranchVersions();
 }
Example #2
0
        public object Clone()
        {
            ModuleState clone = new ModuleState();

            clone.dependencies = new List <Dependency>();
            foreach (Dependency dependency in this.dependencies)
            {
                clone.dependencies.Add((Dependency)dependency.Clone());
            }
            clone.description = this.description;
            clone.name        = this.name;
            clone.path        = this.path;
            clone.tags        = new List <Tag>();
            foreach (Tag tag in this.tags)
            {
                clone.tags.Add(tag);
            }
            clone.trl = this.trl;
            return(clone);
        }
Example #3
0
        public void ModifyModule(IModule module, ModuleState moduleState)
        {
            bool shouldCommit = false;

            if (module.CurrentBranchVersion.ToString() == "master")
            {
                string moduleOldPath = module.Path;
                if (moduleState.Path != moduleOldPath)
                {
                    this.MoveSubmodule(module, moduleOldPath, moduleState.Path);
                }
                module.CurrentState = moduleState;
                module.SaveMetadata();
                if (module.IsDirty)
                {
                    module.PublishChanges("chore(metadata): modify the metadata of the module");
                    shouldCommit = true;
                }
                if (this.projectRepository != null && shouldCommit)
                {
                    this.projectRepository.StageFile(this.projectRepository.GetSubmoduleRelativePath(moduleState.Path));
                    this.projectRepository.Commit(string.Format("chore(modules): modify module {0} [{1}]", module.Name, module.CurrentBranchVersion));
                }

                if (moduleState.Path != moduleOldPath)
                {
                    AssetDatabase.Refresh();
                }

                if (this.OnMessageTriggered != null)
                {
                    this.OnMessageTriggered(new Message(string.Format("Module modified {0} [{1}] successfully !", module.Name, module.CurrentBranchVersion), MessageType.Info));
                }
            }
            else
            {
                throw new ModuniException("You can't modify the metadata of a module that is not currently on the branch 'master'.");
            }
        }
Example #4
0
        public void CreateModule(IRepositoryManager repositoryManager, ModuleState moduleState, Moduni.BranchVersion version)
        {
            Task <ISourceControlRepository> creationTask = repositoryManager.CreateRepository(moduleState.Name);

            creationTask.Wait();
            ISourceControlRepository remoteRepository  = creationTask.Result;
            ISourceControlRepository projectRepository = remoteRepository.InitOrCloneRepository(moduleState.Path);
            IModule module = this.moduleFactory.CreateModuleFromRepository(projectRepository);

            module.CurrentState = moduleState;
            module.SaveMetadata();
            module.PublishChanges("feat(Global): initial commit of the module");
            module.PublishVersion(version);
            module.CreateBaseBranches();
            this.projectModules.Add(module);

            if (this.projectRepository != null)
            {
                this.projectRepository.AddSubmodule(module.Path, module.RepositoryURL);
                this.projectRepository.StageFile(projectRepository.RepositoryURL.Remove(projectRepository.RepositoryURL.Length - 1, 1));
            }
            this.modules.Add(new Tuple <IRepositoryManager, IModule>(repositoryManager, this.moduleFactory.CreateModuleFromRepository(remoteRepository)));

            module.CheckoutBranchVersion(new BranchVersion("master"));

            if (this.OnModulesUpdated != null)
            {
                this.OnModulesUpdated(this.modules);
            }
            if (this.OnProjectModulesUpdated != null)
            {
                this.OnProjectModulesUpdated(this.projectModules);
            }
            if (this.OnMessageTriggered != null)
            {
                this.OnMessageTriggered(new Message(string.Format("Module ({0}) {1} created successfully !", repositoryManager.Name, module.Name), MessageType.Info));
            }
        }