예제 #1
0
        public override int Execute(CommandContext context)
        {
            var gitHelper = new GitHelper();

            if (!gitHelper.HasRepo)
            {
                SpectreHelper.WriteError("There is no repository");
                return(1);
            }

            var flowHelper = new Modules.Flow(gitHelper);

            var response = flowHelper.Init();

            if (!response.Success)
            {
                SpectreHelper.WriteError(response.Message);
                return(1);
            }

            if (response.GitReponse is not EnumGitResponse.NONE)
            {
                SpectreHelper.WriteWarning(response.Message);
                return(0);
            }

            SpectreHelper.WriteSuccess(response.Message);
            return(0);
        }
예제 #2
0
        public static int PerformCommit(string commitMessage, bool addUntracked, bool stageTracked, bool fullCommit, bool amend)
        {
            var gitHelper = new GitHelper();

            if (!gitHelper.HasRepo)
            {
                SpectreHelper.WriteError("There is no repository");
                return(1);
            }

            var response = CommitCommandUtils.Commit(gitHelper, addUntracked, stageTracked,
                                                     fullCommit, commitMessage, amend);

            if (!response.Success)
            {
                SpectreHelper.WriteError(response.Message);
                return(1);
            }

            if (amend)
            {
                SpectreHelper.WriteSuccess($"{response.Message}\nCommit amend made successfully.");
                return(0);
            }

            SpectreHelper.WriteSuccess($"{response.Message}\nCommit made successfully.");
            return(0);
        }
예제 #3
0
        public override int Execute(CommandContext context)
        {
            var          gitHelper  = new GitHelper();
            var          flowHelper = new Modules.Flow(gitHelper);
            FlowResponse response;

            var createResponse = gitHelper.CreateRepository();

            if (!createResponse.Success)
            {
                response = new FlowResponse(createResponse.Success, EnumFlowResponse.GIT_ERROR,
                                            createResponse.Response, createResponse.Message);
            }
            else
            {
                response = flowHelper.Init();
            }

            if (!response.Success)
            {
                SpectreHelper.WriteError(response.Message);
                return(1);
            }

            if (response.GitReponse is not EnumGitResponse.NONE)
            {
                SpectreHelper.WriteWarning(response.Message);
                return(0);
            }

            SpectreHelper.WriteSuccess(response.Message);
            return(0);
        }
예제 #4
0
        public override int Execute(CommandContext context, FlowPublishSettings options)
        {
            var gitHelper = new GitHelper();

            if (!gitHelper.HasRepo)
            {
                SpectreHelper.WriteError("There is no repository");
                return(1);
            }

            if (string.IsNullOrWhiteSpace(options.BranchName))
            {
                options.BranchName = AnsiConsole.Prompt(
                    new SelectionPrompt <string>()
                    .Title("Please select a branch:")
                    .PageSize(10)
                    .MoreChoicesText("(Move up and down to reveal more branches)")
                    .AddChoices(gitHelper.LocalBranches));
            }

            var flowHelper = new Modules.Flow(gitHelper);

            var response = flowHelper.Publish(options.BranchName);

            if (!response.Success)
            {
                SpectreHelper.WriteError(response.Message);
                return(1);
            }

            if (response.GitReponse is not EnumGitResponse.NONE)
            {
                SpectreHelper.WriteWarning(response.Message);
                return(0);
            }

            SpectreHelper.WriteSuccess(response.Message);
            return(0);
        }
예제 #5
0
        public override int Execute(CommandContext context, FlowStartSettings options)
        {
            var gitHelper  = new GitHelper();
            var flowHelper = new Modules.Flow(gitHelper);

            if (!gitHelper.HasRepo)
            {
                SpectreHelper.WriteError("There is no repository");
                return(1);
            }

            var type = AnsiConsole.Prompt(
                new SelectionPrompt <string>()
                .Title("Select the branch type:")
                .PageSize(10)
                .MoreChoicesText("(Move up and down to reveal more branch types)")
                .AddChoices(Constants.ValidWorkingBranchTypeWithDescriptions))
                       .Split(':', StringSplitOptions.TrimEntries)[0];

            var response = flowHelper.Start(options.BranchName, type);

            if (!response.Success)
            {
                SpectreHelper.WriteError(response.Message);
                return(1);
            }

            if (response.GitReponse is not EnumGitResponse.NONE)
            {
                SpectreHelper.WriteWarning(response.Message);
                return(0);
            }

            SpectreHelper.WriteSuccess(response.Message);
            return(0);
        }