Ejemplo n.º 1
0
        protected virtual void HandleAutoVersioning(Repository myRepository, string myShortName, Dependency dependency, CloneOptions cloneOptions)
        {
            if (!string.IsNullOrEmpty(dependency.Commit))
            {
                throw new InvalidOperationException($"Dependency {dependency}: autoversioning: definition is incoherent: Branch = '{dependency.Branch}' and a Commit = '{dependency.Commit}' => you can't have both set!");
            }

            if (Directory.Exists(dependency.OutputFolder))
            {
                Log($"Dependency {dependency}: autoversioning: output folder already exists: removing...");
                new DirectoryInfo(dependency.OutputFolder).ForceDelete();
            }

            Log($"Dependency {dependency}: autoversioning: cloning default branch of '{dependency.Remote}' into '{dependency.OutputFolder}'");
            Repository.Clone(dependency.Remote, dependency.OutputFolder, cloneOptions);

            try
            {
                IndentLevel++;

                using (var otherRepository = new Repository(dependency.OutputFolder))
                {
                    otherRepository.CheckoutAllRemoteBranches();
                    VersionResolver.CheckoutBranchInDependencyRepository(otherRepository, myRepository, myShortName, this);
                }
            }
            finally
            {
                IndentLevel--;
            }
        }
        public void TestVersionResolver_CheckoutBranchInDepencendyRepository()
        {
            var myRepositoryRootFolder    = new DirectoryInfo(@"C:\dev1\GitReposTest\Repo1"); //GetRootRepositoryFolderOf(Directory.GetCurrentDirectory());
            var otherRepositoryRootFolder = new DirectoryInfo(@"C:\dev1\GitReposTest\Repo2");

            using (var myRepository = new Repository(myRepositoryRootFolder.FullName))
                using (var otherRepository = new Repository(otherRepositoryRootFolder.FullName))
                {
                    VersionResolver.CheckoutBranchInDependencyRepository(otherRepository, myRepository, "", new TraceLogger());
                }
        }