From 7b6a8ea60dad68280ae6dd8ee5ac083eaae142cc Mon Sep 17 00:00:00 2001 From: ThomasAunvik Date: Mon, 21 May 2018 17:06:55 +0200 Subject: [PATCH 1/2] Included Generate Gitignore Button --- .../Application/ApplicationManagerBase.cs | 7 ++++++- .../Application/IApplicationManager.cs | 3 ++- .../Editor/GitHub.Unity/UI/SettingsView.cs | 18 ++++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/GitHub.Api/Application/ApplicationManagerBase.cs b/src/GitHub.Api/Application/ApplicationManagerBase.cs index b767416f8..801b6ba9b 100644 --- a/src/GitHub.Api/Application/ApplicationManagerBase.cs +++ b/src/GitHub.Api/Application/ApplicationManagerBase.cs @@ -238,7 +238,7 @@ public void InitializeRepository() GitClient.LfsInstall().RunWithReturn(true); progress.UpdateProgress(30, 100, "Initializing..."); - AssemblyResources.ToFile(ResourceType.Generic, ".gitignore", targetPath, Environment); + GenerateGitignore(targetPath); AssemblyResources.ToFile(ResourceType.Generic, ".gitattributes", targetPath, Environment); assetsGitignore.CreateFile(); GitClient.Add(filesForInitialCommit).RunWithReturn(true); @@ -267,6 +267,11 @@ public void InitializeRepository() thread.Start(); } + public void GenerateGitignore(NPath path) + { + AssemblyResources.ToFile(ResourceType.Generic, ".gitignore", path, Environment); + } + private void ConfigureMergeSettings() { var unityYamlMergeExec = diff --git a/src/GitHub.Api/Application/IApplicationManager.cs b/src/GitHub.Api/Application/IApplicationManager.cs index 736c89957..f84d293e4 100644 --- a/src/GitHub.Api/Application/IApplicationManager.cs +++ b/src/GitHub.Api/Application/IApplicationManager.cs @@ -20,8 +20,9 @@ public interface IApplicationManager : IDisposable bool IsBusy { get; } void Run(); void InitializeRepository(); + void GenerateGitignore(NPath path); event Action OnProgress; void SetupGit(GitInstaller.GitInstallationState state); void RestartRepository(); } -} \ No newline at end of file +} diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/SettingsView.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/SettingsView.cs index fe5146dc0..0c931f45d 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/SettingsView.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/SettingsView.cs @@ -33,6 +33,7 @@ class SettingsView : Subview [SerializeField] private string newRepositoryRemoteUrl; [SerializeField] private string repositoryRemoteName; [SerializeField] private string repositoryRemoteUrl; + [SerializeField] private bool hasGitignoreFile; [SerializeField] private Vector2 scroll; [SerializeField] private UserSettingsView userSettingsView = new UserSettingsView(); [SerializeField] private int webTimeout; @@ -206,6 +207,23 @@ private void OnRepositorySettingsGUI() EditorGUI.EndDisabledGroup(); } EditorGUI.EndDisabledGroup(); + + if (!hasGitignoreFile) + { + GUIStyle missingGitignoreStyle = new GUIStyle(EditorStyles.label); + missingGitignoreStyle.normal.textColor = Color.red; + GUILayout.Label(".gitignore file is missing", missingGitignoreStyle); + + EditorGUI.BeginDisabledGroup(IsBusy); + { + if (GUILayout.Button("Generate", GUILayout.ExpandWidth(false))) + { + NPath path = new NPath(System.IO.Directory.GetParent(Application.dataPath).FullName); + Manager.GenerateGitignore(path); + } + } + EditorGUI.EndDisabledGroup(); + } } private void OnPrivacyGui() From 4550409fc884ccff2447a79daf1661d4b4b5cfe8 Mon Sep 17 00:00:00 2001 From: ThomasAunvik Date: Mon, 21 May 2018 18:07:45 +0200 Subject: [PATCH 2/2] Forgot to save. hasGitIgnore --- .../Assets/Editor/GitHub.Unity/UI/SettingsView.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/SettingsView.cs b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/SettingsView.cs index 0c931f45d..9394915eb 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/SettingsView.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/SettingsView.cs @@ -173,6 +173,8 @@ private void MaybeUpdateData() newRepositoryRemoteUrl = repositoryRemoteUrl = currentRemote.Value.Url; } } + + hasGitignoreFile = System.IO.File.Exists(System.IO.Directory.GetParent(Application.dataPath) + "/.gitignore"); } private void OnRepositorySettingsGUI()