Ejemplo n.º 1
0
 public MainWindowViewModel()
 {
     _gitManager        = new GitManager();
     _repositoryService = new RepositoriesService();
     _repositories      = new ObservableCollection <Models.Repository>(_repositoryService.GetRepositories());
     BrowseCommand      = new RelayCommand(SelectPath);
 }
Ejemplo n.º 2
0
    public void Setup()
    {
        injectionHelper = new InjectionHelper();
        injectionHelper.Bind <UniGitPaths>().FromInstance(new UniGitPaths(@"D:\Test_Repo", @"D:\Test_Repo"));
        injectionHelper.Bind <GitSettingsJson>().FromInstance(new GitSettingsJson
        {
            Threading = 0
        });

        injectionHelper.Bind <GitCallbacks>();
        injectionHelper.Bind <IGitPrefs>().To <GitPrefs>();
        injectionHelper.Bind <GitAsyncManager>();
        injectionHelper.Bind <GitManager>();
        injectionHelper.Bind <GitReflectionHelper>();
        injectionHelper.Bind <GitOverlay>();
        injectionHelper.Bind <GitSettingsManager>();
        injectionHelper.Bind <IGitResourceManager>().To <GitResourceManagerMock>();
        injectionHelper.Bind <ILogger>().FromInstance(Debug.unityLogger);
        injectionHelper.Bind <UniGitData>();
        injectionHelper.Bind <GitInitializer>();

        gitManager = injectionHelper.GetInstance <GitManager>();
        injectionHelper.GetInstance <GitInitializer>().InitializeRepository();
        gitCallbacks = injectionHelper.GetInstance <GitCallbacks>();
        signature    = new Signature("Test", "*****@*****.**", DateTime.Now);
        data         = injectionHelper.GetInstance <UniGitData>();

        EditorApplication.update += gitCallbacks.IssueEditorUpdate;

        gitCallbacks.IssueEditorUpdate();

        injectionHelper.CreateNonLazy();
    }
Ejemplo n.º 3
0
 public CommitViewModel(Guid repositoryId)
 {
     _repositoryId    = repositoryId;
     _gitManager      = new GitManager();
     _branchService   = new BranchService();
     _commitService   = new CommitService();
     _branches        = new ObservableCollection <Branch>(_branchService.GetBranches(_repositoryId));
     _commits         = new ObservableCollection <CommitDto>(_branchService.GetBranches(_repositoryId).CreateCommitsDto());
     _changedFiles    = new ObservableCollection <string>(_gitManager.GitStatusAsync(_repositoryId).Result);
     _stage           = new ObservableCollection <string>();
     _visibility      = Visibility.Hidden;
     _mergeVisibility = Visibility.Hidden;
     Color            = Brushes.Blue;
     ColorPush        = Brushes.Blue;
     Task.Run(async() =>
     {
         HeadBranch = await _gitManager.NameHeadBranch(_repositoryId);
     });
     Task.Run(async() =>
     {
         var result = await _gitManager.IsExistPullAsync(_repositoryId).ConfigureAwait(false);
         if (!result)
         {
             Color = Brushes.Red;
         }
     });
 }
Ejemplo n.º 4
0
    public void GetChanges()
    {
        Process p      = GitManager.GitCommand("--no-pager log HEAD..FETCH_HEAD --format=\"%an%n%at\" --numstat " + path);
        string  output = p.StandardOutput.ReadToEnd(),
                error  = p.StandardError.ReadToEnd();

        if (error.Length > 0)
        {
            UnityEngine.Debug.Log(error);
        }

        string[]         lines    = output.Split(new char[] { System.Environment.NewLine[0], System.Environment.NewLine[1] });
        List <GitChange> changesL = new List <GitChange>();

        for (int i = 0; i < lines.Length - 4; i += 4)
        {
            GitChange change = new GitChange();
            change.author = lines[i];
            change.date   = lines[i + 1];
            string[] a = lines[i + 3].Split('	');
            change.additions = System.Convert.ToInt32(a[0]);
            change.deletions = System.Convert.ToInt32(a[1]);
            change.path      = a[2];
            changesL.Add(change);
        }
        changes = changesL.ToArray();
        p.WaitForExit();
        p.Close();
    }
Ejemplo n.º 5
0
 public GitRemotesSettingsTab(GitManager gitManager,
                              GitSettingsWindow settingsWindow,
                              UniGitData data,
                              GitSettingsJson gitSettings,
                              GitCallbacks gitCallbacks,
                              GitInitializer initializer)
     : base(new GUIContent("Remotes", "Remote Repositories"), gitManager, settingsWindow, data, gitSettings, gitCallbacks, initializer)
 {
 }
Ejemplo n.º 6
0
    public static void GeneratePackage()
    {
        EditorApplication.LockReloadAssemblies();
        GitManager.DisablePostprocessing();

        try
        {
            BuildDLL();

            /*ProcessStartInfo ProcStartInfo = new ProcessStartInfo("cmd");
             * ProcStartInfo.RedirectStandardOutput = true;
             * ProcStartInfo.UseShellExecute = false;
             * ProcStartInfo.CreateNoWindow = false;
             * ProcStartInfo.RedirectStandardError = true;
             * ProcStartInfo.Verb = "runas";
             * Process MyProcess = new Process();
             * ProcStartInfo.Arguments = "/c cd UniGitVs & start /wait build_dev.bat";
             * MyProcess.StartInfo = ProcStartInfo;
             * MyProcess.Start();
             * MyProcess.WaitForExit();*/

            List <string> paths = new List <string>(AssetFiles);
            foreach (var folder in AssetFolders)
            {
                paths.AddRange(GetAssetAt(folder));
            }

            Debug.Log("---- Paths to be exported ----");
            foreach (var path in paths)
            {
                Debug.Log(path);
            }
            Debug.Log("---- ------------------- ----");

            File.Copy(Application.dataPath.Replace("Assets", "UniGitVs") + "\\bin\\Debug\\Plugins\\UniGit\\Editor\\UniGitVs.dll", Application.dataPath + "\\Plugins\\UniGit\\Editor\\UniGitVs.dll");
            File.Copy(Application.dataPath.Replace("Assets", "UniGitVs") + "\\bin\\Debug\\Plugins\\UniGit\\Editor\\UniGitVs.pdb", Application.dataPath + "\\Plugins\\UniGit\\Editor\\UniGitVs.pdb");
            //double refresh so that Unity generates the UniGitVs.dll.mdb file
            AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport | ImportAssetOptions.ForceUpdate);
            AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport | ImportAssetOptions.ForceUpdate);
            AssetDatabase.ExportPackage(paths.ToArray(), PackageName + ".unitypackage", ExportPackageOptions.Recurse | ExportPackageOptions.IncludeDependencies);
            Debug.Log("Unity Package created at: " + Application.dataPath.Replace("Assets", PackageName + ".unitypackage"));

            AssetDatabase.DeleteAsset("Assets/Plugins/UniGit/Editor/UniGitVs.dll");
            AssetDatabase.DeleteAsset("Assets/Plugins/UniGit/Editor/UniGitVs.pdb");
            AssetDatabase.DeleteAsset("Assets/Plugins/UniGit/Editor/UniGitVs.dll.mdb");
        }
        catch (Exception)
        {
            throw;
        }
        finally
        {
            EditorApplication.UnlockReloadAssemblies();
            GitManager.EnablePostprocessing();
        }
    }
Ejemplo n.º 7
0
        internal GitSettingsTab(GUIContent name, GitManager gitManager, GitSettingsWindow settingsWindow)
        {
            this.name           = name;
            this.gitManager     = gitManager;
            this.settingsWindow = settingsWindow;
            var callbacks = gitManager.Callbacks;

            callbacks.EditorUpdate     += OnEditorUpdateInternal;
            callbacks.UpdateRepository += OnGitManagerUpdateInternal;
        }
 public GitDiffWindowDiffElementRenderer(GitManager gitManager, GitOverlay gitOverlay, GitSettingsJson gitSettings, GitCallbacks gitCallbacks,
                                         IGitPrefs prefs)
 {
     this.gitManager   = gitManager;
     this.gitOverlay   = gitOverlay;
     this.gitSettings  = gitSettings;
     this.gitCallbacks = gitCallbacks;
     OnPrefsChange(prefs);
     gitCallbacks.OnPrefsChange += OnPrefsChange;
 }
Ejemplo n.º 9
0
 public GitExternalsSettingsTab(GitManager gitManager,
                                GitSettingsWindow settingsWindow,
                                GitExternalManager externalManager,
                                UniGitData data,
                                GitSettingsJson gitSettings,
                                GitCallbacks gitCallbacks,
                                GitInitializer initializer)
     : base(new GUIContent("Externals", "External Programs Helpers"), gitManager, settingsWindow, data, gitSettings, gitCallbacks, initializer)
 {
     this.externalManager = externalManager;
 }
Ejemplo n.º 10
0
 public GitLFSSettingsTab(GitManager gitManager,
                          GitSettingsWindow settingsWindow,
                          GitLfsManager lfsManager,
                          InjectionHelper injectionHelper,
                          UniGitData data,
                          GitSettingsJson gitSettings,
                          GitCallbacks gitCallbacks,
                          GitInitializer initializer)
     : base(new GUIContent("LFS", "Git Large File Storage (beta)"), gitManager, settingsWindow, data, gitSettings, gitCallbacks, initializer)
 {
     this.injectionHelper = injectionHelper;
     this.lfsManager      = lfsManager;
 }
Ejemplo n.º 11
0
 public GitSecuritySettingsTab(GitManager gitManager,
                               GitSettingsWindow settingsWindow,
                               GitCredentialsManager credentialsManager,
                               UniGitData data,
                               GitSettingsJson gitSettings,
                               GitCallbacks gitCallbacks,
                               GitInitializer initializer,
                               GitOverlay gitOverlay)
     : base(new GUIContent("Security"), gitManager, settingsWindow, data, gitSettings, gitCallbacks, initializer)
 {
     this.credentialsManager = credentialsManager;
     this.gitOverlay         = gitOverlay;
 }
Ejemplo n.º 12
0
        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            void InitializeBef()
            {
                xIcon.Source = BitmapConverter.FromBitmap(Res.Git4Nextop);
                xRepositoryGrid.IsEnabled = false;
            }

            InitializeBef();

            async void OnLogin(LoginWindow s)
            {
                void InitializeAf()
                {
                    xRepo.Content = $"{GitManager.User.Name}/\n";
                }

                s.Close();
                this.IsEnabled = true;

                var repo = await GitManager.GetRepositoriesAsync();

                var repoMap = new Dictionary <string, List <string> >();

                foreach (var item in repo)
                {
                    string userName = item.Owner.Login;

                    if (repoMap.TryGetValue(userName, out var repoList))
                    {
                        repoList.Add(item.Name);
                    }
                    else
                    {
                        repoMap.Add(userName, new List <string>());
                        repoMap[userName].Add(item.Name);
                    }
                }

                RepoWindow.Initialize(repoMap);
                InitializeAf();

                MessageBox.Show($"Welcome, {GitManager.User.Name}!", MainTitle, MessageBoxButton.OK, MessageBoxImage.Information);
            }

            var login = new LoginWindow(OnLogin);

            login.Show();

            this.IsEnabled = false;
        }
Ejemplo n.º 13
0
 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();
         EditorWindow.GetWindow <GitSettingsWindow>().Focus();
     }
     GUI.enabled = true;
     EditorGUILayout.Space();
 }
Ejemplo n.º 14
0
 public GitBranchesSettingsTab(GitManager gitManager,
                               GitSettingsWindow settingsWindow,
                               GitExternalManager externalManager,
                               InjectionHelper injectionHelper,
                               UniGitData data,
                               ILogger logger,
                               GitSettingsJson gitSettings,
                               GitCallbacks gitCallbacks,
                               GitInitializer initializer)
     : base(new GUIContent("Branches"), gitManager, settingsWindow, data, gitSettings, gitCallbacks, initializer)
 {
     this.injectionHelper = injectionHelper;
     this.externalManager = externalManager;
     this.logger          = logger;
 }
Ejemplo n.º 15
0
 public GitGeneralSettingsTab(GitManager gitManager,
                              GitSettingsWindow settingsWindow,
                              GitLfsManager lfsManager,
                              UniGitData data,
                              GitSettingsJson gitSettings,
                              GitCallbacks gitCallbacks,
                              GitInitializer initializer,
                              GitSettingsManager settingsManager,
                              UniGitPaths paths)
     : base(new GUIContent("General"), gitManager, settingsWindow, data, gitSettings, gitCallbacks, initializer)
 {
     this.paths           = paths;
     this.lfsManager      = lfsManager;
     this.settingsManager = settingsManager;
 }
Ejemplo n.º 16
0
        internal void Add(GitStatusEntry entry, IComparer <StatusListEntry> sorter)
        {
            StatusListEntry statusEntry;

            if (UniGitPathHelper.IsMetaPath(entry.LocalPath))
            {
                string mainAssetPath = GitManager.AssetPathFromMeta(entry.LocalPath);
                if (!gitSettings.ShowEmptyFolders && gitManager.IsEmptyFolder(mainAssetPath))
                {
                    return;
                }

                int index = entries.FindIndex(e => e.LocalPath == mainAssetPath);
                if (index >= 0)
                {
                    StatusListEntry ent = entries[index];
                    ent.MetaChange |= MetaChangeEnum.Meta;
                    ent.State      |= entry.Status;
                    entries[index]  = ent;
                    return;
                }

                statusEntry = new StatusListEntry(mainAssetPath, entry.Status, MetaChangeEnum.Meta, CalculateFlags(entry));
            }
            else
            {
                int index = entries.FindIndex(e => e.LocalPath == entry.LocalPath);
                if (index >= 0)
                {
                    StatusListEntry ent = entries[index];
                    ent.State     |= entry.Status;
                    entries[index] = ent;
                    return;
                }

                statusEntry = new StatusListEntry(entry.LocalPath, entry.Status, MetaChangeEnum.Object, CalculateFlags(entry));
            }

            if (sorter != null)
            {
                AddSorted(statusEntry, sorter);
            }
            else
            {
                entries.Add(statusEntry);
            }
        }
Ejemplo n.º 17
0
        public Build()
        {
            d      = new Devenv(Path.Combine(f.FolderPath, "ImageResizer.sln"));
            extras = new Devenv(Path.Combine(f.FolderPath, "Other-Plugins-With-External-Dependencies.sln"));
            v      = new VersionEditor(Path.Combine(f.FolderPath, "SharedAssemblyInfo.cs"));
            g      = new GitManager(f.ParentPath);
            nuget  = new NugetManager(Path.Combine(f.ParentPath, "nuget"));


            //TODO: nuget and s3 API key need to go.


            packages.Add(new PackageDescriptor("min", PackMin));
            packages.Add(new PackageDescriptor("full", PackFull));
            packages.Add(new PackageDescriptor("standard", PackStandard));
            packages.Add(new PackageDescriptor("allbinaries", PackAllBinaries));
        }
Ejemplo n.º 18
0
    void OnGUI()
    {
        GUI.skin = skin;

        GUILayout.BeginHorizontal(EditorStyles.toolbar);
        if (GUILayout.Button("Commit", EditorStyles.toolbarButton))
        {
        }
        if (GUILayout.Button("Push", EditorStyles.toolbarButton))
        {
        }
        if (GUILayout.Button("Fetch", EditorStyles.toolbarButton))
        {
            GitManager.Log();
        }
        if (GUILayout.Button("Pull", EditorStyles.toolbarButton))
        {
        }

        GUILayout.EndHorizontal();

        showRemote = EditorGUILayout.Foldout(showRemote, "Remote", true);
        if (showRemote)
        {
            foreach (GitFile file in GitManager.fetch)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(file.path);
                GUILayout.Label(file.additions.ToString(), "Additions");
                GUILayout.Label(file.deletions.ToString(), "Deletions");
                GUILayout.EndHorizontal();
            }
        }
        showLocal = EditorGUILayout.Foldout(showLocal, "Local", true);
        if (showLocal)
        {
            foreach (GitFile file in GitManager.head)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(file.path);
                GUILayout.Label(file.additions.ToString(), "Additions");
                GUILayout.Label(file.deletions.ToString(), "Deletions");
                GUILayout.EndHorizontal();
            }
        }
    }
Ejemplo n.º 19
0
 public void RemoveRange(string[] paths)
 {
     foreach (var path in paths)
     {
         if (UniGitPathHelper.IsMetaPath(path))
         {
             var assetPath = GitManager.AssetPathFromMeta(path);
             for (int i = entries.Count - 1; i >= 0; i--)
             {
                 var entry = entries[i];
                 if (entry.LocalPath == assetPath)
                 {
                     if (entry.MetaChange.HasFlag(MetaChangeEnum.Object))
                     {
                         entry.MetaChange = entry.MetaChange.ClearFlags(MetaChangeEnum.Meta);
                         entries[i]       = entry;
                     }
                     else
                     {
                         entries.RemoveAt(i);
                     }
                 }
             }
         }
         else
         {
             for (int i = entries.Count - 1; i >= 0; i--)
             {
                 var entry = entries[i];
                 if (entry.LocalPath == path)
                 {
                     if (entry.MetaChange.HasFlag(MetaChangeEnum.Meta))
                     {
                         entry.MetaChange = entry.MetaChange.ClearFlags(MetaChangeEnum.Object);
                         entries[i]       = entry;
                     }
                     else
                     {
                         entries.RemoveAt(i);
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 20
0
 internal GitSettingsTab(GUIContent name,
                         GitManager gitManager,
                         GitSettingsWindow settingsWindow,
                         UniGitData data,
                         GitSettingsJson gitSettings,
                         GitCallbacks gitCallbacks,
                         GitInitializer initializer)
 {
     this.name                      = name;
     this.gitManager                = gitManager;
     this.settingsWindow            = settingsWindow;
     this.data                      = data;
     this.gitSettings               = gitSettings;
     this.gitCallbacks              = gitCallbacks;
     this.initializer               = initializer;
     gitCallbacks.EditorUpdate     += OnEditorUpdateInternal;
     gitCallbacks.UpdateRepository += OnGitManagerUpdateInternal;
 }
Ejemplo n.º 21
0
    public void Setup()
    {
        injectionHelper = new InjectionHelper();
        injectionHelper.Bind <string>().WithId("repoPath").FromInstance(@"D:\Test_Repo");
        injectionHelper.Bind <GitSettingsJson>().FromInstance(new GitSettingsJson {
            Threading = 0
        });
        injectionHelper.Bind <GitCallbacks>();
        injectionHelper.Bind <IGitPrefs>().To <GitPrefs>();
        injectionHelper.Bind <GitAsyncManager>();
        injectionHelper.Bind <GitManager>();

        gitManager = injectionHelper.GetInstance <GitManager>();
        gitManager.InitilizeRepository();
        signature = new Signature("Test", "*****@*****.**", DateTime.Now);

        injectionHelper.GetInstance <GitCallbacks>().IssueEditorUpdate();
    }
Ejemplo n.º 22
0
        private async void xLogin_Click(object sender, RoutedEventArgs e)
        {
            var token = xToken.Password;

            if (await GitManager.Initialize(token))
            {
                _onLogin(this);
            }
            else
            {
                string reason = "Invalid token";

                if (!Network.IsAvailable)
                {
                    reason = "Network not available";
                }

                MessageBox.Show($"Can't login on GitHub.\n{reason}", MainWindow.MainTitle, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Ejemplo n.º 23
0
    public IEnumerator MissingFolderForDriftingMetaCreated()
    {
        injectionHelper.GetInstance <GitSettingsJson>().CreateFoldersForDriftingMeta = true;

        string metaFileName = "Test Folder.meta";
        string metaFilePath = Path.Combine(gitManager.GetCurrentRepoPath(), metaFileName);

        File.WriteAllText(metaFilePath, "Test Meta");
        Assert.IsTrue(File.Exists(metaFilePath));
        gitManager.AutoStage(metaFileName);
        yield return(null);

        GitStatusEntry metaStatusEntry;

        Assert.IsTrue(data.RepositoryStatus.Get(metaFileName, out metaStatusEntry));
        Assert.AreEqual(FileStatus.NewInIndex, metaStatusEntry.Status);
        var addedMetaCommit = gitManager.Repository.Commit("Drifting Meta Commit", signature, signature);

        yield return(null);

        File.Delete(metaFilePath);
        gitManager.AutoStage(metaFileName);
        yield return(null);

        Assert.IsTrue(data.RepositoryStatus.Get(metaFileName, out metaStatusEntry));
        Assert.AreEqual(FileStatus.DeletedFromIndex, metaStatusEntry.Status);
        Assert.IsFalse(File.Exists(metaFilePath));
        gitManager.Repository.Commit("Removed meta", signature, signature);
        GitCommands.Checkout(gitManager.Repository, addedMetaCommit, new CheckoutOptions()
        {
            CheckoutNotifyFlags = CheckoutNotifyFlags.Updated,
            OnCheckoutNotify    = gitManager.CheckoutNotifyHandler
        });
        Assert.IsTrue(File.Exists(metaFilePath));
        Assert.IsTrue(Directory.Exists(GitManager.AssetPathFromMeta(metaFilePath)));
    }
        internal void DoFileDiff(Rect rect, StatusListEntry info, bool enabled, bool selected, GitDiffWindow window)
        {
            RectOffset elementPadding = GetElementStyle().padding;
            float      iconSize       = GetElementStyle().fixedHeight - elementPadding.vertical;
            float      toggleSize     = styles.toggle.fixedHeight;

            Event  current     = Event.current;
            string projectPath = gitManager.ToProjectPath(info.LocalPath);
            string fileName    = info.Name;

            GitGUI.StartEnable(enabled);
            Rect  stageToggleRect = new Rect(rect.x + rect.width - toggleSize * 2, rect.y + (rect.height - toggleSize) * 0.5f, toggleSize, toggleSize);
            bool  canUnstage      = GitManager.CanUnstage(info.State);
            bool  canStage        = GitManager.CanStage(info.State);
            float maxPathSize     = rect.width - stageToggleRect.width - toggleSize - 21;

            if (current.type == EventType.Repaint)
            {
                (selected ? styles.diffElementSelected : GetElementStyle()).Draw(rect, false, false, false, false);
            }

            if (canStage && canUnstage)
            {
                maxPathSize -= stageToggleRect.width - 4;
                Rect stageWarnningRect = new Rect(stageToggleRect.x - stageToggleRect.width - 4, stageToggleRect.y, stageToggleRect.width, stageToggleRect.height);
                EditorGUIUtility.AddCursorRect(stageWarnningRect, MouseCursor.Link);
                if (GUI.Button(stageWarnningRect, GitGUI.IconContent("console.warnicon", "", "Unstaged changed pending. Stage to update index."), GUIStyle.none))
                {
                    string[] localPaths = gitManager.GetPathWithMeta(info.LocalPath).ToArray();
                    if (gitManager.Threading.IsFlagSet(GitSettingsJson.ThreadingType.Stage))
                    {
                        gitManager.AsyncStage(localPaths).onComplete += (o) => { window.Repaint(); };
                    }
                    else
                    {
                        GitCommands.Stage(gitManager.Repository, localPaths);
                        gitManager.MarkDirtyAuto(localPaths);
                    }
                    window.Repaint();
                }
            }

            if (current.type == EventType.Repaint)
            {
                Object asset = null;
                if (UniGitPathHelper.IsPathInAssetFolder(projectPath))
                {
                    asset = AssetDatabase.LoadAssetAtPath(UniGitPathHelper.IsMetaPath(projectPath) ? GitManager.AssetPathFromMeta(projectPath) : projectPath, typeof(Object));
                }

                string     extension  = Path.GetExtension(projectPath);
                GUIContent tmpContent = GUIContent.none;
                if (string.IsNullOrEmpty(extension))
                {
                    tmpContent = GitGUI.GetTempContent(styles.folderIcon, "Folder");
                }

                if (tmpContent.image == null)
                {
                    if (asset != null)
                    {
                        tmpContent = GitGUI.GetTempContent(string.Empty, AssetDatabase.GetCachedIcon(projectPath), asset.GetType().Name);
                    }
                    else
                    {
                        tmpContent = GitGUI.GetTempContent(styles.defaultAssetIcon, "Unknown Type");
                    }
                }

                float x = rect.x + elementPadding.left;
                GUI.Box(new Rect(x, rect.y + elementPadding.top, iconSize, iconSize), tmpContent, styles.assetIcon);
                x += iconSize + 8;

                styles.diffElementName.Draw(new Rect(x, rect.y + elementPadding.top + 2, rect.width - elementPadding.right - iconSize - rect.height, EditorGUIUtility.singleLineHeight), GitGUI.GetTempContent(fileName), false, selected, selected, false);

                x = rect.x + elementPadding.left + iconSize + 8;
                foreach (var diffTypeIcon in gitOverlay.GetDiffTypeIcons(info.State, false))
                {
                    GUI.Box(new Rect(x, rect.y + elementPadding.top + EditorGUIUtility.singleLineHeight + 4, 21, 21), diffTypeIcon, GUIStyle.none);
                    x += 25;
                }

                if (info.MetaChange == (MetaChangeEnum.Object | MetaChangeEnum.Meta))
                {
                    GUI.Box(new Rect(x, rect.y + elementPadding.top + EditorGUIUtility.singleLineHeight + 4, 21, 21), GitGUI.GetTempContent(gitOverlay.icons.objectIconSmall.image, "main asset file changed"), GUIStyle.none);
                    x += 25;
                }
                if (info.MetaChange.IsFlagSet(MetaChangeEnum.Meta))
                {
                    GUI.Box(new Rect(x, rect.y + elementPadding.top + EditorGUIUtility.singleLineHeight + 4, 21, 21), GitGUI.GetTempContent(gitOverlay.icons.metaIconSmall.image, ".meta file changed"), GUIStyle.none);
                    x += 25;
                }
                if (info.Flags.IsFlagSet(StatusEntryFlags.IsLfs))
                {
                    GUI.Box(new Rect(x, rect.y + elementPadding.top + EditorGUIUtility.singleLineHeight + 4, 21, 21), GitGUI.GetTempContent(gitOverlay.icons.lfsObjectIconSmall.image, "Lfs Object"), GUIStyle.none);
                    x += 25;
                }
                if (info.Flags.IsFlagSet(StatusEntryFlags.IsSubModule))
                {
                    GUI.Box(new Rect(x, rect.y + elementPadding.top + EditorGUIUtility.singleLineHeight + 4, 21, 21), GitGUI.GetTempContent(gitOverlay.icons.submoduleTagIconSmall.image, "Sub Module"), GUIStyle.none);
                    x += 25;
                }

                Vector2 pathSize = styles.diffElementPath.CalcSize(GitGUI.GetTempContent(projectPath));
                pathSize.x = Mathf.Min(pathSize.x, maxPathSize - x);

                Rect pathRect = new Rect(x, rect.y + elementPadding.top + EditorGUIUtility.singleLineHeight, pathSize.x, EditorGUIUtility.singleLineHeight * 2);

                styles.diffElementPath.Draw(pathRect, GitGUI.GetTempContent(projectPath), false, selected, selected, false);
                x += pathRect.width + 4;

                if (!enabled)
                {
                    GUI.Box(new Rect(x, rect.y + elementPadding.top + EditorGUIUtility.singleLineHeight + 4, 21, 21), GitGUI.GetTempSpinAnimatedTexture(), GUIStyle.none);
                    //spinning animation needs constant repaint
                    if (gitSettings.AnimationType.HasFlag(GitSettingsJson.AnimationTypeEnum.Loading))
                    {
                        window.Repaint();
                    }
                }
            }

            if (canUnstage || canStage)
            {
                EditorGUI.BeginChangeCheck();
                EditorGUIUtility.AddCursorRect(stageToggleRect, MouseCursor.Link);
                EditorGUI.Toggle(stageToggleRect, canUnstage, styles.toggle);
                if (EditorGUI.EndChangeCheck())
                {
                    bool updateFlag = false;
                    if (GitManager.CanStage(info.State))
                    {
                        string[] paths = gitManager.GetPathWithMeta(info.LocalPath).ToArray();
                        if (gitManager.Threading.IsFlagSet(GitSettingsJson.ThreadingType.Stage))
                        {
                            gitManager.AsyncStage(paths).onComplete += (o) => { window.Repaint(); };
                        }
                        else
                        {
                            GitCommands.Stage(gitManager.Repository, paths);
                            gitManager.MarkDirtyAuto(paths);
                        }
                        updateFlag = true;
                    }
                    else if (GitManager.CanUnstage(info.State))
                    {
                        string[] paths = gitManager.GetPathWithMeta(info.LocalPath).ToArray();
                        if (gitManager.Threading.IsFlagSet(GitSettingsJson.ThreadingType.Unstage))
                        {
                            gitManager.AsyncUnstage(paths).onComplete += (o) => { window.Repaint(); };
                        }
                        else
                        {
                            GitCommands.Unstage(gitManager.Repository, paths);
                            gitManager.MarkDirtyAuto(paths);
                        }
                        updateFlag = true;
                    }

                    if (updateFlag)
                    {
                        window.Repaint();
                        current.Use();
                    }
                }
            }
            GitGUI.EndEnable();
        }
Ejemplo n.º 25
0
        internal override void OnGUI(Rect rect, Event current)
        {
            GitSettingsJson settings = GitManager.Settings;

            scroll = EditorGUILayout.BeginScrollView(scroll);
            //todo cache general settings to reduce lookup
            GUILayout.Box(GitGUI.IconContent("SceneAsset Icon", "Unity Settings"), "IN BigTitle", GUILayout.ExpandWidth(true), GUILayout.Height(EditorGUIUtility.singleLineHeight * 1.6f));

            if (settings != null)
            {
                bool save = false;

                EditorGUI.BeginChangeCheck();
                settings.AutoStage = EditorGUILayout.Toggle(GitGUI.GetTempContent("Auto Stage", "Auto stage changes for committing when an asset is modified"), settings.AutoStage);
                settings.AutoFetch = EditorGUILayout.Toggle(GitGUI.GetTempContent("Auto Fetch", "Auto fetch repository changes when possible. This will tell you about changes to the remote repository without having to pull. This only works with the Credentials Manager."), settings.AutoFetch);
                save = EditorGUI.EndChangeCheck();
                EditorGUI.BeginChangeCheck();
                settings.ProjectStatusOverlayDepth = EditorGUILayout.DelayedIntField(GitGUI.GetTempContent("Project Status Overlay Depth", "The maximum depth at which overlays will be shown in the Project Window. This means that folders at levels higher than this will not be marked as changed. -1 indicates no limit"), settings.ProjectStatusOverlayDepth);
                settings.ShowEmptyFolders          = EditorGUILayout.Toggle(new GUIContent("Show Empty Folders", "Show status for empty folder meta files and auto stage them, if 'Auto stage' option is enabled."), settings.ShowEmptyFolders);
                settings.GitStatusMultithreaded    = EditorGUILayout.Toggle(GitGUI.GetTempContent("Git Status Multithreaded", "Should Git status retrieval be multithreaded."), settings.GitStatusMultithreaded);
                settings.UseGavatar            = EditorGUILayout.Toggle(GitGUI.GetTempContent("Use Gavatar", "Load Gavatars based on the committer's email address."), settings.UseGavatar);
                settings.MaxCommitTextAreaSize = EditorGUILayout.DelayedFloatField(GitGUI.GetTempContent("Max Commit Text Area Size", "The maximum height the commit text area can expand to."), settings.MaxCommitTextAreaSize);
                settings.DetectRenames         = EditorGUILayout.Toggle(GitGUI.GetTempContent("Detect Renames", "Detect Renames. This will make UniGit detect rename changes of files. Note that this feature is not always working as expected do the the modular updating and how Git itself works."), settings.DetectRenames);
                settings.UseSimpleContextMenus = EditorGUILayout.Toggle(GitGUI.GetTempContent("Use Simple Context Menus", "Use Unity's default context menu on Diff window, instead of the UniGit one (with icons)"), settings.UseSimpleContextMenus);
                if (EditorGUI.EndChangeCheck())
                {
                    save = true;
                    GitManager.MarkDirty();
                }

                if (save)
                {
                    settings.MarkDirty();
                }
            }

            GUILayout.Box(GitGUI.IconContent("ListIcon", "Git Settings"), "IN BigTitle", GUILayout.ExpandWidth(true), GUILayout.Height(EditorGUIUtility.singleLineHeight * 1.6f));

            EditorGUILayout.LabelField(GitGUI.GetTempContent("User"), EditorStyles.boldLabel);
            EditorGUI.indentLevel = 1;
            GitGUI.DoConfigStringField(GitGUI.GetTempContent("Name", "Your full name to be recorded in any newly created commits."), "user.name", "");
            GitGUI.DoConfigStringField(GitGUI.GetTempContent("Email", "Your email address to be recorded in any newly created commits."), "user.email", "");
            EditorGUI.indentLevel = 0;

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

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

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

            EditorGUILayout.LabelField(GitGUI.GetTempContent("HTTP"), EditorStyles.boldLabel);
            EditorGUI.indentLevel = 1;
            GitGUI.DoConfigToggle(GitGUI.GetTempContent("Verify SSL Crtificate", "Whether to verify the SSL certificate when fetching or pushing over HTTPS."), "http.sslVerify", true);
            string oldPath = GitManager.Repository.Config.GetValueOrDefault <string>("http.sslCAInfo");

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PrefixLabel(GitGUI.GetTempContent("SSL Certificate File", "File containing the certificates to verify the peer with when fetching or pushing over HTTPS."));
            if (GUILayout.Button(GitGUI.GetTempContent(oldPath), "TE ToolbarDropDown"))
            {
                EditorGUI.BeginChangeCheck();
                string newPath = EditorUtility.OpenFilePanelWithFilters("Certificate", string.IsNullOrEmpty(oldPath) ? Application.dataPath : Path.GetFullPath(oldPath), new string[] { "", "cer", "", "pom", "", "crt" });
                if (oldPath != newPath)
                {
                    GitManager.Repository.Config.Set("http.sslCAInfo", newPath);
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUI.indentLevel = 0;

            GUILayout.Box(GitGUI.IconContent("IN LockButton on", "Git Ignore"), "IN BigTitle", GUILayout.ExpandWidth(true), GUILayout.Height(EditorGUIUtility.singleLineHeight * 1.6f));

            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button(GitGUI.IconContent("IN LockButton on", "Open Git Ignore File")))
            {
                OpenGitIgnore();
            }
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndScrollView();
        }
Ejemplo n.º 26
0
 public GitExtensionsAdapter(GitManager gitManager) : base(gitManager)
 {
 }
Ejemplo n.º 27
0
 public AddRepositoryPopup(GitManager gitManager, RemoteCollection remoteCollection)
 {
     this.gitManager       = gitManager;
     this.remoteCollection = remoteCollection;
 }
Ejemplo n.º 28
0
 public GitLfsPrePushHook(GitManager gitManager, GitLfsManager lfsManager) : base(gitManager)
 {
     this.lfsManager = lfsManager;
 }
Ejemplo n.º 29
0
 public GitLFSSettingsTab(GitManager gitManager, GitSettingsWindow settingsWindow, GitLfsManager lfsManager)
     : base(new GUIContent("LFS", "Git Large File Storage (beta)"), gitManager, settingsWindow)
 {
     this.lfsManager = lfsManager;
 }
Ejemplo n.º 30
0
    public static void GeneratePackage()
    {
        EditorApplication.LockReloadAssemblies();
        GitManager.DisablePostprocessing();

        try
        {
            UpdateVSProject();

            string devnetPath = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\devenv.exe", null, null).ToString();
            if (string.IsNullOrEmpty(devnetPath))
            {
                Debug.LogError("Could not find devnet in registry!");
                devnetPath = EditorUtility.OpenFilePanel("Devnet.Exe", "", "exe");

                if (string.IsNullOrEmpty(devnetPath))
                {
                    Debug.LogError("Could not find devnet!");
                    return;
                }
            }
            else
            {
                Debug.Log("Devnet Path: " + devnetPath);
            }

            Process devnetProcess = new Process();
            devnetProcess.StartInfo.Arguments              = string.Format("{0} {1} {2} {3}", "\"UniGitVs.sln\"", " /build Debug", "/project \"UniGitVs.csproj\"", "/projectconfig Debug");
            devnetProcess.StartInfo.RedirectStandardError  = true;
            devnetProcess.StartInfo.RedirectStandardOutput = true;
            devnetProcess.StartInfo.UseShellExecute        = false;
            devnetProcess.StartInfo.FileName = devnetPath.ToString();
            //devnetProcess.StartInfo.Verb = "runas";
            devnetProcess.StartInfo.WorkingDirectory = Application.dataPath.Replace("/", "\\").Replace("Assets", "UniGitVs");

            devnetProcess.Start();
            EditorUtility.DisplayProgressBar("Building Project", "Building in progress", 0.1f);
            devnetProcess.WaitForExit();
            EditorUtility.ClearProgressBar();

            string logs           = devnetProcess.StandardOutput.ReadToEnd();
            string errors         = devnetProcess.StandardError.ReadToEnd();
            bool   buildHasOutput = !string.IsNullOrEmpty(logs) || !string.IsNullOrEmpty(errors);

            if (buildHasOutput)
            {
                Debug.Log("---- Build Process Output ----");
                if (!string.IsNullOrEmpty(logs))
                {
                    Debug.Log(logs);
                }

                if (!string.IsNullOrEmpty(errors))
                {
                    Debug.LogError(errors);
                }
                Debug.Log("---- ------------------- ----");
            }

            /*ProcessStartInfo ProcStartInfo = new ProcessStartInfo("cmd");
             * ProcStartInfo.RedirectStandardOutput = true;
             * ProcStartInfo.UseShellExecute = false;
             * ProcStartInfo.CreateNoWindow = false;
             * ProcStartInfo.RedirectStandardError = true;
             * ProcStartInfo.Verb = "runas";
             * Process MyProcess = new Process();
             * ProcStartInfo.Arguments = "/c cd UniGitVs & start /wait build_dev.bat";
             * MyProcess.StartInfo = ProcStartInfo;
             * MyProcess.Start();
             * MyProcess.WaitForExit();*/

            List <string> paths = new List <string>(AssetFiles);
            foreach (var folder in AssetFolders)
            {
                paths.AddRange(GetAssetAt(folder));
            }

            Debug.Log("---- Paths to be exported ----");
            foreach (var path in paths)
            {
                Debug.Log(path);
            }
            Debug.Log("---- ------------------- ----");

            File.Copy(Application.dataPath.Replace("Assets", "UniGitVs") + "\\bin\\Debug\\Plugins\\UniGit\\Editor\\UniGitVs.dll", Application.dataPath + "\\Plugins\\UniGit\\Editor\\UniGitVs.dll");
            File.Copy(Application.dataPath.Replace("Assets", "UniGitVs") + "\\bin\\Debug\\Plugins\\UniGit\\Editor\\UniGitVs.pdb", Application.dataPath + "\\Plugins\\UniGit\\Editor\\UniGitVs.pdb");
            //double refresh so that Unity generates the UniGitVs.dll.mdb file
            AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport | ImportAssetOptions.ForceUpdate);
            AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport | ImportAssetOptions.ForceUpdate);
            AssetDatabase.ExportPackage(paths.ToArray(), PackageName + ".unitypackage", ExportPackageOptions.Recurse | ExportPackageOptions.IncludeDependencies);
            Debug.Log("Unity Package created at: " + Application.dataPath.Replace("Assets", PackageName + ".unitypackage"));

            AssetDatabase.DeleteAsset("Assets/Plugins/UniGit/Editor/UniGitVs.dll");
            AssetDatabase.DeleteAsset("Assets/Plugins/UniGit/Editor/UniGitVs.pdb");
            AssetDatabase.DeleteAsset("Assets/Plugins/UniGit/Editor/UniGitVs.dll.mdb");
        }
        catch (Exception)
        {
            throw;
        }
        finally
        {
            EditorApplication.UnlockReloadAssemblies();
            GitManager.EnablePostprocessing();
        }
    }