Exemple #1
0
        private void MainGUI()
        {
            RepositoryInformation repoInfo = gitManager.Repository.Info;

            GUILayout.BeginArea(CommitRect);
            gitDiffWindowCommitRenderer.DoCommit(repoInfo, this, ref commitScroll);
            GUILayout.EndArea();

            toolbarRenderer.DoDiffToolbar(DiffToolbarRect, this, ref filter);

            if (diffWindowStatusList == null)
            {
                if (gitSettings.AnimationType.HasFlag(GitSettingsJson.AnimationTypeEnum.Loading))
                {
                    Repaint();
                }
                GitGUI.DrawLoading(new Rect(0, 0, position.width, position.height), GitGUI.GetTempContent(GetStatusBuildingState()));
            }
            else
            {
                DoDiffScroll(Event.current);
            }


            editoSerializedObject.ApplyModifiedProperties();

            if (Event.current.type == EventType.MouseDown)
            {
                GUIUtility.keyboardControl = 0;
                GUI.FocusControl(null);
            }
        }
Exemple #2
0
        private void DoRemotes(Event current)
        {
            int remoteCount = remotes.Count();

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

            foreach (var remote in remoteCacheList)
            {
                GUILayout.Label(GitGUI.GetTempContent(remote.Name), "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"), "minibuttonleft"))
                {
                    remote.Update(remotes);
                    UpdateRemotes();
                    GUI.FocusControl("");
                }
                if (GUILayout.Button(GitGUI.GetTempContent("Open", "Show the repository in browser."), "minibuttonmid"))
                {
                    Application.OpenURL(remote.Url);
                }
                if (GUILayout.Button(GitGUI.GetTempContent("Remove"), "minibuttonright"))
                {
                    remotes.Remove(remote.Name);
                    UpdateRemotes();
                    GUI.FocusControl("");
                }
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();
                EditorGUILayout.EndVertical();
            }

            GUILayout.FlexibleSpace();
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(GitGUI.GetTempContent("Add Remote"), "LargeButton"))
            {
                PopupWindow.Show(addRepositoryButtonRect, new AddRepositoryPopup(remotes));
            }
            if (current.type == EventType.Repaint)
            {
                addRepositoryButtonRect = GUILayoutUtility.GetLastRect();
            }
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
        }
        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();
        }
Exemple #4
0
 protected void DrawBranchSelection()
 {
     EditorGUILayout.BeginHorizontal();
     EditorGUILayout.PrefixLabel(GitGUI.GetTempContent("Branch"));
     selectedBranch = EditorGUILayout.Popup(selectedBranch, branchFriendlyNames);
     EditorGUILayout.EndHorizontal();
 }
        internal static void InvalidRepoGUI()
        {
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Box(GitGUI.GetTempContent("Not a GIT Repository"), "NotificationBackground");
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            //initialization tips
            EditorGUILayout.HelpBox("If you have an existing remote repository and want to clone it, you will have to do so outside of the editor.", MessageType.Info);
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(GitGUI.GetTempContent("Create"), "LargeButton", GUILayout.Height(32), GUILayout.Width(128)))
            {
                if (EditorUtility.DisplayDialog("Initialize Repository", "Are you sure you want to initialize a Repository for your project", "Yes", "Cancel"))
                {
                    GitManager.InitilizeRepository();
                    GUIUtility.ExitGUI();
                    return;
                }
            }
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
        }
Exemple #6
0
 protected override bool DrawWizardGUI()
 {
     EditorGUI.BeginChangeCheck();
     DrawBranchSelection();
     force = EditorGUILayout.Toggle(GitGUI.GetTempContent("Force", "Override working tree changes"), force);
     return(EditorGUI.EndChangeCheck());
 }
Exemple #7
0
 protected override bool DrawWizardGUI()
 {
     EditorGUILayout.LabelField(GitGUI.GetTempContent("Stash Message:"));
     stashMessage   = EditorGUILayout.TextArea(stashMessage, GUILayout.Height(EditorGUIUtility.singleLineHeight * 6));
     stashModifiers = (StashModifiers)EditorGUILayout.EnumFlagsField("Stash Modifiers", stashModifiers);
     return(false);
 }
        protected override bool DrawWizardGUI()
        {
            EditorGUI.BeginChangeCheck();
            GUILayout.Label(path, EditorStyles.largeLabel);
            if (submodule != null)
            {
                GUILayout.Label("URL: " + submodule.Url, EditorStyles.miniLabel);
                if (submodule.WorkDirCommitId != null)
                {
                    GUILayout.Label("Workdir: " + submodule.WorkDirCommitId.Sha, EditorStyles.miniLabel);
                }
                if (submodule.HeadCommitId != null)
                {
                    GUILayout.Label("Head: " + submodule.HeadCommitId.Sha, EditorStyles.miniLabel);
                }

                if (submodule.HeadCommitId != submodule.WorkDirCommitId)
                {
                    EditorGUILayout.HelpBox("Sub module out of sync with super project. Updating sub module will reset it to it's original index.", MessageType.Warning);
                }
            }
            EditorGUILayout.Space();
            DrawCredentials();
            init = EditorGUILayout.Toggle(GitGUI.GetTempContent("Init"), init);
            return(false);
        }
Exemple #9
0
        private IEnumerable <GUIContent> GetIcons(FileStatus status, SubmoduleStatus submoduleStatus, bool isSubModule)
        {
            foreach (var s in gitOverlay.GetDiffTypeIcons(status, true))
            {
                yield return(s);
            }
            if (isSubModule)
            {
                yield return(gitOverlay.icons.submoduleIconSmall);

                if (submoduleStatus.HasFlag(SubmoduleStatus.WorkDirFilesModified))
                {
                    yield return(gitOverlay.icons.modifiedIconSmall);
                }
                if (submoduleStatus.HasFlag(SubmoduleStatus.WorkDirFilesUntracked))
                {
                    yield return(gitOverlay.icons.untrackedIconSmall);
                }
                if (submoduleStatus.HasFlag(SubmoduleStatus.WorkDirFilesIndexDirty))
                {
                    yield return(gitOverlay.icons.addedIconSmall);
                }
                if (submoduleStatus.HasFlag(SubmoduleStatus.WorkDirModified))
                {
                    yield return(GitGUI.GetTempContent(GitGUI.Textures.CollabPush));
                }
            }
        }
Exemple #10
0
        private void DoExternals(Event current)
        {
            if (serializedSettings == null)
            {
                return;
            }
            SerializedProperty externalTypesProperty = serializedSettings.FindProperty("ExternalsType");

            if (externalTypesProperty != null)
            {
                externalTypesProperty.intValue = (int)(GitSettings.ExternalsTypeEnum)EditorGUILayout.EnumMaskField(GitGUI.GetTempContent("External Program Uses", "Use an external program for more advanced features like pushing, pulling, merging and so on"), (GitSettings.ExternalsTypeEnum)externalTypesProperty.intValue);
                if (serializedSettings.ApplyModifiedProperties())
                {
                    AssetDatabase.SaveAssets();
                }
            }

            SerializedProperty externalProgramProperty = serializedSettings.FindProperty("ExternalProgram");

            if (externalProgramProperty != null)
            {
                int newSelectedIndex = EditorGUILayout.Popup(GitGUI.GetTempContent("External Program", "The name of the External program to use"), GitExternalManager.SelectedAdapterIndex, GitExternalManager.AdapterNames);
                externalProgramProperty.stringValue = GitExternalManager.AdapterNames[newSelectedIndex].text;
                if (serializedSettings.ApplyModifiedPropertiesWithoutUndo())
                {
                    GitExternalManager.SetSelectedAdapter(newSelectedIndex);
                    AssetDatabase.SaveAssets();
                }
            }
        }
Exemple #11
0
            public override void OnGUI(Rect rect)
            {
                EditorGUILayout.Space();
                resetMode = (ResetMode)EditorGUILayout.EnumPopup(GitGUI.GetTempContent("Reset Type"), resetMode);
                switch (resetMode)
                {
                case ResetMode.Soft:
                    EditorGUILayout.HelpBox("Leave working tree and index untouched", MessageType.Info);
                    break;

                case ResetMode.Mixed:
                    EditorGUILayout.HelpBox("Leave working tree untouched,reset index (Default)", MessageType.Info);
                    break;

                case ResetMode.Hard:
                    EditorGUILayout.HelpBox("Reset working tree and index (Will delete all files)", MessageType.Error);
                    break;
                }
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Reset"))
                {
                    if (EditorUtility.DisplayDialog("Reset", "Are you sure you want to reset to the selected commit", "Reset", "Cancel"))
                    {
                        GitProfilerProxy.BeginSample("Git Reset Popup", editorWindow);
                        GitManager.Repository.Reset(resetMode, commit, checkoutOptions);
                        GitManager.MarkDirty(true);
                        editorWindow.Close();
                        GitProfilerProxy.EndSample();
                        AssetDatabase.Refresh();
                    }
                }
                EditorGUILayout.Space();
            }
Exemple #12
0
        private void DoWarningBox(Rect rect, RepositoryInformation info, BranchInfo branch)
        {
            int?       behindBy = selectedBranch.TrackingDetails.BehindBy;
            GUIContent content  = GUIContent.none;

            if (info.CurrentOperation == CurrentOperation.Merge)
            {
                content = GitGUI.GetTempContent("Merging with remote branch in progress. You <b>must</b> do a merge commit before pushing.");
            }
            else if (behindBy != null && behindBy.Value > 0)
            {
                content = GitGUI.GetTempContent(string.Format("Branch <b>{0}</b> behind tracked branch <b>{1}</b>", selectedBranch.FriendlyName, selectedBranch.TrackedBranch));
            }
            else if (branch.IsRemote)
            {
                content = GitGUI.GetTempContent("Viewing a remote branch. Showing local history of remote branch.");
            }
            else if (!branch.IsCurrentRepositoryHead)
            {
                content = GitGUI.GetTempContent("Viewing a branch that is not the HEAD.");
            }

            GUI.Box(rect, content, styles.historyHelpBox);
            GUI.Box(rect, GUIContent.none, styles.historyHelpBoxLabel);
        }
Exemple #13
0
        private void DoLFS(Event current)
        {
            if (!GitLfsManager.Installed)
            {
                EditorGUILayout.HelpBox("Git LFS not installed", MessageType.Warning);
                if (GUILayout.Button(GitGUI.GetTempContent("Download")))
                {
                    Application.OpenURL("https://git-lfs.github.com/");
                }
                return;
            }

            if (!GitLfsManager.CheckInitialized())
            {
                EditorGUILayout.HelpBox("Git LFS not Initialized", MessageType.Info);
                if (GUILayout.Button(GitGUI.GetTempContent("Initialize")))
                {
                    GitLfsManager.Initialize();
                }
                return;
            }

            GUILayout.Label(GitGUI.GetTempContent("Settings"), "ProjectBrowserHeaderBgTop");


            string url = GitManager.Repository.Config.GetValueOrDefault("lfs.url", "");

            if (string.IsNullOrEmpty(url))
            {
                EditorGUILayout.HelpBox("You should specify a LFS server URL", MessageType.Warning);
            }

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

            EditorGUILayout.Space();

            foreach (var info in GitLfsManager.TrackedInfo)
            {
                GUILayout.Label(GitGUI.GetTempContent(info.Extension), "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)
                {
                    GitLfsManager.SaveTracking();
                    break;
                }
            }

            if (GUILayout.Button("Track File"))
            {
                PopupWindow.Show(trackFileRect, new GitLfsTrackPopupWindow(this));
            }
            if (current.type == EventType.Repaint)
            {
                trackFileRect = GUILayoutUtility.GetLastRect();
            }
        }
        internal override void OnGUI(Rect rect, Event current)
        {
            GitSettingsJson settings = gitManager.Settings;

            if (settings == null)
            {
                return;
            }

            EditorGUI.BeginChangeCheck();
            settings.ExternalsType = (GitSettingsJson.ExternalsTypeEnum)EditorGUILayout.EnumFlagsField(GitGUI.GetTempContent("External Program Uses", "Use an external program for more advanced features like pushing, pulling, merging and so on"), settings.ExternalsType);
            if (EditorGUI.EndChangeCheck())
            {
                settings.MarkDirty();
            }

            EditorGUI.BeginChangeCheck();
            int newSelectedIndex = EditorGUILayout.Popup(GitGUI.GetTempContent("External Program", "The name of the External program to use"), externalManager.SelectedAdapterIndex, externalManager.AdapterNames);

            settings.ExternalProgram = externalManager.AdapterNames[newSelectedIndex].text;
            if (EditorGUI.EndChangeCheck())
            {
                externalManager.SetSelectedAdapter(newSelectedIndex);
                settings.MarkDirty();
            }

            EditorGUILayout.HelpBox("Using external programs is always recommended as UniGit is still in development.", MessageType.Info);
        }
Exemple #15
0
 private float GetLineWidth(string line)
 {
     if (string.IsNullOrEmpty(line))
     {
         return(0);
     }
     return(styles.NormalLine.CalcSize(GitGUI.GetTempContent(line)).x);
 }
Exemple #16
0
 public override void OnGUI(Rect rect)
 {
     EditorGUILayout.SelectableLabel(commit.Message, "AS TextArea");
     EditorGUILayout.TextField(GitGUI.GetTempContent("Author"), commit.Author.Name);
     EditorGUILayout.TextField(GitGUI.GetTempContent("Author Email"), commit.Author.Email);
     EditorGUILayout.TextField(GitGUI.GetTempContent("Date"), commit.Author.When.ToString());
     EditorGUILayout.TextField(GitGUI.GetTempContent("Revision (SHA)"), commit.Sha);
 }
Exemple #17
0
 protected override bool DrawWizardGUI()
 {
     EditorGUI.BeginChangeCheck();
     DrawRemoteSelection();
     DrawCredentials();
     prune = EditorGUILayout.Toggle(GitGUI.GetTempContent("Prune", "Prune all unreachable objects from the object database"), prune);
     return(EditorGUI.EndChangeCheck());
 }
Exemple #18
0
 protected override bool DrawWizardGUI()
 {
     prune               = EditorGUILayout.Toggle(GitGUI.GetTempContent("Prune", "Prune all unreachable objects from the object database"), prune);
     commitOnSuccess     = EditorGUILayout.Toggle(GitGUI.GetTempContent("Commit on success"), commitOnSuccess);
     fastForwardStrategy = (FastForwardStrategy)EditorGUILayout.EnumPopup(GitGUI.GetTempContent("Fast Forward Strategy"), fastForwardStrategy);
     mergeFileFavor      = (ConflictMergeType)EditorGUILayout.EnumPopup(GitGUI.GetTempContent("File Merge Favor"), mergeFileFavor);
     return(false);
 }
Exemple #19
0
 public override void OnGUI(Rect rect)
 {
     line = EditorGUILayout.IntField(GitGUI.GetTempContent("Line"), line);
     if (GUILayout.Button(GitGUI.GetTempContent("Go To Line")))
     {
         gotoLineAction.Invoke(line);
         editorWindow.Close();
     }
 }
 protected override bool DrawWizardGUI()
 {
     GUILayout.Label(GitGUI.GetTempContent("Fetch Settings:"), "ProjectBrowserHeaderBgMiddle");
     base.DrawWizardGUI();
     prune = EditorGUILayout.Toggle(GitGUI.GetTempContent("Prune", "Prune all unreachable objects from the object database"), prune);
     GUILayout.Label(GitGUI.GetTempContent("Merge Settings:"), "ProjectBrowserHeaderBgMiddle");
     prune               = EditorGUILayout.Toggle(GitGUI.GetTempContent("Prune", "Prune all unreachable objects from the object database"), prune);
     commitOnSuccess     = EditorGUILayout.Toggle(GitGUI.GetTempContent("Commit on success"), commitOnSuccess);
     fastForwardStrategy = (FastForwardStrategy)EditorGUILayout.EnumPopup(GitGUI.GetTempContent("Fast Forward Strategy"), fastForwardStrategy);
     mergeFileFavor      = (ConflictMergeType)EditorGUILayout.EnumPopup(GitGUI.GetTempContent("File Merge Favor"), mergeFileFavor);
     return(false);
 }
Exemple #21
0
 public override void OnInspectorGUI()
 {
     EditorGUILayout.HelpBox("Open the 'Git Settings' window to change the settings.", MessageType.Info);
     EditorGUILayout.BeginHorizontal();
     GUILayout.FlexibleSpace();
     if (GUILayout.Button(GitGUI.GetTempContent("Open Settings"), GitGUI.Styles.AddComponentBtn))
     {
         UniGitLoader.GetWindow <GitSettingsWindow>();
     }
     GUILayout.FlexibleSpace();
     EditorGUILayout.EndHorizontal();
 }
 public override void OnGUI(Rect rect)
 {
     extension = EditorGUILayout.TextField(GitGUI.GetTempContent("Extension"), extension);
     GitGUI.StartEnable(!string.IsNullOrEmpty(extension));
     if (GUILayout.Button(GitGUI.GetTempContent("Track")))
     {
         lfsManager.Track(extension);
         focusWindow.Focus();
         focusWindow.ShowNotification(new GUIContent(extension + " now tracked by LFS."));
         lfsManager.Update();
     }
     GitGUI.EndEnable();
 }
        public override void OnGUI(Rect rect)
        {
            GUILayout.Label(new GUIContent("Create Branch"), "IN BigTitle", GUILayout.ExpandWidth(true));
            if (commit != null)
            {
                name = EditorGUILayout.TextField(GitGUI.GetTempContent("Name"), name);
                EditorGUILayout.LabelField(GitGUI.GetTempContent("Commit SHA"), new GUIContent(commit.Sha));
            }
            else
            {
                EditorGUILayout.HelpBox("No selected commit.", MessageType.Warning);
            }

            GitGUI.StartEnable(IsValidBranchName(name) && commit != null);
            GUIContent createBranchContent = GitGUI.GetTempContent("Create Branch");

            if (!IsValidBranchName(name))
            {
                createBranchContent.tooltip = "Invalid Branch Name";
            }
            if (GUILayout.Button(createBranchContent))
            {
                try
                {
                    var branch = GitManager.Repository.CreateBranch(name, commit);
                    if (branch != null)
                    {
                        Debug.Log("Branch " + name + " created");
                        editorWindow.Close();
                        if (onCreated != null)
                        {
                            onCreated.Invoke();
                        }
                    }
                    else
                    {
                        Debug.LogError("Could not create branch: " + name);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError("Could not create branch!");
                    Debug.LogException(e);
                }
                finally
                {
                    GitManager.MarkDirty(true);
                }
            }
            GitGUI.EndEnable();
        }
Exemple #24
0
 private void DoBranches(Event current)
 {
     foreach (var branch in branches)
     {
         GUILayout.Label(GitGUI.GetTempContent(branch.FriendlyName), "ShurikenModuleTitle");
         int selectedRemote = Array.IndexOf(remoteCacheList, branch.Remote);
         EditorGUI.BeginChangeCheck();
         EditorGUILayout.BeginHorizontal();
         EditorGUILayout.PrefixLabel(GitGUI.GetTempContent("Remote"));
         int newSelectedRemote = EditorGUILayout.Popup(selectedRemote, remoteNames);
         EditorGUILayout.EndHorizontal();
         if (EditorGUI.EndChangeCheck() && selectedRemote != newSelectedRemote)
         {
             branches.Update(branch, (u) =>
             {
                 u.Remote         = remoteCacheList[newSelectedRemote].Name;
                 u.UpstreamBranch = branch.CanonicalName;
             });
         }
         EditorGUILayout.TextField(GitGUI.GetTempContent("Upstream Branch"), branch.UpstreamBranchCanonicalName);
         EditorGUILayout.BeginHorizontal();
         GUILayout.FlexibleSpace();
         if (GUILayout.Button("Save", "minibuttonleft"))
         {
             branches.Update(branch, (u) =>
             {
                 u.Remote         = remoteCacheList[selectedRemote].Name;
                 u.UpstreamBranch = branch.CanonicalName;
             });
         }
         GUI.enabled = !branch.IsRemote && branch.IsCurrentRepositoryHead;
         if (GUILayout.Button("Switch", "minibuttonmid"))
         {
             Debug.LogException(new NotImplementedException("Branch Checkout not implemented"));
             //todo implement branch checkout
         }
         GUI.enabled = !branch.IsRemote;
         if (GUILayout.Button("Reset", "minibuttonright"))
         {
             branches.Update(branch, (u) =>
             {
                 u.Remote         = "";
                 u.UpstreamBranch = "";
             });
         }
         GUI.enabled = true;
         GUILayout.FlexibleSpace();
         EditorGUILayout.EndHorizontal();
     }
 }
 public override void OnGUI(Rect rect)
 {
     EditorGUILayout.Space();
     name        = EditorGUILayout.TextField(GitGUI.GetTempContent("Name"), name);
     url         = EditorGUILayout.TextField(GitGUI.GetTempContent("URL"), url);
     GUI.enabled = !string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(url);
     if (GUILayout.Button(GitGUI.GetTempContent("Add Remote")))
     {
         remoteCollection.Add(name, url);
         gitManager.MarkDirty();
     }
     GUI.enabled = true;
     EditorGUILayout.Space();
 }
Exemple #26
0
 protected void DrawCredentials()
 {
     credentials.Active = EditorGUILayout.Toggle(GitGUI.GetTempContent("Custom Credentials", "Credentials to use instead of the ones from the credentials manager."), credentials.Active);
     if (credentials.Active)
     {
         EditorGUI.indentLevel = 1;
         credentials.IsToken   = EditorGUILayout.Toggle(GitGUI.GetTempContent("Is Token"), credentials.IsToken);
         credentials.Username  = EditorGUILayout.TextField(GitGUI.GetTempContent(credentials.IsToken ? "Token" : "Username", "If left empty, stored credentials in settings will be used."), credentials.Username);
         if (!credentials.IsToken)
         {
             GitGUI.SecurePasswordFieldLayout(GitGUI.GetTempContent("Password", "If left empty, stored credentials in settings will be used."), credentials.Password);
         }
         EditorGUI.indentLevel = 0;
     }
 }
Exemple #27
0
        internal static void InvalidRepoGUI()
        {
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Box(GitGUI.GetTempContent("Not a GIT Repository"), "NotificationBackground");
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
            GUILayout.FlexibleSpace();
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(GitGUI.GetTempContent("Create"), "LargeButton", GUILayout.Height(32), GUILayout.Width(128)))
            {
                if (EditorUtility.DisplayDialog("Initialize Repository", "Are you sure you want to initialize a Repository for your project", "Yes", "Cancel"))
                {
                    Repository.Init(Application.dataPath.Replace("/Assets", ""));
                    TextAsset textAsset = EditorGUIUtility.Load("UniGit/gitignore.txt") as TextAsset;
                    if (textAsset != null)
                    {
                        string textAssetPath    = AssetDatabase.GetAssetPath(textAsset).Replace("Assets/", "");
                        string newGitIgnoreFile = Path.Combine(Application.dataPath.Replace("Assets", "").Replace("Contents", ""), ".gitignore");
                        if (!File.Exists(newGitIgnoreFile))
                        {
                            File.Copy(Path.Combine(Application.dataPath, textAssetPath), newGitIgnoreFile);
                        }
                        else
                        {
#if UNITY_EDITOR
                            Debug.Log("Git Ignore file already present");
#endif
                        }
                    }
                    else
                    {
                        Debug.LogError("Missing default gitignore.txt in resources");
                    }
                    AssetDatabase.Refresh();
                    AssetDatabase.SaveAssets();
                    GitManager.Initlize();
                    GitManager.MarkDirty();
                    GUIUtility.ExitGUI();
                    return;
                }
            }
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
        }
Exemple #28
0
        internal static void InvalidRepoGUI(GitManager gitManager)
        {
            if (gitManager == null)
            {
                Rect initilizingRect = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));
                GitGUI.DrawLoading(new Rect(initilizingRect.x, initilizingRect.y, initilizingRect.width, initilizingRect.height), GitGUI.GetTempContent("Initializing..."));
                return;
            }

            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Box(GitGUI.GetTempContent("Not a GIT Repository"), "NotificationBackground");
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            //initialization tips
            EditorGUILayout.HelpBox("If you have an existing remote repository and want to clone it, you will have to do so outside of the editor.", MessageType.Info);
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUI.enabled = gitManager != null;
            if (GUILayout.Button(GitGUI.GetTempContent("Create"), GitGUI.Styles.LargeButton, GUILayout.Height(32), GUILayout.Width(128)))
            {
                if (EditorUtility.DisplayDialog("Initialize Repository", "Are you sure you want to initialize a Repository for your project", "Yes", "Cancel"))
                {
                    if (gitManager != null && !gitManager.IsValidRepo)
                    {
                        gitManager.InitilizeRepositoryAndRecompile();
                    }
                    GUIUtility.ExitGUI();
                    return;
                }
            }
            GUI.enabled = true;
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
        }
Exemple #29
0
 protected void DrawCredentials()
 {
     credentalsExpanded = EditorGUILayout.PropertyField(serializedObject.FindProperty("credentials"));
     if (credentalsExpanded)
     {
         EditorGUI.indentLevel = 1;
         credentials.IsToken   = EditorGUILayout.Toggle(GitGUI.GetTempContent("Is Token"), credentials.IsToken);
         if (credentials.IsToken)
         {
             credentials.Token = EditorGUILayout.TextField(GitGUI.GetTempContent("Token", "If left empty, stored credentials in settings will be used."), credentials.Token);
         }
         else
         {
             credentials.Username = EditorGUILayout.TextField(GitGUI.GetTempContent("Username", "If left empty, stored credentials in settings will be used."), credentials.Username);
             credentials.Password = EditorGUILayout.PasswordField(GitGUI.GetTempContent("Password", "If left empty, stored credentials in settings will be used."), credentials.Password);
         }
         EditorGUI.indentLevel = 0;
     }
 }
        public override void OnGUI(Rect rect)
        {
            EditorGUILayout.Space();
            float msgHeight = commitMessageStyle.CalcHeight(GitGUI.GetTempContent(commit.Message), rect.width);

            scroll = EditorGUILayout.BeginScrollView(scroll);
            EditorGUILayout.LabelField(GitGUI.GetTempContent(commit.Message), commitMessageStyle, GUILayout.Height(msgHeight));
            if (changes != null)
            {
                foreach (var change in changes)
                {
                    //EditorGUILayout.BeginHorizontal();
                    //GUILayout.Label(change.Status.ToString(), "AssetLabel");
                    EditorGUILayout.BeginHorizontal("ProjectBrowserHeaderBgTop");
                    GUILayout.Label(new GUIContent(GitOverlay.GetDiffTypeIcon(change.Status, true))
                    {
                        tooltip = change.Status.ToString()
                    }, GUILayout.Width(16));
                    GUILayout.Space(8);
                    string[] pathChunks = change.Path.Split(Path.DirectorySeparatorChar);
                    for (int i = 0; i < pathChunks.Length; i++)
                    {
                        string chunk = pathChunks[i];
                        if (GUILayout.Button(GitGUI.GetTempContent(chunk), GitGUI.Styles.BreadcrumMid))
                        {
                            string assetPath = string.Join("/", pathChunks, 0, i + 1);
                            if (assetPath.EndsWith(".meta"))
                            {
                                assetPath = AssetDatabase.GetAssetPathFromTextMetaFilePath(assetPath);
                            }
                            ShowContextMenuForElement(change.Path, assetPath);
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }
            else
            {
                DrawTreeEntry(commitTree, 0);
            }
            EditorGUILayout.Space();
            EditorGUILayout.EndScrollView();
        }