Beispiel #1
0
        } // MigratePvcsArchiveSourcestoGit

        static bool MigratePvcsArchiveSourcestoGit(PvcsCompleteSystemArchiveDetail pvcsCompleteSystemArchiveDetail,
                                                   string singlePromotionGroupName,
                                                   string rootWorkingDirectory)
        {
            bool success = false;

            const CommandOperation.DebugProgress debugProgress = CommandOperation.DebugProgress.None;
            const int highLevelIndent = 0;

            PvcsPromotionGroupDetailCollection pvcsPromotionGroupDetailCollection = new PvcsPromotionGroupDetailCollection();

            // ============================================================================================================
            // For this to work, the Repository must have the branch from which this Promotion Group is to come checked out
            // ============================================================================================================
            success = GitOperation.ImportBranchFromPvcs(pvcsCompleteSystemArchiveDetail,
                                                        singlePromotionGroupName,
                                                        true,
                                                        pvcsPromotionGroupDetailCollection.PromotionGroupNetworkShareName(singlePromotionGroupName),
                                                        pvcsPromotionGroupDetailCollection.GitBranchName(singlePromotionGroupName),
                                                        rootWorkingDirectory,
                                                        String.Format("Initial PVCS {0} commit to Git {1}",
                                                                      singlePromotionGroupName,
                                                                      pvcsPromotionGroupDetailCollection.GitBranchName(singlePromotionGroupName)),
                                                        highLevelIndent,
                                                        debugProgress);

            return(success);
        } // MigratePvcsArchiveSourcestoGit
Beispiel #2
0
        static bool MigratePvcsArchiveSourcestoGit(PvcsCompleteSystemArchiveDetail pvcsCompleteSystemArchiveDetail,
                                                   SortedSet <string> sortedSetPromotionGroupExclude,
                                                   string rootWorkingDirectory,
                                                   bool useExistingGitRepository)
        {
            bool success = false;

            const CommandOperation.DebugProgress debugProgress = CommandOperation.DebugProgress.None;
            const int highLevelIndent = 0;

            PvcsPromotionGroupDetailCollection pvcsPromotionGroupDetailCollection = new PvcsPromotionGroupDetailCollection();

            bool createRepositoryAndPerformInitialCommit = !useExistingGitRepository;

            // Assume that if using the existing Repository the user knows that the branch structure already exists

            bool importPvcsProduction = !sortedSetPromotionGroupExclude.Contains(PvcsPromotionGroupDetailCollection.ProductionPromotionGroupName);

            // It only makes sense to import this Promotion Group if all higher Promotion Groups have been imported
            // unless the existing Git Repository already contains those higher Promotion Groups
            bool importPvcsPreProduction =
                ((importPvcsProduction) || (useExistingGitRepository /* Higher Promotion Group must already be present */)) &&
                (!sortedSetPromotionGroupExclude.Contains(PvcsPromotionGroupDetailCollection.PreProductionPromotionGroupName));

            // It only makes sense to import this Promotion Group if all higher Promotion Groups have been imported
            // unless the existing Git Repository already contains those higher Promotion Groups
            bool importPvcsUserTest =
                ((importPvcsPreProduction) || (useExistingGitRepository /* Higher Promotion Group must already be present */)) &&
                (!sortedSetPromotionGroupExclude.Contains(PvcsPromotionGroupDetailCollection.UserTestPromotionGroupName));

            // It only makes sense to import this Promotion Group if all higher Promotion Groups have been imported
            // unless the existing Git Repository already contains those higher Promotion Groups
            bool importPvcsSystemTest =
                ((importPvcsUserTest) || (useExistingGitRepository /* Higher Promotion Group must already be present */)) &&
                (!sortedSetPromotionGroupExclude.Contains(PvcsPromotionGroupDetailCollection.SystemTestPromotionGroupName));

            Console.WriteLine();
            ConsoleDisplay.WritelineWithUnderline("Importing PVCS Archive Revisions for PVCS Promotion Groups into a single Git Repository");

            if (createRepositoryAndPerformInitialCommit)
            {
                success = CreateRepositoryAndPerformInitialCommit(rootWorkingDirectory, highLevelIndent, debugProgress);
            }
            else
            {
                // Indicate success so that subsequent steps execute
                success = true;
            }

            if (success)
            {
                string promotionGroupName   = PvcsPromotionGroupDetailCollection.ProductionPromotionGroupName;
                bool   importPromotionGroup = importPvcsProduction;
                success = GitOperation.ImportBranchFromPvcs(
                    pvcsCompleteSystemArchiveDetail,
                    promotionGroupName,
                    importPromotionGroup,
                    pvcsPromotionGroupDetailCollection.PromotionGroupNetworkShareName(promotionGroupName),
                    pvcsPromotionGroupDetailCollection.GitBranchName(promotionGroupName),
                    rootWorkingDirectory,
                    String.Format("Initial PVCS {0} commit to Git {1}",
                                  promotionGroupName,
                                  pvcsPromotionGroupDetailCollection.GitBranchName(promotionGroupName)),
                    highLevelIndent,
                    debugProgress);
            }

            if (success)
            {
                string promotionGroupName   = PvcsPromotionGroupDetailCollection.PreProductionPromotionGroupName;
                bool   importPromotionGroup = importPvcsPreProduction;
                success = GitOperation.ImportBranchFromPvcs(
                    pvcsCompleteSystemArchiveDetail,
                    promotionGroupName,
                    importPromotionGroup,
                    pvcsPromotionGroupDetailCollection.PromotionGroupNetworkShareName(promotionGroupName),
                    pvcsPromotionGroupDetailCollection.GitBranchName(promotionGroupName),
                    rootWorkingDirectory,
                    String.Format("Initial PVCS {0} commit to Git {1}",
                                  promotionGroupName,
                                  pvcsPromotionGroupDetailCollection.GitBranchName(promotionGroupName)),
                    highLevelIndent,
                    debugProgress);
            }

            if (success)
            {
                string promotionGroupName   = PvcsPromotionGroupDetailCollection.UserTestPromotionGroupName;
                bool   importPromotionGroup = importPvcsUserTest;
                success = GitOperation.ImportBranchFromPvcs(
                    pvcsCompleteSystemArchiveDetail,
                    promotionGroupName,
                    importPromotionGroup,
                    pvcsPromotionGroupDetailCollection.PromotionGroupNetworkShareName(promotionGroupName),
                    pvcsPromotionGroupDetailCollection.GitBranchName(promotionGroupName),
                    rootWorkingDirectory,
                    String.Format("Initial PVCS {0} commit to Git {1}",
                                  promotionGroupName,
                                  pvcsPromotionGroupDetailCollection.GitBranchName(promotionGroupName)),
                    highLevelIndent,
                    debugProgress);
            }

            if (success)
            {
                string promotionGroupName   = PvcsPromotionGroupDetailCollection.SystemTestPromotionGroupName;
                bool   importPromotionGroup = importPvcsSystemTest;
                success = GitOperation.ImportBranchFromPvcs(
                    pvcsCompleteSystemArchiveDetail,
                    promotionGroupName,
                    importPromotionGroup,
                    pvcsPromotionGroupDetailCollection.PromotionGroupNetworkShareName(promotionGroupName),
                    pvcsPromotionGroupDetailCollection.GitBranchName(promotionGroupName),
                    rootWorkingDirectory,
                    String.Format("Initial PVCS {0} commit to Git {1}",
                                  promotionGroupName,
                                  pvcsPromotionGroupDetailCollection.GitBranchName(promotionGroupName)),
                    highLevelIndent,
                    debugProgress);
            }

            if (success)
            {
                for (int pvcsSystemTestIndex = PvcsPromotionGroupDetailCollection.FirstLowerSystemTestNumber;
                     (success) && (pvcsSystemTestIndex <= PvcsPromotionGroupDetailCollection.LastLowerSystemTestNumber);
                     ++pvcsSystemTestIndex)
                {
                    string pvcsBranchName = String.Format("{0}{1}",
                                                          PvcsPromotionGroupDetailCollection.SystemTestPromotionGroupName, pvcsSystemTestIndex);
                    string pvcsShareName          = pvcsPromotionGroupDetailCollection.PromotionGroupNetworkShareName(pvcsBranchName);
                    string gitBranchName          = pvcsPromotionGroupDetailCollection.GitBranchName(pvcsBranchName);
                    string gitBranchCommitComment = String.Format("Initial PVCS {0} commit to Git {1}", pvcsBranchName, gitBranchName);

                    // Ensure that the new Git Branch comes off Git Integration Test
                    if (!GitOperation.CheckedOutBranchIs(pvcsPromotionGroupDetailCollection.GitBranchName(PvcsPromotionGroupDetailCollection.SystemTestPromotionGroupName),
                                                         rootWorkingDirectory)
                        )
                    {
                        // Switch (back) to the Integration Test Branch
                        success = GitOperation.CheckOutBranch(pvcsPromotionGroupDetailCollection.GitBranchName(PvcsPromotionGroupDetailCollection.SystemTestPromotionGroupName),
                                                              rootWorkingDirectory, highLevelIndent, debugProgress);
                    }

                    if (success)
                    {
                        // It only makes sense to import this Promotion Group if all higher Promotion Groups have been imported
                        // unless the existing Git Repository already contains those higher Promotion Groups
                        bool importPvcsLowerSystemTest =
                            ((importPvcsSystemTest) || (useExistingGitRepository /* Higher Promotion Group must already be present */)) &&
                            (!sortedSetPromotionGroupExclude.Contains(pvcsBranchName));
                        success = GitOperation.ImportBranchFromPvcs(pvcsCompleteSystemArchiveDetail,
                                                                    pvcsBranchName,
                                                                    importPvcsLowerSystemTest,
                                                                    pvcsShareName,
                                                                    gitBranchName,
                                                                    rootWorkingDirectory,
                                                                    gitBranchCommitComment,
                                                                    highLevelIndent,
                                                                    debugProgress);
                    }
                } // for pvcsSystemTestIndex
            }

            if (success)
            {
                // Switch to the Integration Test Branch when everything is done
                success = GitOperation.CheckOutBranch(pvcsPromotionGroupDetailCollection.GitBranchName(PvcsPromotionGroupDetailCollection.SystemTestPromotionGroupName),
                                                      rootWorkingDirectory, highLevelIndent, debugProgress);
            }

            return(success);
        } // MigratePvcsArchiveSourcestoGit