Пример #1
0
        //---------------------------------------------------------------------------------
        /// <summary>
        /// ProcessRecord - main processing goes here
        /// </summary>
        //---------------------------------------------------------------------------------
        protected override void ProcessRecord()
        {
            ProcessSafely(() =>
            {
                int stackLevel = (int)StackLevelAlias.Top;
                var stackName  = (string)null;

                if (Name == null)
                {
                }
                else if (Level != null)
                {
                    stackName = Name;
                    if (TryParseLevelNumber(Level, out var parsedLevel))
                    {
                        stackLevel = parsedLevel;
                    }
                    else
                    {
                        throw new ShortStackException("Stack level must be a number or [Top|Bottom|Root]");
                    }
                }
                else if (TryParseLevelNumber(Name, out var parsedLevel))
                {
                    stackLevel = parsedLevel;
                }
                else
                {
                    stackName  = Name;
                    stackLevel = (int)StackLevelAlias.Top;
                }

                Handler.GoToStack(stackName, stackLevel);
                Print(ConsoleColor.White, $"Checked out to {GetCurrentStackLevel().LocalBranch}");
                if (ObjectOutput.IsPresent)
                {
                    WriteObject(CurrentStack.CurrentLevel());
                }
            });
        }
Пример #2
0
        //---------------------------------------------------------------------------------
        /// <summary>
        /// ProcessRecord - main processing goes here
        /// </summary>
        //---------------------------------------------------------------------------------
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            if (CurrentStack == null)
            {
                Print(ConsoleColor.Red, "You are not in a stacked branch.  Use Get-Stacks to see available stacks.");
                return;
            }

            var danglingStatus = Handler.CheckServerForDanglingWork();

            if (danglingStatus == DanglingWorkStatus.UncommittedChanges)
            {
                Print(ConsoleColor.Red, "There are uncommitted changes. Please commit your changes first.");
                return;
            }

            int startLevel, stopLevel;

            if (!this.TryParseLevelNumber(Start, out startLevel))
            {
                if (String.IsNullOrEmpty(Start))
                {
                    startLevel = 1;
                }
                else
                {
                    Print(ConsoleColor.Red, "Start is an invalid level number");
                    return;
                }
            }

            if (!this.TryParseLevelNumber(Stop, out stopLevel))
            {
                if (String.IsNullOrEmpty(Stop))
                {
                    stopLevel = CurrentStack.CurrentLevel().Number;
                }
                else
                {
                    Print(ConsoleColor.Red, "Stop is an invalid level number");
                    return;
                }
            }

            if (startLevel > stopLevel)
            {
                Print(ConsoleColor.Red, "Start must be an earlier level than Stop");
                return;
            }


            StackLevel originalLevel = this.GetCurrentStackLevel();

            for (int i = startLevel; i <= stopLevel; i++)
            {
                StackLevel level = this.CurrentStack.Levels[i];
                this.Handler.GoToStack(this.CurrentStack.StackName, level.Number);
                level.FillDetails(this.Handler);
                if (level.UnpulledCommits.Any())
                {
                    //Pull and do a merge conflict
                }
                if (level.UnpushedCommits.Any() || level.UnpushedCommits.Any())
                {
                    this.Handler.PushStackLevel();
                }
            }

            this.Handler.GoToStack(this.CurrentStack.StackName, originalLevel.Number);
        }