diff --git a/src/GitHub.Api/Application/ApplicationManagerBase.cs b/src/GitHub.Api/Application/ApplicationManagerBase.cs index e009573d2..8b4bcbe5f 100644 --- a/src/GitHub.Api/Application/ApplicationManagerBase.cs +++ b/src/GitHub.Api/Application/ApplicationManagerBase.cs @@ -252,7 +252,7 @@ public void InitializeRepository() GitClient.LfsInstall().RunSynchronously(); 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).RunSynchronously(); @@ -281,6 +281,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 9b8b5f638..be7bafb39 100644 --- a/src/GitHub.Api/Application/IApplicationManager.cs +++ b/src/GitHub.Api/Application/IApplicationManager.cs @@ -19,8 +19,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 890fb09c7..a596482f1 100644 --- a/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/SettingsView.cs +++ b/src/UnityExtension/Assets/Editor/GitHub.Unity/UI/SettingsView.cs @@ -34,6 +34,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; @@ -173,6 +174,8 @@ private void MaybeUpdateData() newRepositoryRemoteUrl = repositoryRemoteUrl = currentRemote.Value.Url; } } + + hasGitignoreFile = System.IO.File.Exists(System.IO.Directory.GetParent(Application.dataPath) + "/.gitignore"); } private void OnRepositorySettingsGUI() @@ -207,6 +210,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()