Exemplo n.º 1
0
        protected virtual void ConstructGUI(VisualElement root)
        {
            root.styleSheets.Add(resourceManager.LoadUniGitAsset <StyleSheet>("Editor/UI/RootSheet.uss"));

            invalidRepoElement   = root.Q("InvalidRepository");
            invalidRepoPathLabel = invalidRepoElement.Q <Label>("RepoPath");
            var findRepositoryButton  = invalidRepoElement.Q <Button>("FindRepository");
            var invalidRepoHelpButton = invalidRepoElement.Q <Button>("Help");

            invalidRepoHelpButton.clickable.clicked += () => GitLinks.GoTo(GitLinks.ConfigurationHelp);

            invalidRepoElement.styleSheets.Add(resourceManager.LoadUniGitAsset <StyleSheet>("Editor/UI/InvalidRepositorySheet.uss"));
            if (invalidRepoElement != null)
            {
                invalidRepoElement.Q <Button>("CreateRepository").clickable.clicked += () =>
                {
                    if (!initializer.IsValidRepo)
                    {
                        initializer.InitializeRepositoryAndRecompile();
                    }
                };
            }

            findRepositoryButton.clickable.clicked += () =>
            {
                settingsManager.ShowChooseMainRepositoryPathPopup(this);
            };

            invalidRepoPathLabel.text = this.paths.RepoPath;
        }
Exemplo n.º 2
0
        private void DrawToolbar()
        {
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
            Rect goToLineRect = GUILayoutUtility.GetRect(GitGUI.GetTempContent("Go To Line"), EditorStyles.toolbarButton);

            if (GUI.Button(goToLineRect, GitGUI.GetTempContent("Go To Line"), EditorStyles.toolbarButton))
            {
                PopupWindow.Show(goToLineRect, new GoToLinePopup(GoToLine));
            }
            if (GUILayout.Button(GitGUI.GetTempContent("Previous Change"), EditorStyles.toolbarButton))
            {
                GoToPreviousChange();
            }
            if (GUILayout.Button(GitGUI.GetTempContent("Next Change"), EditorStyles.toolbarButton))
            {
                GoToNextChange();
            }
            GUILayout.FlexibleSpace();
            GUILayout.Label(GitGUI.GetTempContent(localPath));
            if (GitGUI.LinkButtonLayout(gitOverlay.icons.donateSmall, GitGUI.Styles.IconButton))
            {
                GitLinks.GoTo(GitLinks.Donate);
            }
            if (GitGUI.LinkButtonLayout(GitGUI.Contents.Help, GitGUI.Styles.IconButton))
            {
                GitLinks.GoTo(GitLinks.DiffInspectorHelp);
            }
            EditorGUILayout.EndHorizontal();
        }
Exemplo n.º 3
0
        private void OnGUI()
        {
            if (gitManager == null || !gitManager.IsValidRepo)
            {
                GitHistoryWindow.InvalidRepoGUI(gitManager);
                return;
            }

            Event current = Event.current;

            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
            EditorGUI.BeginChangeCheck();
            if (tabs != null)
            {
                for (int i = 0; i < tabs.Length; i++)
                {
                    bool value = GUILayout.Toggle(tab == i, tabs[i].Name, EditorStyles.toolbarButton);
                    if (value)
                    {
                        tab = i;
                    }
                }
            }
            if (EditorGUI.EndChangeCheck())
            {
                LoseFocus();
                if (currentTab != null)
                {
                    currentTab.OnFocus();
                }
            }
            GUILayout.FlexibleSpace();
            if (GitGUI.LinkButtonLayout(GitOverlay.icons.donateSmall, GitGUI.Styles.IconButton))
            {
                GitLinks.GoTo(GitLinks.Donate);
            }
            if (GitGUI.LinkButtonLayout(GitGUI.Contents.Help, GitGUI.Styles.IconButton))
            {
                GitLinks.GoTo(GitLinks.SettingsWindowHelp);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();
            if (gitManager.Repository != null)
            {
                Rect localRect = new Rect(0, 0, position.width, position.height - EditorGUIUtility.singleLineHeight * 1.6f);
                if (currentTab != null)
                {
                    currentTab.OnGUI(localRect, current);
                }
            }
            EditorGUILayout.Space();

            if (current.type == EventType.MouseDown)
            {
                LoseFocus();
            }
        }
Exemplo n.º 4
0
 public void AddItemsToMenu(GenericMenu menu)
 {
     if (gitManager == null)
     {
         return;
     }
     menu.AddItem(new GUIContent("Push"), false, GoToPush);
     menu.AddItem(new GUIContent("Pull"), false, GoToPull);
     menu.AddItem(new GUIContent("Fetch"), false, GoToFetch);
     menu.AddItem(new GUIContent("Merge"), false, GoToMerge);
     menu.AddItem(new GUIContent("Donate"), false, () => { GitLinks.GoTo(GitLinks.Donate); });
     menu.AddItem(new GUIContent("Help"), false, () => { GitLinks.GoTo(GitLinks.HistoryWindowHelp); });
 }
Exemplo n.º 5
0
 public void AddItemsToMenu(GenericMenu menu)
 {
     if (tabs != null)
     {
         foreach (var settingsTab in tabs)
         {
             var customMenu = settingsTab as IHasCustomMenu;
             if (customMenu != null)
             {
                 customMenu.AddItemsToMenu(menu);
             }
         }
     }
     menu.AddItem(new GUIContent("Donate"), false, () => { GitLinks.GoTo(GitLinks.Donate); });
     menu.AddItem(new GUIContent("Help"), false, () => { GitLinks.GoTo(GitLinks.SettingsWindowHelp); });
 }
Exemplo n.º 6
0
        protected override void ConstructGUI(VisualElement root)
        {
            var uxml = resourceManager.LoadUniGitAsset <VisualTreeAsset>("Editor/UI/SettingsWindow.uxml");
            var uss  = resourceManager.LoadUniGitAsset <StyleSheet>("Editor/UI/SettingsWindowSheet.uss");

            uxml.CloneTree(root);
            root.styleSheets.Add(uss);

            base.ConstructGUI(root);

            settingsWindowElement = root.Q("SettingsWindow");
            settingsTabsElement   = root.Q("SettingsTabs");
            tabsToolbar           = root.Q("TabsToolbar");
            helpButton            = root.Q <Button>("Help");
            donateButton          = root.Q <Button>("Donate");

            helpButton.clickable.clicked   += () => GitLinks.GoTo(GitLinks.SettingsWindowHelp);
            donateButton.clickable.clicked += () => GitLinks.GoTo(GitLinks.Donate);
        }
Exemplo n.º 7
0
 private static void Donate()
 {
     GitLinks.GoTo(GitLinks.Donate);
 }
Exemplo n.º 8
0
 private static void Help()
 {
     GitLinks.GoTo(GitLinks.Wiki);
 }
Exemplo n.º 9
0
 private static void ReportIssue()
 {
     GitLinks.GoTo(GitLinks.ReportIssue);
 }
Exemplo n.º 10
0
        internal override void OnGUI(Rect rect, Event current)
        {
            if (!lfsManager.Installed)
            {
                EditorGUILayout.HelpBox("Git LFS not installed", MessageType.Warning);
                if (GUILayout.Button(GitGUI.GetTempContent("Download")))
                {
                    GitLinks.GoTo(GitLinks.GitLFS);
                }
            }
            else
            {
                EditorGUI.BeginChangeCheck();
                gitManager.Settings.DisableGitLFS = EditorGUILayout.Toggle(GitGUI.GetTempContent("Disable Git LFS"), gitManager.Settings.DisableGitLFS);
                if (EditorGUI.EndChangeCheck())
                {
                    gitManager.Settings.MarkDirty();
                }

                if (!lfsManager.CheckInitialized())
                {
                    EditorGUILayout.HelpBox("Git LFS not Initialized", MessageType.Info);
                    if (GUILayout.Button(GitGUI.GetTempContent("Initialize")))
                    {
                        lfsManager.Initialize();
                    }
                }
                else
                {
                    GUILayout.Label(GitGUI.GetTempContent("Settings"), GitGUI.Styles.ProjectBrowserHeaderBgTop);

                    using (Configuration c = Configuration.BuildFrom(gitManager.RepoPath))
                    {
                        string url = c.GetValueOrDefault("lfs.url", "");
                        if (string.IsNullOrEmpty(url))
                        {
                            EditorGUILayout.HelpBox("You should specify a LFS server URL", MessageType.Warning);
                        }

                        GitGUI.DoConfigStringField(c, GitGUI.GetTempContent("URL"), "lfs.url", "");
                    }

                    EditorGUILayout.Space();

                    foreach (var info in lfsManager.TrackedInfo)
                    {
                        GUILayout.Label(GitGUI.GetTempContent(info.Extension), GitGUI.Styles.ShurikenModuleTitle);
                        GUI.SetNextControlName(info.GetHashCode() + " Extension");
                        info.Extension = EditorGUILayout.DelayedTextField(GitGUI.GetTempContent("Extension"), info.Extension);
                        GUI.SetNextControlName(info.GetHashCode() + " Type");
                        info.Type = (GitLfsTrackedInfo.TrackType)EditorGUILayout.EnumPopup(GitGUI.GetTempContent("Type"), info.Type);

                        if (info.IsDirty)
                        {
                            lfsManager.SaveTracking();
                            break;
                        }
                    }

                    if (GUILayout.Button("Track File"))
                    {
                        PopupWindow.Show(trackFileRect, new GitLfsTrackPopupWindow(settingsWindow, lfsManager));
                    }
                    if (current.type == EventType.Repaint)
                    {
                        trackFileRect = GUILayoutUtility.GetLastRect();
                    }
                }
            }

            EditorGUILayout.HelpBox("Git LFS is still in development, and is recommended to use an external program for handling it.", MessageType.Warning);
        }
Exemplo n.º 11
0
        internal override void OnGUI()
        {
            if (remotes == null)
            {
                return;
            }
            int remoteCount = remotes.Count();

            if (remoteCount <= 0)
            {
                EditorGUILayout.HelpBox("No Remotes", MessageType.Info);
            }

            scroll = EditorGUILayout.BeginScrollView(scroll);
            foreach (var remote in remoteCacheList)
            {
                GUILayout.Label(GitGUI.GetTempContent(remote.Name), GitGUI.Styles.ShurikenModuleTitle);
                EditorGUILayout.Space();
                EditorGUILayout.BeginVertical();
                EditorGUI.BeginChangeCheck();
                GUI.enabled = false;
                GUI.SetNextControlName(remote.GetHashCode() + " Remote Name");
                EditorGUILayout.TextField(GitGUI.GetTempContent("Name"), remote.Name);
                GUI.enabled = true;
                GUI.SetNextControlName(remote.GetHashCode() + " Remote URL");
                remote.Url = EditorGUILayout.DelayedTextField(GitGUI.GetTempContent("URL"), remote.Url);
                //remote.PushUrl = EditorGUILayout.DelayedTextField(new GUIContent("Push URL"), remote.PushUrl, "ShurikenValue");
                remote.TagFetchMode = (TagFetchMode)EditorGUILayout.EnumPopup(GitGUI.GetTempContent("Tag Fetch Mode"), remote.TagFetchMode);
                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button(GitGUI.GetTempContent("Save"), EditorStyles.miniButtonLeft))
                {
                    remote.Update(remotes);
                    UpdateRemotes();
                    GUI.FocusControl("");
                }
                if (GUILayout.Button(GitGUI.GetTempContent("Open", "Show the repository in browser."), EditorStyles.miniButtonMid))
                {
                    GitLinks.GoTo(remote.Url);
                }
                if (GUILayout.Button(GitGUI.GetTempContent("Remove"), EditorStyles.miniButtonRight))
                {
                    remotes.Remove(remote.Name);
                    UpdateRemotes();
                    GUI.FocusControl("");
                }
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndScrollView();

            GUILayout.FlexibleSpace();
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(GitGUI.IconContent("ol plus", "Add Remote"), GitGUI.Styles.AddComponentBtn))
            {
                PopupWindow.Show(addRepositoryButtonRect, new AddRepositoryPopup(gitManager, remotes));
            }
            if (Event.current.type == EventType.Repaint)
            {
                addRepositoryButtonRect = GUILayoutUtility.GetLastRect();
            }
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
        }
Exemplo n.º 12
0
 public void AddItemsToMenu(GenericMenu menu)
 {
     menu.AddItem(new GUIContent("♺ Reload"), false, ReloadCallback);
     menu.AddItem(new GUIContent("💰 Donate"), false, () => { GitLinks.GoTo(GitLinks.Donate); });
     menu.AddItem(new GUIContent("⛐ Help"), false, () => { GitLinks.GoTo(GitLinks.DiffWindowHelp); });
 }
Exemplo n.º 13
0
        internal override void OnGUI()
        {
            scroll = EditorGUILayout.BeginScrollView(scroll);
            //todo cache general settings to reduce lookup
            GUILayout.BeginHorizontal(GitGUI.Styles.BigTitle, GUILayout.ExpandWidth(true));
            GUILayout.FlexibleSpace();
            GUILayout.Label(GitGUI.IconContent("SceneAsset Icon", "Unity Settings"), GUILayout.Height(18));
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(GitGUI.Contents.Help, GitGUI.Styles.IconButton))
            {
                GitLinks.GoTo(GitLinks.SettingsUniGitSettings);
            }
            EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link);
            GUILayout.EndHorizontal();


            if (gitSettings != null)
            {
                bool save      = false;
                bool updateGit = false;

                EditorGUI.BeginChangeCheck();
                gitSettings.AutoStage = EditorGUILayout.Toggle(GitGUI.GetTempContent("Auto Stage", "Auto stage changes for committing when an asset is modified"), gitSettings.AutoStage);
                gitSettings.AutoFetch = EditorGUILayout.Toggle(GitGUI.GetTempContent("Auto Fetch", "Auto fetch repository changes when possible. This will tell you about changes to the remote repository without having to pull. This only works with the Credentials Manager."), gitSettings.AutoFetch);
                save |= EditorGUI.EndChangeCheck();

                EditorGUI.BeginChangeCheck();
                gitSettings.ProjectStatusOverlayDepth = EditorGUILayout.DelayedIntField(GitGUI.GetTempContent("Project Status Overlay Depth", "The maximum depth at which overlays will be shown in the Project Window. This means that folders at levels higher than this will not be marked as changed. -1 indicates no limit"), gitSettings.ProjectStatusOverlayDepth);
                gitSettings.ShowEmptyFolders          = EditorGUILayout.Toggle(GitGUI.GetTempContent("Show Empty Folders", "Show status for empty folder meta files and auto stage them, if 'Auto stage' option is enabled."), gitSettings.ShowEmptyFolders);
                GUIContent threadingContent = GitGUI.GetTempContent("Use Threading", "When Should Threading be used. In staging, unstaging or status retrival.");
                if ((gitSettings.Threading.IsFlagSet(GitSettingsJson.ThreadingType.Stage) || gitSettings.Threading.IsFlagSet(GitSettingsJson.ThreadingType.Unstage)) && lfsManager.Installed && lfsManager.CheckInitialized())
                {
                    threadingContent.image   = GitGUI.Textures.WarrningIconSmall;
                    threadingContent.tooltip = "Threaded 'Stage' and 'Unstage' are disabled when Git LFS is enabled.";
                }
                gitSettings.Threading = (GitSettingsJson.ThreadingType)EditorGUILayout.EnumFlagsField(threadingContent, gitSettings.Threading);

                gitSettings.UseGavatar            = EditorGUILayout.Toggle(GitGUI.GetTempContent("Use Gavatar", "Load Gavatars based on the committer's email address."), gitSettings.UseGavatar);
                gitSettings.MaxCommitTextAreaSize = EditorGUILayout.DelayedFloatField(GitGUI.GetTempContent("Max Commit Text Area Size", "The maximum height the commit text area can expand to."), gitSettings.MaxCommitTextAreaSize);
                GUIContent detectRenamesContent = GitGUI.GetTempContent("Detect Renames", "Detect Renames. This will make UniGit detect rename changes of files. Note that this feature is not always working as expected do the the modular updating and how Git itself works.");
                if (gitSettings.LazyMode)
                {
                    detectRenamesContent.image   = GitGUI.Textures.WarrningIconSmall;
                    detectRenamesContent.tooltip = "Rename Detection will not work properly in preview with lazy update, altho they WILL still be detected by Git internally.";
                }
                gitSettings.DetectRenames = (GitSettingsJson.RenameTypeEnum)EditorGUILayout.EnumFlagsField(detectRenamesContent, gitSettings.DetectRenames);
                if (EditorGUI.EndChangeCheck())
                {
                    save      = true;
                    updateGit = true;
                }

                EditorGUI.BeginChangeCheck();
                gitSettings.UseSimpleContextMenus = EditorGUILayout.Toggle(GitGUI.GetTempContent("Use Simple Context Menus", "Use Unity's default context menu on Diff window, instead of the UniGit one (with icons and animations)."), gitSettings.UseSimpleContextMenus);
                gitSettings.LazyMode                     = EditorGUILayout.Toggle(GitGUI.GetTempContent("Lazy Update Mode", "Without lazy mode, git status is updated on each assembly reload, leaving and entering play mode, staging, unstaging and any asset change."), gitSettings.LazyMode);
                gitSettings.TrackSystemFiles             = EditorGUILayout.Toggle(GitGUI.GetTempContent("Track System Files", "Should files and folders be tracked that are outside the 'Assets' folder? This should definitely be used if lazy mode is on."), gitSettings.TrackSystemFiles);
                gitSettings.UseUnityConsole              = EditorGUILayout.Toggle(GitGUI.GetTempContent("Use Unity's Console", "Show Info, Warning and Error messages in Unity's builtin console instead of the Git Log."), gitSettings.UseUnityConsole);
                gitSettings.AnimationType                = (GitSettingsJson.AnimationTypeEnum)EditorGUILayout.EnumFlagsField(GitGUI.GetTempContent("Animation Types", "Which animation are allowed?"), gitSettings.AnimationType);
                gitSettings.CreateFoldersForDriftingMeta = EditorGUILayout.Toggle(GitGUI.GetTempContent("Create Missing Meta Folders", "Create Missing Folders for .meta files. If a .meta folder is merged but the folder is not present, create it."), gitSettings.CreateFoldersForDriftingMeta);

                save |= EditorGUI.EndChangeCheck();

                if (save)
                {
                    gitSettings.MarkDirty();
                }
                if (updateGit)
                {
                    gitManager.MarkDirty();
                }
            }

            GUILayout.BeginHorizontal(GitGUI.Styles.BigTitle, GUILayout.ExpandWidth(true));
            GUILayout.FlexibleSpace();
            GUILayout.Label(GitGUI.IconContent("UnityEditor.SceneHierarchyWindow", "Git Settings"), GUILayout.Height(18));
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(GitGUI.Contents.Help, GitGUI.Styles.IconButton))
            {
                GitLinks.GoTo(GitLinks.SettingsGitSettings);
            }
            EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link);
            GUILayout.EndHorizontal();

            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.TextField(new GUIContent("Repository Path"), paths.RepoPath);
            EditorGUI.EndDisabledGroup();

            GUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel(GitGUI.GetTempContent("Main Path"));
            if (GUILayout.Button("Select Main Repository Path", EditorStyles.miniButton))
            {
                settingsManager.ShowChooseMainRepositoryPathPopup(settingsWindow);
                GUIUtility.ExitGUI();
            }
            GUILayout.EndHorizontal();

            string currentConfigFolder = gitManager.GetCurrentDotGitFolder();

            if (Directory.Exists(currentConfigFolder))
            {
                using (Configuration c = Configuration.BuildFrom(currentConfigFolder))
                {
                    EditorGUILayout.LabelField(GitGUI.GetTempContent("User"), EditorStyles.boldLabel);
                    EditorGUI.indentLevel = 1;
                    GitGUI.DoConfigStringField(c, GitGUI.GetTempContent("Name", "Your full name to be recorded in any newly created commits."), "user.name", "");
                    GitGUI.DoConfigStringField(c, GitGUI.GetTempContent("Email", "Your email address to be recorded in any newly created commits."), "user.email", "");
                    EditorGUI.indentLevel = 0;

                    EditorGUILayout.LabelField(GitGUI.GetTempContent("Core"), EditorStyles.boldLabel);
                    EditorGUI.indentLevel = 1;
                    GitGUI.DoConfigToggle(c, GitGUI.GetTempContent("Auto LF line endings", "Setting this variable to 'true' is the same as setting the text attribute to 'auto' on all files and core.eol to 'crlf'. Set to true if you want to have CRLF line endings in your working directory and the repository has LF line endings. "), "core.autocrlf", true);
                    GitGUI.DoConfigToggle(c, GitGUI.GetTempContent("Bare", "If true this repository is assumed to be bare and has no working directory associated with it. If this is the case a number of commands that require a working directory will be disabled, such as git-add[1] or git-merge[1]."), "core.bare", false);
                    GitGUI.DoConfigToggle(c, GitGUI.GetTempContent("Symlinks", "If false, symbolic links are checked out as small plain files that contain the link text. git-update-index[1] and git-add[1] will not change the recorded type to regular file. Useful on filesystems like FAT that do not support symbolic links."), "core.symlinks", false);
                    GitGUI.DoConfigToggle(c, GitGUI.GetTempContent("Ignore Case", "If true, this option enables various workarounds to enable Git to work better on filesystems that are not case sensitive, like FAT. For example, if a directory listing finds 'makefile' when Git expects 'Makefile', Git will assume it is really the same file, and continue to remember it as 'Makefile'."), "core.ignorecase", true);
                    GitGUI.DoConfigToggle(c, GitGUI.GetTempContent("Logal Reference Updates", "Enable the reflog."), "core.logallrefupdates", true);
                    GitGUI.DoConfigIntSlider(c, GitGUI.GetTempContent("Compression", "An integer -1..9, indicating a default compression level. -1 is the zlib default. 0 means no compression, and 1..9 are various speed/size tradeoffs, 9 being slowest."), -1, 9, "core.compression", -1);
                    GitGUI.DoConfigStringField(c, GitGUI.GetTempContent("Big File Threshold", "Files larger than this size are stored deflated, without attempting delta compression. Storing large files without delta compression avoids excessive memory usage, at the slight expense of increased disk usage. Additionally files larger than this size are always treated as binary."), "core.bigFileThreshold", "512m");
                    EditorGUI.indentLevel = 0;

                    EditorGUILayout.LabelField(GitGUI.GetTempContent("Branch"), EditorStyles.boldLabel);
                    EditorGUI.indentLevel = 1;
                    GitGUI.DoConfigStringsField(c, GitGUI.GetTempContent("Auto Setup Rebase", "When a new branch is created with git branch or git checkout that tracks another branch, this variable tells Git to set up pull to rebase instead of merge."), "branch.autoSetupRebase", autoRebaseOptions, "never");
                    EditorGUI.indentLevel = 0;

                    EditorGUILayout.LabelField(GitGUI.GetTempContent("Diff"), EditorStyles.boldLabel);
                    EditorGUI.indentLevel = 1;
                    GitGUI.DoConfigToggle(c, GitGUI.GetTempContent("Renames", "Whether and how Git detects renames. If set to 'false', rename detection is disabled. If set to 'true', basic rename detection is enabled. "), "diff.renames", true);
                    GitGUI.DoConfigIntField(c, GitGUI.GetTempContent("Rename Limit", "The number of files to consider when performing the copy/rename detection. Use -1 for unlimited"), "diff.renameLimit", -1);
                    EditorGUI.indentLevel = 0;

                    EditorGUILayout.LabelField(GitGUI.GetTempContent("HTTP"), EditorStyles.boldLabel);
                    EditorGUI.indentLevel = 1;
                    GitGUI.DoConfigToggle(c, GitGUI.GetTempContent("Verify SSL Crtificate", "Whether to verify the SSL certificate when fetching or pushing over HTTPS."), "http.sslVerify", true);
                    string oldPath = c.GetValueOrDefault <string>("http.sslCAInfo");
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.PrefixLabel(GitGUI.GetTempContent("SSL Certificate File", "File containing the certificates to verify the peer with when fetching or pushing over HTTPS."));
                    if (GUILayout.Button(GitGUI.GetTempContent(oldPath), "TE ToolbarDropDown"))
                    {
                        EditorGUI.BeginChangeCheck();
                        string newPath = EditorUtility.OpenFilePanelWithFilters("Certificate", string.IsNullOrEmpty(oldPath) ? Application.dataPath : Path.GetFullPath(oldPath), new string[] { "", "cer", "", "pom", "", "crt" });
                        if (oldPath != newPath)
                        {
                            c.Set("http.sslCAInfo", newPath);
                        }
                    }

                    EditorGUILayout.EndHorizontal();
                    EditorGUI.indentLevel = 0;
                }
            }

            GUILayout.BeginHorizontal(GitGUI.Styles.BigTitle, GUILayout.ExpandWidth(true));
            GUILayout.FlexibleSpace();
            GUILayout.Label(GitGUI.IconContent("IN LockButton on", "Git Ignore"), GUILayout.Height(18));
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(GitGUI.Contents.Help, GitGUI.Styles.IconButton))
            {
                GitLinks.GoTo(GitLinks.SettingsGitIgnoreHelp);
            }
            EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link);
            GUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(GitGUI.IconContent("IN LockButton on", "Open Git Ignore File")))
            {
                OpenGitIgnore();
            }
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndScrollView();
        }
        internal void DoCommit(RepositoryInformation repoInfo, GitDiffWindow window, ref Vector2 commitScroll)
        {
            var settings = window.GitDiffSettings;

            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            if (repoInfo.CurrentOperation == CurrentOperation.Merge)
            {
                GUILayout.Label(GitGUI.GetTempContent("Merge"), styles.mergeIndicator);
            }
            window.CommitMaximized = GUILayout.Toggle(window.CommitMaximized, GitGUI.GetTempContent(gitSettings.ReadFromFile ? "File Commit Message: (Read Only)" : "Commit Message: "), styles.commitMessageFoldoud, GUILayout.Width(gitSettings.ReadFromFile ? 210 : 116));
            EditorGUI.BeginDisabledGroup(true);
            if (!window.CommitMaximized)
            {
                if (!gitSettings.ReadFromFile)
                {
                    EditorGUI.BeginChangeCheck();
                    GUI.SetNextControlName("Commit Message Field");
                    settings.commitMessage = EditorGUILayout.TextArea(settings.commitMessage, GUILayout.Height(EditorGUIUtility.singleLineHeight));
                    if (EditorGUI.EndChangeCheck())
                    {
                        window.SaveCommitMessage();
                    }
                }
                else
                {
                    GUILayout.Label(GitGUI.GetTempContent(settings.commitMessageFromFile), GUI.skin.textArea, GUILayout.Height(EditorGUIUtility.singleLineHeight));
                }
            }
            EditorGUI.EndDisabledGroup();
            EditorGUILayout.EndHorizontal();
            if (window.CommitMaximized)
            {
                commitScroll = EditorGUILayout.BeginScrollView(commitScroll, GUILayout.Height(window.CalculateCommitTextHeight()));
                if (!gitSettings.ReadFromFile)
                {
                    EditorGUI.BeginChangeCheck();
                    GUI.SetNextControlName("Commit Message Field");
                    string newCommitMessage = EditorGUILayout.TextArea(settings.commitMessage, GUILayout.ExpandHeight(true));
                    if (EditorGUI.EndChangeCheck())
                    {
                        if ((Event.current.character == ' ' || Event.current.character == '\0') && !(commitMessageLastChar == ' ' || commitMessageLastChar == '\0'))
                        {
                            if (Undo.GetCurrentGroupName() == GitDiffWindow.CommitMessageUndoGroup)
                            {
                                Undo.IncrementCurrentGroup();
                            }
                        }
                        commitMessageLastChar = Event.current.character;
                        Undo.RecordObject(window, GitDiffWindow.CommitMessageUndoGroup);
                        settings.commitMessage = newCommitMessage;
                        window.SaveCommitMessage();
                    }
                }
                else
                {
                    GUILayout.Label(GitGUI.GetTempContent(settings.commitMessageFromFile), GUI.skin.textArea, GUILayout.ExpandHeight(true));
                }
                EditorGUILayout.EndScrollView();
            }

            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button(GitGUI.GetTempContent("Commit"), styles.commitButton))
            {
                GenericMenu commitMenu = new GenericMenu();
                BuildCommitMenu(commitMenu, window);
                commitMenu.ShowAsContext();
            }
            GitGUI.StartEnable(!gitSettings.ExternalsType.IsFlagSet(GitSettingsJson.ExternalsTypeEnum.Commit));
            settings.emptyCommit = GUILayout.Toggle(settings.emptyCommit, GitGUI.GetTempContent("Empty Commit", "Commit the message only without changes"));
            EditorGUI.BeginChangeCheck();
            settings.amendCommit = GUILayout.Toggle(settings.amendCommit, GitGUI.GetTempContent("Amend Commit", "Amend previous commit."));
            if (EditorGUI.EndChangeCheck())
            {
                if (settings.amendCommit)
                {
                    window.AmmendCommit();
                }
            }
            settings.prettify = GUILayout.Toggle(settings.prettify, GitGUI.GetTempContent("Prettify", "Prettify the commit message"));
            GitGUI.EndEnable();
            GUILayout.FlexibleSpace();
            if (GitGUI.LinkButtonLayout(gitOverlay.icons.donateSmall, GitGUI.Styles.IconButton))
            {
                GitLinks.GoTo(GitLinks.Donate);
            }
            if (GitGUI.LinkButtonLayout(GitGUI.Contents.Help, GitGUI.Styles.IconButton))
            {
                GitLinks.GoTo(GitLinks.DiffWindowHelp);
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
        }
Exemplo n.º 15
0
        private void DoToolbar(Rect rect, RepositoryInformation info)
        {
            Branch branch = selectedBranch.LoadBranch(gitManager);

            if (branch == null)
            {
                EditorGUILayout.HelpBox(string.Format("Invalid Branch: '{0}'", selectedBranch.CanonicalName), MessageType.Warning, true);
                return;
            }

            GitGUI.StartEnable();
            GitProfilerProxy.BeginSample("Git History Window Toolbar GUI", this);
            GUI.Box(rect, GUIContent.none, EditorStyles.toolbar);
            Rect       btRect            = new Rect(rect.x, rect.y, 64, rect.height);
            GUIContent pushButtonContent = GitGUI.GetTempContent("Push", GitGUI.Textures.CollabPush, "Push local changes to a remote repository.");

            if (info.CurrentOperation == CurrentOperation.Merge)
            {
                GUI.enabled = false;
                pushButtonContent.tooltip = "Do a Merge commit before pushing.";
            }
            else if (hasConflicts)
            {
                GUI.enabled = false;
                pushButtonContent.tooltip = "Resolve conflicts before pushing.";
            }
            else if (selectedBranch == null)
            {
                GUI.enabled = false;
                pushButtonContent.tooltip = "No Selected branch. Create a new branch or create atleast one commit.";
            }
            if (GUI.Button(btRect, pushButtonContent, EditorStyles.toolbarButton))
            {
                GoToPush();
            }
            btRect      = new Rect(btRect.x + 64, btRect.y, 64, btRect.height);
            GUI.enabled = !hasConflicts;
            if (GUI.Button(btRect, GitGUI.IconContent("CollabPull", "Pull", hasConflicts ? "Must resolve conflicts before pulling" : "Pull changes from remote repository by fetching them and then merging them. This is the same as calling Fetch then Merge."), EditorStyles.toolbarButton))
            {
                GoToPull();
            }
            btRect = new Rect(btRect.x + 70, btRect.y, 64, btRect.height);
            GUIContent fetchContent = GitGUI.GetTempContent("Fetch", GitOverlay.icons.fetch.image, "Get changes from remote repository but do not merge them.");

            if (branch.Remote != null)
            {
                fetchContent.tooltip = "Branch does not have a remote.";
                GUI.enabled          = false;
            }
            if (GUI.Button(btRect, fetchContent, EditorStyles.toolbarButton))
            {
                GoToFetch();
            }
            GUI.enabled = true;
            btRect      = new Rect(btRect.x + 64, btRect.y, 64, btRect.height);
            if (GUI.Button(btRect, GitGUI.GetTempContent("Merge", GitOverlay.icons.merge.image, hasConflicts ? "Must Resolve conflict before merging" : "Merge fetched changes from remote repository. Changes from the latest fetch will be merged."), EditorStyles.toolbarButton))
            {
                GoToMerge();
            }
            GUI.enabled = gitManager.IsValidRepo;
            btRect      = new Rect(btRect.x + 64, btRect.y, 64, btRect.height);
            if (GUI.Button(btRect, GitGUI.GetTempContent("Stash", GitOverlay.icons.stashIcon.image), EditorStyles.toolbarButton))
            {
                PopupWindow.Show(btRect, new GitStashWindow(gitManager));
            }
            GUI.enabled = true;

            GUIContent branchNameContent = GitGUI.GetTempContent(string.IsNullOrEmpty(selectedBranchName) ? "Branch" : selectedBranch.FriendlyName);

            if (selectedBranch.IsRemote)
            {
                branchNameContent.image = GitGUI.IconContentTex("ToolHandleGlobal");
            }
            else if (!selectedBranch.IsCurrentRepositoryHead)
            {
                branchNameContent.image = GitGUI.IconContentTex("IN LockButton on");
            }

            float branchNameWidth = EditorStyles.toolbarDropDown.CalcSize(branchNameContent).x;

            btRect = new Rect(rect.x + rect.width - branchNameWidth, btRect.y, branchNameWidth, btRect.height);
            if (GUI.Button(btRect, branchNameContent, EditorStyles.toolbarDropDown))
            {
                GenericMenu selectBranchMenu = new GenericMenu();
                foreach (var cachedBranch in cachedBranches)
                {
                    selectBranchMenu.AddItem(new GUIContent(cachedBranch.FriendlyName), selectedBranchName == cachedBranch.CanonicalName, (b) =>
                    {
                        SetSelectedBranch((string)b);
                        StartUpdateChaches(cachedStatus);
                    }, cachedBranch.CanonicalName);
                }
                selectBranchMenu.ShowAsContext();
            }
            GitGUI.EndEnable();
            btRect = new Rect(btRect.x - 64, btRect.y, 64, btRect.height);
            GitGUI.StartEnable(gitManager.Settings.ExternalsType.IsFlagSet(GitSettingsJson.ExternalsTypeEnum.Switch) || (!selectedBranch.IsRemote && !selectedBranch.IsCurrentRepositoryHead));
            if (GUI.Button(btRect, GitGUI.GetTempContent("Switch", GitOverlay.icons.checkout.image, selectedBranch.IsRemote ? "Cannot switch to remote branches." : selectedBranch.IsCurrentRepositoryHead ? "This branch is the active one" : "Switch to another branch"), EditorStyles.toolbarButton))
            {
                if (externalManager.TakeSwitch())
                {
                    gitManager.Callbacks.IssueAssetDatabaseRefresh();
                    gitManager.MarkDirty();
                }
                else
                {
                    PopupWindow.Show(btRect, new GitCheckoutWindowPopup(gitManager, selectedBranch.LoadBranch(gitManager)));
                }
            }
            GitGUI.EndEnable();
            btRect = new Rect(btRect.x - 21, btRect.y + 1, 21, btRect.height);
            EditorGUIUtility.AddCursorRect(btRect, MouseCursor.Link);
            if (GUI.Button(btRect, GitGUI.Contents.Help, GitGUI.Styles.IconButton))
            {
                GitLinks.GoTo(GitLinks.HistoryWindowHelp);
            }
            GitProfilerProxy.EndSample();
        }
Exemplo n.º 16
0
 public void AddItemsToMenu(GenericMenu menu)
 {
     menu.AddItem(new GUIContent("Donate"), false, () => { GitLinks.GoTo(GitLinks.Donate); });
     menu.AddItem(new GUIContent("Help"), false, () => { GitLinks.GoTo(GitLinks.DiffInspectorHelp); });
 }