Esempio n. 1
0
        public void HandleCheckoutResult(CheckoutParameters parameters, GitOutput output)
        {
            Assert.IsNotNull(parameters);
            Assert.IsNotNull(output);

            if(output.ExitCode != 0)
            {
                if(IsUnknownRevisionError(output.Error, parameters.Revision))
                {
                    throw new UnknownRevisionException(parameters.Revision);
                }
                if(IsRefrerenceIsNotATreeError(output.Error, parameters.Revision))
                {
                    throw new UnknownRevisionException(parameters.Revision);
                }
                if(IsUnknownPathspecError(output.Error, parameters.Revision))
                {
                    throw new UnknownRevisionException(parameters.Revision);
                }
                if(!parameters.Force)
                {
                    string fileName;
                    if(IsUntrackedFileWouldBeOverwrittenError(output.Error, out fileName))
                    {
                        throw new UntrackedFileWouldBeOverwrittenException(fileName);
                    }
                    if(IsHaveLocalChangesError(output.Error, out fileName))
                    {
                        throw new HaveLocalChangesException(fileName);
                    }
                    if(IsHaveConflictsError(output.Error))
                    {
                        throw new HaveConflictsException();
                    }
                }
                output.Throw();
            }
        }
Esempio n. 2
0
        public Command GetCheckoutCommand(CheckoutParameters parameters)
        {
            Assert.IsNotNull(parameters);

            var args = new List<ICommandArgument>();
            if(parameters.Force)
            {
                args.Add(CheckoutCommand.Force());
            }
            if(parameters.Merge)
            {
                args.Add(CheckoutCommand.Merge());
            }
            args.Add(new CommandParameter(parameters.Revision));
            return new CheckoutCommand(args);
        }