Beispiel #1
0
        private void OnWizardCreate()
        {
            checkoutOptions.CheckoutModifiers = force ? CheckoutModifiers.Force : CheckoutModifiers.None;
            var branch = gitManager.Repository.Branches[branchNames[selectedBranch]];

            if (branch != null)
            {
                GitCommands.Checkout(gitManager.Repository, branch, checkoutOptions);
            }
            else
            {
                logger.LogFormat(LogType.Error, "Could not find branch with name: {0}", branchNames[selectedBranch]);
            }
        }
Beispiel #2
0
        public override void OnGUI(Rect rect)
        {
            GUILayout.Label(GitGUI.GetTempContent("Switch to: " + branch.FriendlyName), GitGUI.Styles.BigTitle, GUILayout.ExpandWidth(true));
            force = EditorGUILayout.Toggle(GitGUI.GetTempContent("Force", "Override working tree changes"), force);
            if (GUILayout.Button(GitGUI.GetTempContent("Siwtch")))
            {
                CheckoutOptions checkoutOptions = new CheckoutOptions()
                {
                    OnCheckoutNotify   = OnCheckoutNotify,
                    OnCheckoutProgress = OnCheckoutProgress
                };

                if (force)
                {
                    checkoutOptions.CheckoutModifiers = CheckoutModifiers.Force;
                }

                if (branch != null)
                {
                    try
                    {
                        GitCommands.Checkout(gitManager.Repository, branch, checkoutOptions);
                    }
                    catch (Exception e)
                    {
                        logger.LogFormat(LogType.Error, "There was a problem while switching to branch: {0}", branch.CanonicalName);
                        logger.LogException(e);
                    }
                    finally
                    {
                        gitCallbacks.IssueAssetDatabaseRefresh();
                        gitManager.MarkDirty(true);
                    }
                }
                else
                {
                    logger.Log(LogType.Error, "Trying to switch to null branch");
                }
            }
        }