예제 #1
0
 public static void BreakLocksIfEnabled(this ILockBreaker lockBreaker)
 {
     if (lockBreaker.ShouldBreakLocks)
     {
         lockBreaker.BreakLocks();
     }
 }
예제 #2
0
        // ----------------- Constructor -----------------

        public Grabber(
            string svnUrl,
            Options options,
            ICommandRunner commandRunner,
            string gitConfigCommandArguments,
            IMessageDisplayer messageDisplayer,
            ILogger logger,
            IGcErrorIgnorer ignorer,
            ILockBreaker lockBreaker
            ) :
            base(options, commandRunner, gitConfigCommandArguments, messageDisplayer, logger)
        {
            _svnUrl   = svnUrl;
            _metaInfo = new MetaInfo()
            {
                RemoteBranches = new List <string>(),
                LocalBranches  = new List <string>(),
                Tags           = new List <string>()
            };
            _gcIgnorer   = ignorer;
            _lockBreaker = lockBreaker;
        }
예제 #3
0
        public void Run(
            IGrabber grabber,
            IFixer fixer,
            IStaleSvnBranchDeleter svnBranchDeleter,
            IGitPusher gitPusher,
            ILockBreaker lockBreaker
            )
        {
            if (grabber == null)
            {
                throw new ArgumentNullException(nameof(grabber));
            }

            if (fixer == null)
            {
                throw new ArgumentNullException(nameof(fixer));
            }

            if (svnBranchDeleter == null)
            {
                throw new ArgumentNullException(nameof(svnBranchDeleter));
            }

            if (lockBreaker == null)
            {
                throw new ArgumentNullException(nameof(lockBreaker));
            }

            try
            {
                PreRunPrepare();

                lockBreaker.BreakLocksIfEnabled();

                if (Options.Rebase)
                {
                    grabber.FetchBranches();
                }
                else if (!string.IsNullOrWhiteSpace(Options.RebaseBranch))
                {
                    grabber.FetchRebaseBraches();
                }
                else
                {
                    grabber.Clone();
                }

                fixer.FixBranches();
                fixer.FixTags();
                fixer.FixTrunk();
                fixer.OptimizeRepos();

                if (Options.StaleSvnBranchPurgeOption != StaleSvnBranchPurgeOptions.nothing)
                {
                    IEnumerable <string> svnBranches = svnBranchDeleter.QueryHeadSvnBranches();

                    IEnumerable <string> gitBranchesToPurge = svnBranchDeleter.GetGitBranchesToPurge(svnBranches);
                    svnBranches = null;

                    svnBranchDeleter.PurgeGitBranches(gitBranchesToPurge);
                    gitBranchesToPurge = null;

                    if (Options.StaleSvnBranchPurgeOption == StaleSvnBranchPurgeOptions.delete_local_and_remote)
                    {
                        gitPusher.PushPrune();
                    }
                }

                if (Options.PushWhenDone)
                {
                    gitPusher.PushAll();
                }
            }
            finally
            {
                PostRunCleanup();
            }
        }