private void Commit()
        {
            Signature signature = GitManager.Signature;

            try
            {
                if (!GitExternalManager.TakeCommit(commitMessage))
                {
                    GitManager.Repository.Commit(commitMessage, signature, signature, new CommitOptions()
                    {
                        AllowEmptyCommit = settings.emptyCommit, AmendPreviousCommit = settings.amendCommit, PrettifyMessage = settings.prettify
                    });
                    GitHistoryWindow.GetWindow(true);
                }
                GitManager.Update();
            }
            catch (Exception e)
            {
                Debug.LogException(e);
            }
            finally
            {
                GUI.FocusControl("");
                commitMessage = string.Empty;
            }
        }
        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();
        }
Beispiel #3
0
 public GitCheckoutWindowPopup(GitManager gitManager, Branch branch, ILogger logger, GitCallbacks gitCallbacks)
 {
     this.gitManager   = gitManager;
     this.branch       = branch;
     this.logger       = logger;
     this.gitCallbacks = gitCallbacks;
 }
Beispiel #4
0
        protected void OnMergeComplete(MergeResult result, string mergeType)
        {
            switch (result.Status)
            {
            case MergeStatus.UpToDate:
                GitHistoryWindow.GetWindow(true).ShowNotification(new GUIContent(string.Format("Everything is Up to date. Nothing to {0}.", mergeType)));
                break;

            case MergeStatus.FastForward:
                GitHistoryWindow.GetWindow(true).ShowNotification(new GUIContent(mergeType + " Complete with Fast Forwarding."));
                break;

            case MergeStatus.NonFastForward:
                GitDiffWindow.GetWindow(true).ShowNotification(new GUIContent("Do a merge commit in order to push changes."));
                GitDiffWindow.GetWindow(false).commitMessage = GitManager.Repository.Info.Message;
                Debug.Log(mergeType + " Complete without Fast Forwarding.");
                break;

            case MergeStatus.Conflicts:
                GUIContent content = EditorGUIUtility.IconContent("console.warnicon");
                content.text = "There are merge conflicts!";
                GitDiffWindow.GetWindow(true).ShowNotification(content);
                GitDiffWindow.GetWindow(false).commitMessage = GitManager.Repository.Info.Message;
                break;
            }
            GitManager.Update();
            Debug.LogFormat("{0} Status: {1}", mergeType, result.Status);
        }
        private void DoDiffStatusContex(FileStatus fileStatus, GenericMenu menu)
        {
            menu.AddItem(new GUIContent("Select All"), false, SelectFilteredCallback, fileStatus);
            if (GitManager.CanStage(fileStatus))
            {
                menu.AddItem(new GUIContent("Add All"), false, () =>
                {
                    GitManager.Repository.Stage(statusList.Where(s => s.State.IsFlagSet(fileStatus)).SelectMany(s => GitManager.GetPathWithMeta(s.Path)));
                    GitManager.Update();
                });
            }
            else
            {
                menu.AddDisabledItem(new GUIContent("Add All"));
            }

            if (GitManager.CanUnstage(fileStatus))
            {
                menu.AddItem(new GUIContent("Remove All"), false, () =>
                {
                    GitManager.Repository.Unstage(statusList.Where(s => s.State.IsFlagSet(fileStatus)).SelectMany(s => GitManager.GetPathWithMeta(s.Path)));
                    GitManager.Update();
                });
            }
            else
            {
                menu.AddDisabledItem(new GUIContent("Remove All"));
            }
        }
 public GitDiffWindowCommitRenderer(GitSettingsJson gitSettings, GitManager gitManager, GitOverlay gitOverlay, GitInitializer initializer)
 {
     this.gitSettings = gitSettings;
     this.gitManager  = gitManager;
     this.gitOverlay  = gitOverlay;
     this.initializer = initializer;
 }
Beispiel #7
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();
            }
Beispiel #8
0
 private void Construct(GitManager gitManager, GitOverlay gitOverlay, ILogger logger, GitAnimation gitAnimation)
 {
     this.gitManager   = gitManager;
     this.gitOverlay   = gitOverlay;
     this.logger       = logger;
     this.gitAnimation = gitAnimation;
 }
 private void OnWizardCreate()
 {
     try
     {
         using (var repository = new Repository(GitManager.RepoPath))
         {
             repository.Network.Push(repository.Branches[branchNames[selectedBranch]], pushOptions);
             GitManager.Update();
             var window = GitHistoryWindow.GetWindow(true);
             window.ShowNotification(new GUIContent("Push Complete"));
         }
     }
     catch (Exception e)
     {
         if (e is NonFastForwardException)
         {
             GUIContent content = EditorGUIUtility.IconContent("console.warnicon");
             content.text = "Could not push changes to remote. Merge changes with remote before pushing.";
             GetWindow <GitHistoryWindow>().ShowNotification(content);
         }
         Debug.LogException(e);
     }
     finally
     {
         EditorUtility.ClearProgressBar();
     }
 }
Beispiel #10
0
        private void Construct(GitManager gitManager,
                               GitReflectionHelper reflectionHelper,
                               UniGitData data,
                               ILogger logger,
                               GitSettingsJson gitSettings,
                               GitCallbacks gitCallbacks,
                               GitInitializer initializer,
                               GitSettingsManager settingsManager,
                               UniGitPaths paths,
                               IGitResourceManager resourceManager)
        {
            this.resourceManager = resourceManager;
            this.paths           = paths;
            this.settingsManager = settingsManager;
            this.logger          = logger;
            this.gitSettings     = gitSettings;
            this.initializer     = initializer;

            if (gitManager == null)
            {
                logger.Log(LogType.Error, "Git manager cannot be null.");
                return;
            }
            if (this.gitCallbacks != null)
            {
                Unsubscribe(this.gitCallbacks);
            }

            this.data       = data;
            this.gitManager = gitManager;
            this.gitManager.AddWatcher(this);
            this.reflectionHelper = reflectionHelper;
            Subscribe(gitCallbacks);
        }
Beispiel #11
0
        public GitLfsManager(GitManager gitManager, GitCallbacks gitCallbacks, ILogger logger, GitSettingsJson gitSettings)
        {
            this.gitManager                = gitManager;
            this.gitCallbacks              = gitCallbacks;
            this.logger                    = logger;
            this.gitSettings               = gitSettings;
            gitCallbacks.UpdateRepository += OnUpdateRepository;
            gitManager.AddSettingsAffector(this);

            try
            {
                version     = GitHelper.RunExeOutput(gitManager.GetCurrentRepoPath(), "git-lfs", "version", null);
                isInstalled = true;
            }
            catch (Exception)
            {
                isInstalled = false;
                return;
            }

            UpdateInitilized();
            if (Initilized)
            {
                RegisterFilter();
                Update();
            }
        }
Beispiel #12
0
 public StatusTreeClass(GitSettingsJson gitSettings, GitManager gitManager, bool cullNonAssetPaths, UniGitPaths paths)
 {
     this.paths             = paths;
     this.gitManager        = gitManager;
     this.cullNonAssetPaths = cullNonAssetPaths;
     this.gitSettings       = gitSettings;
 }
Beispiel #13
0
        private static void Rebuild(InjectionHelper injectionHelper)
        {
            GitCallbacks = injectionHelper.GetInstance <GitCallbacks>();

            var settingsManager = injectionHelper.GetInstance <GitSettingsManager>();

            settingsManager.LoadGitSettings();

            //delayed called must be used for serialized properties to be loaded
            EditorApplication.delayCall += () =>
            {
                settingsManager.LoadOldSettingsFile();
            };

            GitManager = injectionHelper.GetInstance <GitManager>();

            injectionHelper.GetInstance <GitReflectionHelper>();
            GitSettings = injectionHelper.GetInstance <GitSettingsJson>();

            GitCallbacks.OnLogEntry             += OnLogEntry;
            GitCallbacks.OnBeforeAssemblyReload += OnBeforeAssemblyReload;

            injectionHelper.CreateNonLazy();

            injectionHelper.InjectStatic(typeof(GitProjectContextMenus));
            injectionHelper.InjectStatic(typeof(GitUnityMenu));
        }
Beispiel #14
0
 private static void Initilize()
 {
     if (EditorUtility.DisplayDialog("Initialize Repository", "Are you sure you want to initialize a Repository for your project", "Yes", "Cancel"))
     {
         GitManager.InitilizeRepository();
     }
 }
Beispiel #15
0
 public GitAutoFetcher(GitManager gitManager, GitCredentialsManager credentialsManager, GitCallbacks gitCallbacks)
 {
     this.gitManager            = gitManager;
     this.credentialsManager    = credentialsManager;
     this.gitCallbacks          = gitCallbacks;
     gitCallbacks.EditorUpdate += OnEditorUpdate;
     needsFetch = !EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isCompiling && !EditorApplication.isUpdating;
 }
Beispiel #16
0
 internal static void SetCommitMessage(GitInitializer initializer, GitManager gitManager, GitSettingsJson gitSettings, string commitMessage)
 {
     if (gitSettings.ReadFromFile)
     {
         SaveCommitMessageToFile(initializer, gitSettings, commitMessage);
     }
     gitManager.Prefs.SetString(CommitMessageKey, commitMessage);
 }
Beispiel #17
0
 private static bool RemoveSelectedValidate()
 {
     if (gitManager == null || !initializer.IsValidRepo)
     {
         return(false);
     }
     return(Selection.assetGUIDs.Select(AssetDatabase.GUIDToAssetPath).Select(p => gitManager.ToLocalPath(p)).SelectMany(gitManager.GetPathWithMeta)
            .Any(g => GitManager.CanUnstage(gitManager.Repository.RetrieveStatus(g))));
 }
Beispiel #18
0
 private static bool RemoveSelectedValidate()
 {
     if (gitManager == null || !gitManager.IsValidRepo)
     {
         return(false);
     }
     string[] paths = Selection.assetGUIDs.Select(g => string.IsNullOrEmpty(Path.GetExtension(AssetDatabase.GUIDToAssetPath(g))) ? AssetDatabase.GUIDToAssetPath(g) + ".meta" : AssetDatabase.GUIDToAssetPath(g)).SelectMany(GitManager.GetPathWithMeta).ToArray();
     return(paths.Any(g => GitManager.CanUnstage(gitManager.Repository.RetrieveStatus(g))));
 }
Beispiel #19
0
 public GitDiffElementContextFactory(GitManager gitManager, GitConflictsHandler conflictsHandler, GitOverlay gitOverlay,
                                     GitExternalManager externalManager, GitCallbacks gitCallbacks)
 {
     this.gitManager       = gitManager;
     this.conflictsHandler = conflictsHandler;
     this.gitOverlay       = gitOverlay;
     this.externalManager  = externalManager;
     this.gitCallbacks     = gitCallbacks;
 }
Beispiel #20
0
        public override void OnGUI(Rect rect)
        {
            EditorGUILayout.Space();
            float msgHeight = commitMessageStyle.CalcHeight(new GUIContent(commit.Message), rect.width);

            EditorGUILayout.LabelField(new GUIContent(commit.Message), commitMessageStyle, GUILayout.Height(msgHeight));
            scroll = EditorGUILayout.BeginScrollView(scroll);
            EditorGUILayout.Space();
            if (changes != null)
            {
                foreach (var change in changes)
                {
                    //EditorGUILayout.BeginHorizontal();
                    //GUILayout.Label(change.Status.ToString(), "AssetLabel");
                    EditorGUILayout.BeginHorizontal("ProjectBrowserHeaderBgTop");
                    GUILayout.Label(new GUIContent(GitManager.GetDiffTypeIcon(change.Status, true)), GUILayout.Width(16));
                    GUILayout.Label(new GUIContent("(" + change.Status + ")"), "AboutWIndowLicenseLabel");
                    GUILayout.Space(8);
                    foreach (var chunk in change.Path.Split('\\'))
                    {
                        GUILayout.Label(new GUIContent(chunk), "GUIEditor.BreadcrumbMid");
                    }
                    //GUILayout.Label(new GUIContent(" (" + change.Status + ") " + change.Path));
                    EditorGUILayout.EndHorizontal();
                    Rect r = GUILayoutUtility.GetLastRect();
                    if (Event.current.type == EventType.ContextClick)
                    {
                        GenericMenu menu = new GenericMenu();
                        if (commit.Parents.Count() == 1)
                        {
                            menu.AddItem(new GUIContent("Difference with previous commit"), false, () =>
                            {
                                Commit parent = commit.Parents.Single();
                                GitManager.ShowDiff(change.Path, parent, commit);
                            });
                        }
                        else
                        {
                            menu.AddDisabledItem(new GUIContent(new GUIContent("Difference with previous commit")));
                        }
                        menu.AddItem(new GUIContent("Difference with HEAD"), false, () =>
                        {
                            GitManager.ShowDiff(change.Path, commit, GitManager.Repository.Head.Tip);
                        });
                        menu.ShowAsContext();
                    }
                    //EditorGUILayout.EndHorizontal();
                }
            }
            else
            {
                DrawTreeEntry(commitTree, 0);
            }
            EditorGUILayout.Space();
            EditorGUILayout.EndScrollView();
        }
Beispiel #21
0
 public GitSubModulesPopup(UniGitData data, GitOverlay gitOverlay, GitManager gitManager)
 {
     this.data       = data;
     this.gitOverlay = gitOverlay;
     this.gitManager = gitManager;
     moduleStyle     = new GUIStyle("ProjectBrowserHeaderBgTop")
     {
         wordWrap = true, fixedHeight = 0, alignment = TextAnchor.MiddleLeft
     };
 }
Beispiel #22
0
        public GitExternalManager(GitManager gitManager, ICollection <IExternalAdapter> adapters)
        {
            var injectionHelper = new InjectionHelper();

            injectionHelper.Bind <GitManager>().FromInstance(gitManager);
            injectionHelper.Bind <GitExternalManager>().FromInstance(this);
            this.gitManager = gitManager;
            this.adapters   = adapters.OrderBy(GetAdapterPriority).ToArray();
            adapterNames    = adapters.Select(a => new GUIContent(GetAdapterName(a))).ToArray();
        }
 public GitCreateBranchWindow(Commit commit,
                              [UniGitInjectOptional] Action onCreated,
                              GitManager gitManager,
                              ILogger logger)
 {
     this.gitManager = gitManager;
     this.commit     = commit;
     this.onCreated  = onCreated;
     this.logger     = logger;
 }
 private void Build(IEnumerable <GitStatusEntry> status)
 {
     foreach (var entry in status)
     {
         currentPath      = entry.Path;
         currentPathArray = entry.Path.Split('\\');
         currentStatus    = !gitSettings.ShowEmptyFolders && GitManager.IsEmptyFolderMeta(currentPath) ? FileStatus.Ignored : entry.Status;
         AddRecursive(0, entries);
     }
 }
Beispiel #25
0
 private static void Revet()
 {
     GitManager.Repository.CheckoutPaths("HEAD", Selection.assetGUIDs.Select(e => AssetDatabase.GUIDToAssetPath(e)).SelectMany(e => GitManager.GetPathWithMeta(e)), new CheckoutOptions()
     {
         CheckoutModifiers = CheckoutModifiers.Force, OnCheckoutProgress = OnRevertProgress
     });
     EditorUtility.ClearProgressBar();
     GitManager.Update();
     AssetDatabase.Refresh();
 }
Beispiel #26
0
            static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
            {
                if (EditorPrefs.GetBool("UniGit_DisablePostprocess"))
                {
                    return;
                }
                if (GitManager.Repository != null)
                {
                    if (GitManager.Settings != null && GitManager.Settings.AutoStage)
                    {
                        if (importedAssets != null && importedAssets.Length > 0)
                        {
                            string[] importedAssetsToStage = importedAssets.Where(a => !GitManager.IsEmptyFolder(a)).SelectMany(g => GitManager.GetPathWithMeta(g)).Where(g => GitManager.CanStage(GitManager.Repository.RetrieveStatus(g))).ToArray();
                            if (importedAssetsToStage.Length > 0)
                            {
                                GitManager.Repository.Stage(importedAssetsToStage);
                                GitManager.MarkDirty(importedAssetsToStage);
                            }
                        }

                        if (movedAssets != null && movedAssets.Length > 0)
                        {
                            string[] movedAssetsFinal = movedAssets.Where(a => !GitManager.IsEmptyFolder(a)).SelectMany(g => GitManager.GetPathWithMeta(g)).Where(g => GitManager.CanStage(GitManager.Repository.RetrieveStatus(g))).ToArray();
                            if (movedAssetsFinal.Length > 0)
                            {
                                GitManager.Repository.Stage(movedAssetsFinal);
                                GitManager.MarkDirty(movedAssetsFinal);
                            }
                        }
                    }

                    //automatic deletion of previously moved asset is necessary even if AutoStage is off
                    if (movedFromAssetPaths != null && movedFromAssetPaths.Length > 0)
                    {
                        string[] movedFromAssetPathsFinal = movedFromAssetPaths.SelectMany(g => GitManager.GetPathWithMeta(g)).Where(g => GitManager.CanUnstage(GitManager.Repository.RetrieveStatus(g))).ToArray();
                        if (movedFromAssetPathsFinal.Length > 0)
                        {
                            GitManager.Repository.Unstage(movedFromAssetPathsFinal);
                            GitManager.MarkDirty(movedFromAssetPathsFinal);
                        }
                    }

                    //automatic deletion is necessary even if AutoStage is off
                    if (deletedAssets != null && deletedAssets.Length > 0)
                    {
                        string[] deletedAssetsFinal = deletedAssets.SelectMany(g => GitManager.GetPathWithMeta(g)).Where(g => GitManager.CanUnstage(GitManager.Repository.RetrieveStatus(g))).ToArray();
                        if (deletedAssetsFinal.Length > 0)
                        {
                            GitManager.Repository.Unstage(deletedAssetsFinal);
                            GitManager.MarkDirty(deletedAssetsFinal);
                        }
                    }
                }
            }
 private void GoToPush()
 {
     if (GitExternalManager.TakePush())
     {
         GitManager.MarkDirty();
     }
     else
     {
         ScriptableWizard.DisplayWizard <GitPushWizard>("Push", "Push").Init(selectedBranch.LoadBranch());
     }
 }
Beispiel #28
0
        protected virtual void OnEnable()
        {
            titleContent.image = GitManager.GetGitStatusIcon();

            EditorApplication.update    -= OnEditorUpdateInternal;
            EditorApplication.update    += OnEditorUpdateInternal;
            GitManager.updateRepository -= OnGitManagerUpdateInternal;
            GitManager.updateRepository += OnGitManagerUpdateInternal;
            GitManager.onRepositoryLoad -= OnRepositoryLoad;
            GitManager.onRepositoryLoad += OnRepositoryLoad;
        }
        private void DoDiffElementContex(GenericMenu editMenu)
        {
            StatusListEntry[] entries       = statusList.Where(e => e.Selected).ToArray();
            FileStatus        selectedFlags = entries.Select(e => e.State).CombineFlags();

            GUIContent addContent = new GUIContent("Stage");

            if (GitManager.CanStage(selectedFlags))
            {
                editMenu.AddItem(addContent, false, AddSelectedCallback);
            }
            else
            {
                editMenu.AddDisabledItem(addContent);
            }
            GUIContent removeContent = new GUIContent("Unstage");

            if (GitManager.CanUnstage(selectedFlags))
            {
                editMenu.AddItem(removeContent, false, RemoveSelectedCallback);
            }
            else
            {
                editMenu.AddDisabledItem(removeContent);
            }

            editMenu.AddSeparator("");
            if (entries.Length == 1)
            {
                string path = entries[0].Path;
                if (selectedFlags.IsFlagSet(FileStatus.Conflicted))
                {
                    if (GitConflictsHandler.CanResolveConflictsWithTool(path))
                    {
                        editMenu.AddItem(new GUIContent("Resolve Conflicts"), false, ResolveConflictsCallback, path);
                    }
                    else
                    {
                        editMenu.AddDisabledItem(new GUIContent("Resolve Conflicts"));
                    }
                    editMenu.AddItem(new GUIContent("Resolve (Using Ours)"), false, ResolveConflictsOursCallback, entries[0].Path);
                    editMenu.AddItem(new GUIContent("Resolve (Using Theirs)"), false, ResolveConflictsTheirsCallback, entries[0].Path);
                }
                else
                {
                    editMenu.AddItem(new GUIContent("Difference"), false, SeeDifferenceSelectedCallback, entries[0].Path);
                    editMenu.AddItem(new GUIContent("Difference with previous version"), false, SeeDifferencePrevSelectedCallback, entries[0].Path);
                }
            }
            editMenu.AddSeparator("");
            editMenu.AddItem(new GUIContent("Revert"), false, RevertSelectedCallback);
            editMenu.AddSeparator("");
            editMenu.AddItem(new GUIContent("Reload"), false, ReloadCallback);
        }
Beispiel #30
0
 private void BlameAuto(StatusListEntry entry)
 {
     if (entry.MetaChange.IsFlagSet(MetaChangeEnum.Object))
     {
         gitManager.ShowBlameWizard(entry.LocalPath, externalManager);
     }
     else
     {
         gitManager.ShowBlameWizard(GitManager.MetaPathFromAsset(entry.LocalPath), externalManager);
     }
 }