//---------------------------------------------------------------------------------
        /// <summary>
        /// Get stacks for the current repository
        /// </summary>
        //---------------------------------------------------------------------------------
        public void CreateNewStack(string stackName, string originBranch)
        {
            if (_git.HasUncommittedChanges)
            {
                throw new ShortStackException("There are uncommitted changes.");
            }

            StackInfo targetStack = null;

            if (stackName == null)
            {
                if (CurrentStack == null)
                {
                    throw new ShortStackException("You are not in a stacked branch.  Pass in Name (with an optional Origin) to create a stacked branch.");
                }
                stackName = CurrentStack.StackName;

                var status = GetDanglingWorkStatus();
                //we are in the correct stack level but nothing has happenned on this level, so prevent creating a new level
                if (status == DanglingWorkStatus.Clean)
                {
                    throw new ShortStackException("You have not pushed any commits to the current branch. Create some commits before moving to the next level in the stack");
                }
            }

            targetStack = GetStack(stackName);

            // Create the stack if it is not there
            if (targetStack == null)
            {
                LogInformation($"Create new stack '{stackName}' tracking {originBranch}");
                if (_git.GetBranch(originBranch) == null)
                {
                    throw new ShortStackException($"Origin branch '{originBranch}' does not exist at {_git.RemoteUrl}");
                }

                var newStack = new StackInfo(stackName, _git.RemoteUrl, _git.RepositoryRootPath)
                {
                    Origin = originBranch,
                };

                Stacks.Add(stackName, newStack);
                CreateNextStackLevel(stackName, originBranch); // Create Level 0, but this will not get used
                // Make sure it is up to date
                _git.Pull();
                LogVerbose($"Pulled from {newStack.CurrentLevel().OriginBranch} to { newStack.CurrentLevel().TargetOriginBranch }");
            }

            CreateNextStackLevel(stackName); // Create level 1, this is the effective starting stack level
        }
        //---------------------------------------------------------------------------------
        /// <summary>
        /// Push any commits in the current stack level up to the server
        /// </summary>
        //---------------------------------------------------------------------------------
        public StackCommit[] PushStackLevel()
        {
            if (CurrentStack == null)
            {
                throw new ShortStackException("You are not in a stacked branch.  Use Show-Stacks to see available stacks.");
            }

            if (_git.HasUncommittedChanges)
            {
                throw new ShortStackException("There are uncommitted edits.  Please resolve or stash these before attempting this operation.");
            }

            var level = GetLevelDetails(CurrentStack.CurrentLevel());
            var vsts  = new VSTSAccess(_git.RemoteUrl);
            var existingPullRequest = vsts.GetPullRequestByBranch(level.OriginBranch);

            if (existingPullRequest != null)
            {
                var newDescription = new StringBuilder();
                newDescription.Append(existingPullRequest.description);
                foreach (var commit in level.UnpushedCommits)
                {
                    newDescription.AppendLine(commit.ShortMessage);
                    LogVerbose($"Appending to PR description: {commit.ShortMessage}");
                }

                var patch = new Dictionary <string, string>();
                patch["description"] = newDescription.ToString();

                vsts.AmmendPullRequest(existingPullRequest, patch);
            }

            var output = level.UnpushedCommits;

            LogInformation($"Pushing {output.Length} commits to {level.OriginBranch}");
            _git.Push(CurrentStack.CurrentLevel().LocalBranch);

            return(output);
        }