コード例 #1
0
ファイル: GitManager.cs プロジェクト: wuzhangwuzhang/UniGit
 public static void ShowDiff(string path, [NotNull] Commit start, [NotNull] Commit end)
 {
     if (GitExternalManager.TakeDiff(path, start, end))
     {
         return;
     }
 }
コード例 #2
0
		public static void ResolveConflicts(string path, MergeFileFavor favor)
		{
			if(!GitManager.IsValidRepo) return;

			if (favor == MergeFileFavor.Normal)
			{
				GitExternalManager.HandleConflict(path);
			}
			else if (favor == MergeFileFavor.Ours)
			{
				var conflict = GitManager.Repository.Index.Conflicts[path];
				var ours = conflict.Ours;
				if (ours != null)
				{
					GitManager.Repository.Index.Remove(ours.Path);
					GitManager.Repository.CheckoutPaths("ORIG_HEAD", new[] { ours.Path });
				}
			}
			else if (favor == MergeFileFavor.Theirs)
			{
				var conflict = GitManager.Repository.Index.Conflicts[path];
				var theirs = conflict.Theirs;
				if (theirs != null)
				{
					GitManager.Repository.Index.Remove(theirs.Path);
					GitManager.Repository.CheckoutPaths("MERGE_HEAD", new[] { theirs.Path });
				}
			}

			//Debug.Log(EditorUtility.InvokeDiffTool(Path.GetFileName(theirs.Path) + " - Theirs", conflictPathTheirs, Path.GetFileName(ours.Path) + " - Ours", conflictPathOurs, "", conflictPathAncestor));
		}
コード例 #3
0
ファイル: GitSettingsWindow.cs プロジェクト: bp-bling/UniGit
        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();
                }
            }
        }
コード例 #4
0
        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;
            }
        }
コード例 #5
0
ファイル: GitManager.cs プロジェクト: bp-bling/UniGit
 public static void ShowDiff(string path)
 {
     if (string.IsNullOrEmpty(path) || Repository == null)
     {
         return;
     }
     GitExternalManager.ShowDiff(path);
 }
コード例 #6
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;
 }
コード例 #7
0
 private void GoToPush()
 {
     if (GitExternalManager.TakePush())
     {
         GitManager.MarkDirty();
     }
     else
     {
         ScriptableWizard.DisplayWizard <GitPushWizard>("Push", "Push").Init(selectedBranch.LoadBranch());
     }
 }
コード例 #8
0
 private void GoToMerge()
 {
     if (GitExternalManager.TakeMerge())
     {
         GitManager.MarkDirty();
     }
     else
     {
         ScriptableWizard.DisplayWizard <GitMergeWizard>("Merge", "Merge");
     }
 }
コード例 #9
0
 private void GoToPull()
 {
     if (GitExternalManager.TakePull())
     {
         AssetDatabase.Refresh();
         GitManager.MarkDirty();
     }
     else
     {
         ScriptableWizard.DisplayWizard <GitPullWizard>("Pull", "Pull").Init(selectedBranch.LoadBranch());
     }
 }
コード例 #10
0
ファイル: GitWizardBase.cs プロジェクト: oznogongames/UniGit
        private void Construct(GitManager gitManager, GitCredentialsManager credentialsManager, GitExternalManager externalManager)
        {
            this.gitManager         = gitManager;
            this.credentialsManager = credentialsManager;
            this.externalManager    = externalManager;

            remotes = gitManager.Repository.Network != null && gitManager.Repository.Network.Remotes != null?gitManager.Repository.Network.Remotes.ToArray() : new Remote[0];

            remoteNames         = remotes.Select(r => new GUIContent(r.Name)).ToArray();
            branchNames         = gitManager.Repository.Branches.Select(b => b.CanonicalName).ToArray();
            branchFriendlyNames = gitManager.Repository.Branches.Select(b => b.FriendlyName).ToArray();
        }
コード例 #11
0
ファイル: GitManager.cs プロジェクト: wuzhangwuzhang/UniGit
        public static void ShowDiff(string path)
        {
            if (string.IsNullOrEmpty(path) || Repository == null)
            {
                return;
            }
            if (GitExternalManager.TakeDiff(path))
            {
                return;
            }

            EditorWindow.GetWindow <GitDiffInspector>(true).Init(path);
        }
コード例 #12
0
        private void GoToFetch()
        {
            var branch = selectedBranch.LoadBranch();

            if (GitExternalManager.TakeFetch(branch.Remote.Name))
            {
                GitManager.MarkDirty();
            }
            else
            {
                ScriptableWizard.DisplayWizard <GitFetchWizard>("Fetch", "Fetch").Init(branch);
            }
        }
コード例 #13
0
ファイル: GitManager.cs プロジェクト: wuzhangwuzhang/UniGit
        public static void ShowBlameWizard(string path)
        {
            if (!string.IsNullOrEmpty(path))
            {
                if (GitExternalManager.TakeBlame(path))
                {
                    return;
                }

                var blameWizard = EditorWindow.GetWindow <GitBlameWizard>(true);
                blameWizard.SetBlamePath(path);
            }
        }
コード例 #14
0
        public void ShowBlameWizard(string path, GitExternalManager externalManager)
        {
            if (!string.IsNullOrEmpty(path))
            {
                if (externalManager.TakeBlame(path))
                {
                    return;
                }

                var blameWizard = UniGitLoader.GetWindow <GitBlameWizard>(true);
                blameWizard.SetBlamePath(path);
            }
        }
コード例 #15
0
        public void ShowDiff(string path, GitExternalManager externalManager)
        {
            if (string.IsNullOrEmpty(path) || Repository == null)
            {
                return;
            }
            if (externalManager.TakeDiff(path))
            {
                return;
            }

            var window = UniGitLoader.GetWindow <GitDiffInspector>();

            window.Init(path);
        }
コード例 #16
0
 internal static void Init(GitManager gitManager,
                           GitExternalManager externalManager,
                           GitCallbacks gitCallbacks,
                           ILogger logger,
                           GitProjectOverlay gitProjectOverlay,
                           GitReflectionHelper reflectionHelper,
                           GitInitializer initializer)
 {
     GitProjectContextMenus.gitManager        = gitManager;
     GitProjectContextMenus.externalManager   = externalManager;
     GitProjectContextMenus.gitCallbacks      = gitCallbacks;
     GitProjectContextMenus.logger            = logger;
     GitProjectContextMenus.reflectionHelper  = reflectionHelper;
     GitProjectContextMenus.gitProjectOverlay = gitProjectOverlay;
     GitProjectContextMenus.initializer       = initializer;
 }
コード例 #17
0
        public static void ShowDiff(string path, Commit commit, [CanBeNull] Commit other)
        {
            TreeEntry entry = commit[path];

            if (entry != null)
            {
                Blob blob = entry.Target as Blob;
                if (blob == null || blob.IsBinary)
                {
                    return;
                }
                string oldFilePath = Application.dataPath.Replace("Assets", "Temp/") + "Git-diff-tmp-file";
                if (!string.IsNullOrEmpty(oldFilePath))
                {
                    using (FileStream file = File.Create(oldFilePath))
                    {
                        blob.GetContentStream().CopyTo(file);
                    }
                }
                string otherFilePath = path;
                if (other != null)
                {
                    TreeEntry otherEntry = other[path];
                    if (otherEntry == null)
                    {
                        return;
                    }
                    Blob otherBlob = otherEntry.Target as Blob;
                    if (otherBlob == null || otherBlob.IsBinary)
                    {
                        return;
                    }
                    otherFilePath = Application.dataPath.Replace("Assets", "Temp/") + "Git-diff-tmp-file-other";
                    if (string.IsNullOrEmpty(otherFilePath))
                    {
                        return;
                    }
                    using (FileStream file = File.Create(otherFilePath))
                    {
                        otherBlob.GetContentStream().CopyTo(file);
                    }
                }

                var asset = AssetDatabase.LoadAssetAtPath(path, typeof(Object));
                GitExternalManager.ShowDiff(Path.GetFileName(path) + " - " + entry.Target.Sha, oldFilePath, Path.GetFileName(path) + " - " + (other == null ? "Working Tree" : other.Id.Sha), otherFilePath, asset != null ? asset.GetType() : null);
            }
        }
コード例 #18
0
        public GitCommitDetailsWindow(GitManager gitManager, GitExternalManager externalManager, Commit commit)
        {
            this.gitManager      = gitManager;
            this.commit          = commit;
            this.externalManager = externalManager;
            commitTree           = commit.Tree;
            Commit parentCommit = commit.Parents.FirstOrDefault();

            if (parentCommit != null)
            {
                changes = gitManager.Repository.Diff.Compare <TreeChanges>(parentCommit.Tree, commitTree);
            }

            commitMessageStyle = new GUIStyle("TL SelectionButton")
            {
                alignment = TextAnchor.UpperLeft, padding = new RectOffset(4, 4, 4, 4), wordWrap = true
            };
        }
コード例 #19
0
        private static void Revet()
        {
            var paths = Selection.assetGUIDs.Select(e => AssetDatabase.GUIDToAssetPath(e)).SelectMany(e => GitManager.GetPathWithMeta(e)).ToArray();

            if (GitExternalManager.TakeRevert(paths))
            {
                AssetDatabase.Refresh();
                GitManager.MarkDirty(paths);
                return;
            }

            GitManager.Repository.CheckoutPaths("HEAD", paths, new CheckoutOptions()
            {
                CheckoutModifiers = CheckoutModifiers.Force, OnCheckoutProgress = OnRevertProgress
            });
            EditorUtility.ClearProgressBar();
            AssetDatabase.Refresh();
            GitManager.MarkDirty(paths);
        }
コード例 #20
0
ファイル: GitManager.cs プロジェクト: wuzhangwuzhang/UniGit
        public static void ShowDiffPrev(string path)
        {
            if (string.IsNullOrEmpty(path) && Repository != null)
            {
                return;
            }
            var lastCommit = Repository.Commits.QueryBy(path).Skip(1).FirstOrDefault();

            if (lastCommit == null)
            {
                return;
            }
            if (GitExternalManager.TakeDiff(path, lastCommit.Commit))
            {
                return;
            }

            EditorWindow.GetWindow <GitDiffInspector>(true).Init(path, lastCommit.Commit);
        }
コード例 #21
0
        public void ShowDiffPrev(string path, GitExternalManager externalManager)
        {
            if (string.IsNullOrEmpty(path) || Repository == null)
            {
                return;
            }
            var lastCommit = Repository.Commits.QueryBy(path).Skip(1).FirstOrDefault();

            if (lastCommit == null)
            {
                return;
            }
            if (externalManager.TakeDiff(path, lastCommit.Commit))
            {
                return;
            }

            var window = UniGitLoader.GetWindow <GitDiffInspector>();

            window.Init(path, lastCommit.Commit);
        }
コード例 #22
0
 private void Construct(GitExternalManager externalManager,
                        GitAsyncManager asyncManager,
                        GitOverlay gitOverlay,
                        InjectionHelper injectionHelper,
                        GitDiffWindowToolbarRenderer toolbarRenderer,
                        GitDiffElementContextFactory elementContextFactory,
                        GitDiffWindowCommitRenderer gitDiffWindowCommitRenderer,
                        GitDiffWindowDiffElementRenderer diffElementRenderer,
                        GitLfsHelper lfsHelper)
 {
     this.lfsHelper                   = lfsHelper;
     this.externalManager             = externalManager;
     this.asyncManager                = asyncManager;
     this.gitOverlay                  = gitOverlay;
     this.injectionHelper             = injectionHelper;
     this.toolbarRenderer             = toolbarRenderer;
     this.elementContextFactory       = elementContextFactory;
     this.gitDiffWindowCommitRenderer = gitDiffWindowCommitRenderer;
     this.diffElementRenderer         = diffElementRenderer;
     sorter = new GitDiffWindowSorter(this, gitManager);
 }
コード例 #23
0
ファイル: GitManager.cs プロジェクト: wuzhangwuzhang/UniGit
        internal static void Initlize()
        {
            repoPathCached = Application.dataPath.Replace("/Assets", "").Replace("/", "\\");
            gitPathCached  = Application.dataPath.Replace("Assets", ".git");

            if (!IsValidRepo)
            {
                return;
            }

            LoadGitSettings();

            GitResourceManager.Initilize();
            GitCredentialsManager.Load();
            GitOverlay.Initlize();
            GitLfsManager.Load();
            GitHookManager.Load();
            GitExternalManager.Load();

            needsFetch                 = !EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isCompiling && !EditorApplication.isUpdating;
            repositoryDirty            = true;
            GitCallbacks.EditorUpdate += OnEditorUpdate;
        }
コード例 #24
0
ファイル: UniGitLoader.cs プロジェクト: oznogongames/UniGit
        private static void Rebuild(InjectionHelper injectionHelper)
        {
            var settingsManager = injectionHelper.GetInstance <GitSettingsManager>();

            settingsManager.LoadGitSettings();

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

            HookManager        = injectionHelper.GetInstance <GitHookManager>();
            LfsManager         = injectionHelper.GetInstance <GitLfsManager>();
            ExternalManager    = injectionHelper.GetInstance <GitExternalManager>();
            CredentialsManager = injectionHelper.GetInstance <GitCredentialsManager>();
            LfsHelper          = injectionHelper.GetInstance <GitLfsHelper>();
            AsyncManager       = injectionHelper.GetInstance <GitAsyncManager>();

            injectionHelper.GetInstance <GitAutoFetcher>();
            injectionHelper.GetInstance <GitProjectOverlay>();

            GitProjectContextMenus.Init(GitManager, ExternalManager);
        }
コード例 #25
0
 public GitConflictsHandler(GitManager gitManager, GitExternalManager externalManager, GitInitializer initializer)
 {
     this.gitManager      = gitManager;
     this.externalManager = externalManager;
     this.initializer     = initializer;
 }
コード例 #26
0
 internal static void Init(GitManager gitManager, GitExternalManager externalManager)
 {
     GitProjectContextMenus.gitManager      = gitManager;
     GitProjectContextMenus.externalManager = externalManager;
 }
コード例 #27
0
ファイル: GitHistoryWindow.cs プロジェクト: bp-bling/UniGit
        private void DoToolbar(Rect rect, RepositoryInformation info)
        {
            GitProfilerProxy.BeginSample("Git History Window Toolbar GUI", this);
            GUI.Box(rect, GUIContent.none, "Toolbar");
            Rect       btRect            = new Rect(rect.x, rect.y, 64, rect.height);
            GUIContent pushButtonContent = GitGUI.GetTempContent(EditorGUIUtility.FindTexture("CollabPush"), "Push", "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.";
            }
            if (GUI.Button(btRect, pushButtonContent, "toolbarbutton"))
            {
                if (GitExternalManager.TakePush())
                {
                    GitManager.MarkDirty();
                }
                else
                {
                    ScriptableWizard.DisplayWizard <GitPushWizard>("Push", "Push").Init(selectedBranch.LoadBranch());
                }
            }
            btRect      = new Rect(btRect.x + 64, btRect.y, 64, btRect.height);
            GUI.enabled = !hasConflicts;
            if (GUI.Button(btRect, GitGUI.GetTempContent(EditorGUIUtility.IconContent("CollabPull").image, "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."), "toolbarbutton"))
            {
                Branch branch = selectedBranch.LoadBranch();
                if (branch != null)
                {
                    if (GitExternalManager.TakePull())
                    {
                        AssetDatabase.Refresh();
                        GitManager.MarkDirty();
                    }
                    else
                    {
                        ScriptableWizard.DisplayWizard <GitPullWizard>("Pull", "Pull").Init(branch);
                    }
                }
                else
                {
                    Debug.LogError("Could Not Load Branch");
                }
            }
            btRect = new Rect(btRect.x + 70, btRect.y, 64, btRect.height);
            if (GUI.Button(btRect, GitGUI.GetTempContent(EditorGUIUtility.IconContent("UniGit/GitFetch").image, "Fetch", "Get changes from remote repository but do not merge them."), "toolbarbutton"))
            {
                Branch branch = selectedBranch.LoadBranch();
                if (branch != null)
                {
                    if (branch.Remote != null)
                    {
                        if (GitExternalManager.TakeFetch(branch.Remote.Name))
                        {
                            GitManager.MarkDirty();
                        }
                        else
                        {
                            ScriptableWizard.DisplayWizard <GitFetchWizard>("Fetch", "Fetch").Init(branch);
                        }
                    }
                    else
                    {
                        Debug.LogError("Branch does not have a remote");
                    }
                }
                else
                {
                    Debug.LogError("Could not Load Branch");
                }
            }
            btRect = new Rect(btRect.x + 64, btRect.y, 64, btRect.height);
            if (GUI.Button(btRect, GitGUI.GetTempContent(EditorGUIUtility.IconContent("UniGit/GitMerge").image, "Merge", hasConflicts ? "Must Resolve conflict before merging" : "Merge fetched changes from remote repository. Changes from the latest fetch will be merged."), "toolbarbutton"))
            {
                if (GitExternalManager.TakeMerge())
                {
                    GitManager.MarkDirty();
                }
                else
                {
                    ScriptableWizard.DisplayWizard <GitMergeWizard>("Merge", "Merge");
                }
            }
            GUI.enabled = true;
            btRect      = new Rect(rect.x + rect.width - 64, btRect.y, 64, btRect.height);
            if (GUI.Button(btRect, GitGUI.GetTempContent(string.IsNullOrEmpty(selectedBranchName) ? "Branch" : selectedBranch.FriendlyName), "ToolbarDropDown"))
            {
                GenericMenu selectBranchMenu = new GenericMenu();
                foreach (var branch in cachedBranches)
                {
                    selectBranchMenu.AddItem(new GUIContent(branch.FriendlyName), false, (b) =>
                    {
                        selectedBranchName = (string)b;
                        UpdateSelectedBranch();
                    }, branch.FriendlyName);
                }
                selectBranchMenu.ShowAsContext();
            }
            btRect      = new Rect(btRect.x - 64, btRect.y, 64, btRect.height);
            GUI.enabled = GitManager.Settings.ExternalsType.HasFlag(GitSettings.ExternalsTypeEnum.Switch) || (!selectedBranch.IsRemote && !selectedBranch.IsCurrentRepositoryHead);
            if (GUI.Button(btRect, GitGUI.GetTempContent(EditorGUIUtility.IconContent("UniGit/GitCheckout").image, "Switch", selectedBranch.IsRemote ? "Cannot switch to remote branches." : selectedBranch.IsCurrentRepositoryHead ? "This branch is the active one" : "Switch to another branch"), "toolbarbutton"))
            {
                if (GitExternalManager.TakeSwitch())
                {
                    AssetDatabase.Refresh();
                    GitManager.MarkDirty();
                }

                //todo Implement native switching
            }
            GUI.enabled = true;
            GitProfilerProxy.EndSample();
        }
コード例 #28
0
ファイル: GitHistoryWindow.cs プロジェクト: bp-bling/UniGit
        private void DoCommit(Rect rect, Rect scrollRect, CommitInfo commit)
        {
            GitProfilerProxy.BeginSample("Git History Window Commit GUI", this);
            Event current = Event.current;

            if (rect.y > scrollRect.height + historyScroll.y || rect.y + scrollRect.height < historyScroll.y)
            {
                return;
            }

            BranchInfo[] branches = commit.Branches;
            bool         isHead   = commit.IsHead;
            bool         isRemote = commit.IsRemote;

            GUI.Box(new Rect(8, rect.y + 6, 16, 16), GUIContent.none, "AC LeftArrow");
            GUI.Box(new Rect(8, rect.y + 6, 16, 16), GUIContent.none, branches != null && branches.Length > 0 ? isHead ? styles.historyKnobHead : isRemote ? styles.historyKnobRemote : styles.historyKnobOther : styles.historyKnobNormal);

            float y = 8;
            float x = 12;

            if (isHead)
            {
                //GUI.Box(new Rect(commitRect.x + 4, commitRect.y, commitRect.width - 8, commitRect.height - 8), GUIContent.none, "TL SelectionButton PreDropGlow");
            }
            GUI.Box(rect, GUIContent.none, "RegionBg");
            if (isHead || isRemote)
            {
                GUI.Box(new Rect(rect.x + 4, rect.y, rect.width - 8, 5), GUIContent.none, isHead ? styles.commitLineHead : styles.commitLineRemote);
                y += 4;
            }

            if (GitManager.Settings.UseGavatar && Application.internetReachability != NetworkReachability.NotReachable)
            {
                Texture2D avatar = GetProfilePixture(commit.Committer.Email);
                if (avatar != null)
                {
                    GUI.Box(new Rect(rect.x + x, rect.y + y, 32, 32), GitGUI.GetTempContent(avatar), styles.avatar);
                }
                else
                {
                    GUI.Box(new Rect(rect.x + x, rect.y + y, 32, 32), GitManager.icons.loadingIconSmall, styles.avatar);
                }
            }
            else
            {
                UnityEngine.Random.InitState(commit.Committer.Name.GetHashCode());
                GUI.contentColor = UnityEngine.Random.ColorHSV(0, 1, 0.6f, 0.6f, 0.8f, 1, 1, 1);
                GUI.Box(new Rect(rect.x + x, rect.y + y, 32, 32), GitGUI.GetTempContent(commit.Committer.Name.Substring(0, 1).ToUpper()), styles.avatarName);
                GUI.contentColor = Color.white;
            }


            //if (avatar != null)
            //{
            //GUI.DrawTexture(new Rect(rect.x + x, rect.y + y, 32, 32), avatar);
            //}
            x += 38;
            EditorGUI.LabelField(new Rect(rect.x + x, rect.y + y, rect.width - x, EditorGUIUtility.singleLineHeight), GitGUI.GetTempContent(commit.Committer.Name), EditorStyles.boldLabel);
            y += 16;
            EditorGUI.LabelField(new Rect(rect.x + x, rect.y + y, rect.width - x, EditorGUIUtility.singleLineHeight), GitGUI.GetTempContent(FormatRemainningTime(commit.Committer.When.UtcDateTime)));
            y += EditorGUIUtility.singleLineHeight + 3;
            int firstNewLineIndex = commit.Message.IndexOf(Environment.NewLine);

            EditorGUI.LabelField(new Rect(rect.x + x, rect.y + y, rect.width - x - 10, EditorGUIUtility.singleLineHeight + 4), GitGUI.GetTempContent(firstNewLineIndex > 0 ? commit.Message.Substring(0, firstNewLineIndex) : commit.Message), styles.commitMessage);
            y += 8;
            if (branches != null)
            {
                if (branches.Length > 0)
                {
                    y += EditorGUIUtility.singleLineHeight;
                }
                foreach (var branch in branches)
                {
                    GUIStyle   style        = branch.IsRemote ? styles.remoteCommitTag : branch.IsCurrentRepositoryHead ? styles.headCommitTag : styles.otherCommitTag;
                    GUIContent labelContent = GitGUI.GetTempContent(branch.FriendlyName);
                    float      labelWidth   = style.CalcSize(labelContent).x;
                    GUI.Label(new Rect(rect.x + x, rect.y + y, labelWidth, EditorGUIUtility.singleLineHeight), labelContent, style);
                    x += labelWidth + 4;
                }
            }

            x  = 12;
            y += EditorGUIUtility.singleLineHeight * 1.5f;
            GUI.Box(new Rect(rect.x + x, rect.y + y, rect.width - x - x, EditorGUIUtility.singleLineHeight), GUIContent.none, "EyeDropperHorizontalLine");
            y += EditorGUIUtility.singleLineHeight / 3;
            EditorGUI.LabelField(new Rect(rect.x + x, rect.y + y, rect.width - x, EditorGUIUtility.singleLineHeight), GitGUI.GetTempContent(commit.Id.Sha));
            x += GUI.skin.label.CalcSize(GitGUI.GetTempContent(commit.Id.Sha)).x + 8;
            Rect buttonRect = new Rect(rect.x + x, rect.y + y, 64, EditorGUIUtility.singleLineHeight);

            x          += 64;
            GUI.enabled = selectedBranch.IsCurrentRepositoryHead && !isHead;
            if (GUI.Button(buttonRect, GitGUI.GetTempContent("Reset", "Reset changes made up to this commit"), "minibuttonleft"))
            {
                if (GitExternalManager.TakeReset(GitManager.Repository.Lookup <Commit>(commit.Id)))
                {
                    AssetDatabase.Refresh();
                    GitManager.MarkDirty();
                }
                else
                {
                    PopupWindow.Show(buttonRect, new ResetPopupWindow(GitManager.Repository.Lookup <Commit>(commit.Id)));
                }
            }
            GUI.enabled = true;
            buttonRect  = new Rect(rect.x + x, rect.y + y, 64, EditorGUIUtility.singleLineHeight);
            if (GUI.Button(buttonRect, GitGUI.GetTempContent("Details"), "minibuttonright"))
            {
                PopupWindow.Show(buttonRect, new GitCommitDetailsWindow(GitManager.Repository.Lookup <Commit>(commit.Id)));
            }

            if (rect.Contains(current.mousePosition))
            {
                if (current.type == EventType.ContextClick)
                {
                    //GenericMenu commitContexMenu = new GenericMenu();

                    //commitContexMenu.ShowAsContext();
                    current.Use();
                }
            }
            GitProfilerProxy.EndSample();
        }
コード例 #29
0
ファイル: GitManager.cs プロジェクト: bp-bling/UniGit
        internal static void Initlize()
        {
            repoPathCached = Application.dataPath.Replace("/Assets", "").Replace("/", "\\");

            if (!IsValidRepo)
            {
                return;
            }

            gitCredentials = EditorGUIUtility.Load("UniGit/Git-Credentials.asset") as GitCredentials;
            gitSettings    = EditorGUIUtility.Load("UniGit/Git-Settings.asset") as GitSettings;
            if (gitSettings == null)
            {
                gitSettings = ScriptableObject.CreateInstance <GitSettings>();
                AssetDatabase.CreateAsset(gitSettings, "Assets/Editor Default Resources/UniGit/Git-Settings.asset");
                AssetDatabase.SaveAssets();
            }

            if (IconStyle == null)
            {
                IconStyle = new GUIStyle
                {
                    imagePosition = ImagePosition.ImageOnly,
                    alignment     = TextAnchor.LowerLeft,
                    padding       = new RectOffset(2, 2, 2, 2)
                };
            }

            if (icons == null)
            {
                icons = new Icons()
                {
                    validIcon          = EditorGUIUtility.IconContent("UniGit/success"),
                    validIconSmall     = EditorGUIUtility.IconContent("UniGit/success_small"),
                    modifiedIcon       = EditorGUIUtility.IconContent("UniGit/error"),
                    modifiedIconSmall  = EditorGUIUtility.IconContent("UniGit/error_small"),
                    addedIcon          = EditorGUIUtility.IconContent("UniGit/add"),
                    addedIconSmall     = EditorGUIUtility.IconContent("UniGit/add_small"),
                    untrackedIcon      = EditorGUIUtility.IconContent("UniGit/info"),
                    untrackedIconSmall = EditorGUIUtility.IconContent("UniGit/info_small"),
                    ignoredIcon        = EditorGUIUtility.IconContent("UniGit/minus"),
                    ignoredIconSmall   = EditorGUIUtility.IconContent("UniGit/minus_small"),
                    conflictIcon       = EditorGUIUtility.IconContent("UniGit/warning"),
                    conflictIconSmall  = EditorGUIUtility.IconContent("UniGit/warning_small"),
                    deletedIcon        = EditorGUIUtility.IconContent("UniGit/deleted"),
                    deletedIconSmall   = EditorGUIUtility.IconContent("UniGit/deleted_small"),
                    renamedIcon        = EditorGUIUtility.IconContent("UniGit/renamed"),
                    renamedIconSmall   = EditorGUIUtility.IconContent("UniGit/renamed_small"),
                    loadingIconSmall   = EditorGUIUtility.IconContent("UniGit/loading"),
                    objectIcon         = EditorGUIUtility.IconContent("UniGit/object"),
                    objectIconSmall    = EditorGUIUtility.IconContent("UniGit/object_small"),
                    metaIcon           = EditorGUIUtility.IconContent("UniGit/meta"),
                    metaIconSmall      = EditorGUIUtility.IconContent("UniGit/meta_small")
                };
            }

            EditorApplication.projectWindowItemOnGUI += CustomIcons;

            GitLfsManager.Load();
            GitHookManager.Load();
            GitExternalManager.Load();
            GitCredentialsManager.Load();

            needsFetch                 = !EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isCompiling && !EditorApplication.isUpdating;
            repositoryDirty            = true;
            GitCallbacks.EditorUpdate += OnEditorUpdate;
        }
コード例 #30
0
ファイル: GitManager.cs プロジェクト: bp-bling/UniGit
 public static void ShowDiff(string path, [NotNull] Commit start, [NotNull] Commit end)
 {
     GitExternalManager.ShowDiff(path, start, end);
 }