Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.gitignore generation when non-existant. #781

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/GitHub.Api/Application/ApplicationManagerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 =
Expand Down
3 changes: 2 additions & 1 deletion src/GitHub.Api/Application/IApplicationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ public interface IApplicationManager : IDisposable
bool IsBusy { get; }
void Run();
void InitializeRepository();
void GenerateGitignore(NPath path);
event Action<IProgress> OnProgress;
void SetupGit(GitInstaller.GitInstallationState state);
void RestartRepository();
}
}
}
20 changes: 20 additions & 0 deletions src/UnityExtension/Assets/Editor/GitHub.Unity/UI/SettingsView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down