Beispiel #1
0
        public void HandleCreateBranchResult(CreateBranchParameters parameters, GitOutput output)
        {
            Assert.IsNotNull(parameters);
            Assert.IsNotNull(output);

            if(output.ExitCode != 0)
            {
                if(IsUnknownRevisionError(output.Error, parameters.StartingRevision))
                {
                    throw new UnknownRevisionException(parameters.StartingRevision);
                }
                if(IsBranchAlreadyExistsError(output.Error, parameters.BranchName))
                {
                    throw new BranchAlreadyExistsException(parameters.BranchName);
                }
                if(IsInvalidBranchNameError(output.Error, parameters.BranchName))
                {
                    throw new InvalidBranchNameException(parameters.BranchName);
                }
                output.Throw();
            }
        }
Beispiel #2
0
        public Command GetCreateBranchCommand(CreateBranchParameters parameters)
        {
            Assert.IsNotNull(parameters);

            var args = new List<ICommandArgument>(6);
            switch(parameters.TrackingMode)
            {
                case BranchTrackingMode.NotTracking:
                    args.Add(BranchCommand.NoTrack());
                    break;
                case BranchTrackingMode.Tracking:
                    args.Add(BranchCommand.Track());
                    break;
            }
            if(parameters.CreateReflog)
            {
                args.Add(BranchCommand.RefLog());
            }
            if(parameters.Checkout)
            {
                if(parameters.Orphan)
                {
                    args.Add(CheckoutCommand.Orphan());
                }
                else
                {
                    args.Add(CheckoutCommand.Branch());
                }
            }
            args.Add(new CommandParameter(parameters.BranchName));
            if(!string.IsNullOrEmpty(parameters.StartingRevision))
            {
                args.Add(new CommandParameter(parameters.StartingRevision));
            }
            if(parameters.Checkout)
            {
                return new CheckoutCommand(args);
            }
            else
            {
                return new BranchCommand(args);
            }
        }