private void BuildCommitMenu(GenericMenu commitMenu, GitDiffWindow window) { if (gitManager == null) { return; } commitMenu.AddItem(new GUIContent("โ Commit"), false, () => CommitCallback(window)); if (!gitSettings.ExternalsType.IsFlagSet(GitSettingsJson.ExternalsTypeEnum.Commit)) { commitMenu.AddItem(new GUIContent("โ Commit And Push"), false, () => CommitAndPushCallback(window)); } else { commitMenu.AddDisabledItem(new GUIContent("โ Commit And Push")); } commitMenu.AddSeparator(""); commitMenu.AddItem(new GUIContent("Commit Message/โ Clear"), false, window.ClearCommitMessage); commitMenu.AddItem(new GUIContent("Commit Message/๐ Read from file"), gitSettings.ReadFromFile, () => ToggleReadFromFile(window)); if (File.Exists(initializer.GetCommitMessageFilePath(gitSettings.ActiveSubModule))) { commitMenu.AddItem(new GUIContent("Commit Message/โ Open File"), false, OpenCommitMessageFile); } else { commitMenu.AddDisabledItem(new GUIContent("Commit Message/โคท Open File")); } commitMenu.AddItem(new GUIContent("Commit Message/โบ Reload"), false, window.ReadCommitMessage); }
private static void SaveCommitMessageToFile(GitInitializer initializer, GitSettingsJson gitSettings, string message) { try { string settingsFolder = initializer.GitSettingsFolderPath; if (!Directory.Exists(settingsFolder)) { Directory.CreateDirectory(settingsFolder); } var commitMessageFilePath = initializer.GetCommitMessageFilePath(gitSettings.ActiveSubModule); var commitMessageFileDirectory = Path.GetDirectoryName(commitMessageFilePath); if (!Directory.Exists(commitMessageFileDirectory)) { Directory.CreateDirectory(commitMessageFileDirectory); } File.WriteAllText(commitMessageFileDirectory, message); } catch (UnauthorizedAccessException e) { Debug.LogWarning("Commit message file is forced to read only."); } catch (Exception e) { #if UNITY_EDITOR Debug.LogError("Could not save commit message to file. Saving to Prefs"); Debug.LogException(e); #endif } }