Example #1
0
        private void InitCommand(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(_envHelper.GetSolutionDir()))
            {
                return;
            }

            var flowDialog = new FlowDialog();

            if (flowDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            var versionTag = string.IsNullOrEmpty(flowDialog.GitConfig.TagPrefix) ? "\"\"" : flowDialog.GitConfig.TagPrefix;

            /* 1. Add GitFlow config options
             * 2. Checkout develop branch (create if it doesn't exist, reset if it does)
             * 3. Push develop branch
             */
            var process = ProcessHelper.StartProcessGui(_dte, _envHelper,
                                                        "cmd.exe",
                                                        $"/c cd \"{_envHelper.GetSolutionDir()}\" && " +
                                                        GitHelper.GetSshSetup(_envHelper) +
                                                        FormatCliCommand($"config --add gitflow.branch.master {flowDialog.GitConfig.MasterBranch}") +
                                                        FormatCliCommand($"config --add gitflow.branch.develop {flowDialog.GitConfig.DevelopBranch}") +
                                                        FormatCliCommand($"config --add gitflow.prefix.feature {flowDialog.GitConfig.FeaturePrefix}") +
                                                        FormatCliCommand($"config --add gitflow.prefix.release {flowDialog.GitConfig.ReleasePrefix}") +
                                                        FormatCliCommand($"config --add gitflow.prefix.hotfix {flowDialog.GitConfig.HotfixPrefix}") +
                                                        FormatCliCommand($"config --add gitflow.prefix.versiontag {versionTag}") +
                                                        (GitHelper.RemoteBranchExists(_envHelper, flowDialog.GitConfig.DevelopBranch) ?
                                                         "echo." :
                                                         FormatCliCommand($"checkout -b {flowDialog.GitConfig.DevelopBranch}", false)),
                                                        "Initializing GitFlow"
                                                        );

            process.WaitForExit();

            _envHelper.ClearCache(CacheKeyEnum.GitConfig);
        }