public static void DrawPackageDownUpButton(GitLinkOnDisk disk, bool affectPackage = true) { if (!disk.HasUrl()) { return; } bool isDirectoryCreated = Directory.Exists(disk.GetDirectoryPath()); bool isGitFolderPresent = disk.HasUrl(); GUIStyle disableStyle = GetDisableStyle(); GUIStyle enableStyle = GetEnableStyle(); GUILayout.BeginHorizontal(); bool downAllow = true; if (GUILayout.Button("Down", downAllow ? enableStyle : disableStyle)) { UnityPackageUtility.Down(disk.GetDirectoryPath(), disk.GetUrl(), affectPackage); } bool upAllow = isDirectoryCreated && isGitFolderPresent; if (GUILayout.Button("Up", upAllow ? enableStyle : disableStyle)) { if (upAllow) { UnityPackageUtility.Up(disk.GetDirectoryPath(), affectPackage); } } GUILayout.EndHorizontal(); }
public static void PushLocalGitToOnlineAccount(GitLinkOnDisk gitLink, ref string userName, ref string projectNameId, ref int dropDownSelectionServer, ref bool compact) { compact = EditorGUILayout.Foldout(compact, "→ Push repository online", EditorStyles.boldLabel); if (!compact) { GUILayout.BeginHorizontal(); GUILayout.Label("User id "); userName = GUILayout.TextField(userName, GUILayout.MaxWidth(500)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Project id "); projectNameId = GUILayout.TextField(projectNameId, GUILayout.MaxWidth(500)); GUILayout.EndHorizontal(); dropDownSelectionServer = EditorGUILayout.Popup(dropDownSelectionServer, new string[] { "GitLab", "GitHub" }); string urlToCreate = ""; if (dropDownSelectionServer == 0) { urlToCreate = string.Format("https://gitlab.com/{0}/{1}.git", userName, projectNameId); } if (dropDownSelectionServer == 1) { urlToCreate = "https://github.com?name=" + projectNameId; } if (userName != "" && projectNameId != "") { string url = ""; if (dropDownSelectionServer == 0) { if (GUILayout.Button("Create/Push Online")) { QuickGit.PushLocalToGitLab(gitLink.GetDirectoryPath(), userName, projectNameId, out url); urlToCreate = string.Format("https://gitlab.com/{0}/{1}.git", userName, projectNameId); Application.OpenURL(urlToCreate); } } if (dropDownSelectionServer == 1) { if (GUILayout.Button("Go to Github")) { //QuickGit.PushLocalToGitHub(gitLink.GetDirectoryPath(), userName, projectNameId, out url); urlToCreate = "https://github.com?name=" + projectNameId; Application.OpenURL(url); } } } DisplayDeleteRepositoryOptions(gitLink); DisplayMessageToHelp("Please enter your account id and the name of the project in the git link: " + urlToCreate); } }
public static void GetAffectedGit(UnityPathSelectionInfo selector, out GitLinkOnDisk gitAffected) { string path = selector.GetAbsolutePath(true); if (QuickGit.IsPathHasGitRootFolder(path)) { gitAffected = new GitLinkOnDisk(path); } QuickGit.GetGitInParents(path, QuickGit.PathReadDirection.LeafToRoot, out gitAffected); }
public static void GetGitsOnFromRoot(List <GitLinkOnDisk> givenGits, out GitLinkOnDisk gitOnTopOfPath) { if (givenGits.Count <= 0) { gitOnTopOfPath = null; } else { gitOnTopOfPath = givenGits.OrderBy(k => k.GetDirectoryPath().Length).First(); } }
public static void DisplayGitInfoWithCommand(GitLinkOnDisk gitDirectory, ref bool displayInfo, ref bool displayAdvance) { if (displayInfo = EditorGUILayout.Foldout(displayInfo, "Git: " + gitDirectory.GetName())) { DisplayGitLink(gitDirectory); if (displayAdvance = EditorGUILayout.Foldout(displayAdvance, " Git Commands")) { DisplayGitCommands(gitDirectory); } } }
public static void DisplayGitCommands(GitLinkOnDisk gitDirectory) { bool hasUrl = gitDirectory.HasUrl(); if (gitDirectory.Exist()) { GUILayout.BeginHorizontal(); if (GUILayout.Button("Add -a")) { QuickGit.Add(gitDirectory.GetDirectoryPath()); } if (GUILayout.Button("Commit")) { QuickGit.Commit(gitDirectory.GetDirectoryPath()); } if (hasUrl && GUILayout.Button("Pull")) { QuickGit.Pull(gitDirectory.GetDirectoryPath()); } if (hasUrl && GUILayout.Button("Push")) { QuickGit.Push(gitDirectory.GetDirectoryPath()); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (hasUrl && GUILayout.Button("Add>Commit>Pull")) { QuickGit.AddCommitAndPush(gitDirectory.GetDirectoryPath()); } if (hasUrl && GUILayout.Button("A>C>Pull + A>C>push")) { QuickGit.PullPushWithAddAndCommit(gitDirectory.GetDirectoryPath()); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Open explorer")) { Application.OpenURL(gitDirectory.GetDirectoryPath()); } if (GUILayout.Button("See Status")) { QuickGit.OpenCmd(gitDirectory.GetDirectoryPath()); } if (hasUrl && GUILayout.Button("Go to Server")) { Application.OpenURL(gitDirectory.GetUrl()); } GUILayout.EndHorizontal(); } }
public static void GetGitsInParents(string path, out List <GitLinkOnDisk> links) { links = new List <GitLinkOnDisk>(); string[] parentsPath = UnityPaths.GetAllParents(path, true); for (int i = 0; i < parentsPath.Length; i++) { if (IsPathContaintGitRoot(parentsPath[i])) { GitLinkOnDisk gd = new GitLinkOnDisk(parentsPath[i]); links.Add(gd); } } }
public static void GetGitInDirectory(string path, out GitLinkOnDisk gitLink, bool searchInChildens) { List <GitLinkOnDisk> gits; GetGitsInDirectory(path, out gits, searchInChildens); if (gits.Count > 0) { gitLink = gits[0]; } else { gitLink = null; } }
public static void GetGitInParents(string path, PathReadDirection readMode, out GitLinkOnDisk git) { List <GitLinkOnDisk> links; GetGitsInParents(path, out links); if (readMode == PathReadDirection.RootToLeaf) { GetGitsOnFromRoot(links, out git); } else { GetGitsFromLeaf(links, out git); } }
public static void DisplayDeleteRepositoryOptions(GitLinkOnDisk gitLink) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Remove Repository")) { FileUtil.DeleteFileOrDirectory(gitLink.GetDirectoryPath()); RefreshDatabase(); } if (GUILayout.Button("Remove .git")) { FileUtil.DeleteFileOrDirectory(gitLink.GetDirectoryPath() + "/.git"); RefreshDatabase(); } EditorGUILayout.EndHorizontal(); }
public static void DisplayGitLink(GitLinkOnDisk git) { GUIStyle button = new GUIStyle(GUI.skin.button); GUILayout.BeginHorizontal(); if (GUILayout.Button("> Git:", button, GUILayout.MaxWidth(50))) { Application.OpenURL(git.GetUrl()); } EditorGUILayout.TextField(git.GetUrl()); if (GUILayout.Button("> Path:", new GUIStyle(GUI.skin.button), GUILayout.MaxWidth(50))) { Application.OpenURL(git.GetDirectoryPath()); } EditorGUILayout.TextField(git.GetDirectoryPath()); GUILayout.EndHorizontal(); }
public static string CreateBasicDefaultOnFrom(GitLinkOnDisk gitLink) { string text = "# Welcome to: " + gitLink.GetUrl() + " \n"; text += "Never used a package before ? \n"; text += "You don't understand how to use this git repository ? \n"; text += "May be you should stop now and learn the basic: \n"; text += "https://eloistree.page.link/hellopackage \n"; text += " \n"; text += "You know how the music work ? \n"; text += "Here is the copy past link of this package manager: \n"; text += "`" + gitLink.GetUrl() + "` \n"; text += " \n"; text += "In hope that this code help you. \n"; text += "Kind regards, \n"; text += Application.companyName; return(text); }
public static void DrawEditorDefaultInterface(ReadMeFileStream readme, ref GitLinkOnDisk gitLink, ref string readMeText, ref bool hide) { hide = EditorGUILayout.Foldout(hide, hide ? "→ Read Me" : "↓ Read Me", EditorStyles.boldLabel); if (!hide) { GUILayout.Label("Read Me:", EditorStyles.boldLabel); GUILayout.Label("Linked git:" + (gitLink == null?"None":gitLink.GetName()), EditorStyles.boldLabel);; readMeText = EditorGUILayout.TextArea(readMeText, GUILayout.MinHeight(100)); GUILayout.BeginHorizontal(); if (GUILayout.Button("Create Default")) { if (gitLink != null) { readme.Create(ReadMeUtility.CreateBasicDefaultOnFrom(gitLink)); } else { readme.Create("# Read Me \n Hey buddy! \nWhat 's up ?"); } readMeText = readme.Get(); } if (GUILayout.Button("Load")) { readMeText = readme.Get(); } if (GUILayout.Button("Override")) { readme.Set(readMeText); } if (GUILayout.Button("Open")) { readme.Open(); } GUILayout.EndHorizontal(); } }
private void DrawGitIniCreateAndPush() { ResetInfo(); if (!m_lockSelection) { m_relativeSelection = GetFolderSelectedInUnity(); } m_absoluteSelection = Application.dataPath + "/" + m_relativeSelection; // propose to create folder if none are selected if (m_relativeSelection == "") { GitForFacilitationEditor.ProposeToCreateFolder(m_info.m_selector, ref m_info.m_tmpFolderToCreate); GitForFacilitationEditor.DisplayMessageToHelp("Please select or create a empty folder"); return; } DisplayLocker(); DisplayFolderSelectionnedInUnity(); bool hasGitInParent; m_gitLinkedToSelectedAsset = GetGitFolderAbsolutPath(out hasGitInParent); if (!hasGitInParent) { ProposeToCreateLocalGit(); return; } /// IF as local git but no url; /// m_gitfolderName = GetGitFolderNameFromFolderPathInUnity(); QuickGit.GetGitUrl(m_gitLinkedToSelectedAsset, out m_linkedGitUrl); DisplayGitPathAndLink(); DisplayGitProjectName(); UnityPackageUtility.TryToAccessPackageNamespaceIdFromFolder(m_absoluteSelection, out m_packageNamespaceId); DisplayPackageInformation(); if (string.IsNullOrEmpty(m_linkedGitUrl)) { //PushLocalGitToOnlineAccount(ref m_info.m_hideGitUtilitary); } if (!string.IsNullOrEmpty(m_linkedGitUrl)) { GitLinkOnDisk gd = new GitLinkOnDisk(m_gitLinkedToSelectedAsset); GitEditorDrawer.DisplayGitCommands(gd); //UnityPackageEditorDrawer.DrawPackageDownUpButton(m_absoluteSelection, m_gitLinkedToSelectedAsset, true); } if (m_gitLinkedToSelectedAsset == "") { return; } m_absolutPathOfFolderToWorkOn = m_gitLinkedToSelectedAsset; m_createPackageFoldout = EditorGUILayout.Foldout(m_createPackageFoldout, "Structure package"); if (m_createPackageFoldout) { CreatePackageStructure(); } m_dangerousButton = EditorGUILayout.Foldout(m_dangerousButton, "Dangerous Option"); if (m_dangerousButton) { if (GUILayout.Button("Remove Repository")) { FileUtil.DeleteFileOrDirectory(m_gitLinkedToSelectedAsset); } if (GUILayout.Button("Remove .git")) { FileUtil.DeleteFileOrDirectory(m_gitLinkedToSelectedAsset + "/.git"); } } }
void OnGUI() { // DisplayPullPushInProject(); m_pushPullInfo = (PackagePullPushObject)EditorGUILayout.ObjectField(m_pushPullInfo, typeof(PackagePullPushObject)); if (m_pushPullInfo != null) { m_pushPull = m_pushPullInfo.m_data; } else { m_pushPull = null; } if (m_pushPullInfo == null) { GUILayout.BeginHorizontal(); GUILayout.Label("Name:", GUILayout.Width(50)); m_folderToCreate = GUILayout.TextArea(m_folderToCreate); GUILayout.EndHorizontal(); DisplayCopyPastField(); if (GUILayout.Button("Create Default")) { m_pushPullInfo = GetDefaultPullPushObject(m_folderToCreate); m_pushPullInfo.m_data.m_gitUrl = m_copyPastShortCut; m_pushPullInfo.m_data.m_packageNamespaceId = m_nameSpaceToCreate; } } if (!string.IsNullOrEmpty(m_copyPastShortCut)) { //\w*\.git string isGitLink = "\\w*\\.git"; //".*"\s*:\s*".*\.git["\s\n\r\z] string isPackageManagerLink = "\".*\"\\s*:\\s*\".*\\.git[\"\\s\\n\\r\\a,]"; //"be.eloistree.overrideandroidvolume":"https://gitlab.com/eloistree/2019_06_30_overrideandroidvolume.git", if (MathRegex(m_copyPastShortCut, isPackageManagerLink)) { string[] tokens = Regex.Split(m_copyPastShortCut, "\"\\s*:\\s*\""); tokens[0] = tokens[0].Replace("\"", ""); tokens[1] = tokens[1].Replace("\"", ""); CheckOrCreateDefault(); m_pushPullInfo.m_data.m_gitUrl = tokens[1]; m_pushPullInfo.m_data.m_packageNamespaceId = tokens[0]; m_pushPullInfo.m_data.m_relativeFolderPath = GetGitProjectName(m_copyPastShortCut); m_copyPastShortCut = ""; } //https://gitlab.com/eloistree/HeyMyFriend //https://gitlab.com/eloistree/2019_06_30_overrideandroidvolume.git else if (MathRegex(m_copyPastShortCut, isGitLink)) { CheckOrCreateDefault(); m_pushPullInfo.m_data.m_gitUrl = m_copyPastShortCut; UnityPackageUtility.TryToAccessPackageNamespaceIdFromGitCloneUrl(m_copyPastShortCut, out m_pushPullInfo.m_data.m_packageNamespaceId); if (string.IsNullOrEmpty(m_pushPullInfo.m_data.m_relativeFolderPath)) { m_pushPullInfo.m_data.m_relativeFolderPath = GetGitProjectName(m_copyPastShortCut); } m_copyPastShortCut = ""; } } scroll = EditorGUILayout.BeginScrollView(scroll); if (m_pushPull != null) { GUILayout.BeginHorizontal(); string pathToWork = GetPathOfFolder(); if (!Directory.Exists(pathToWork) && GUILayout.Button("Create folder")) { Directory.CreateDirectory(GetPathOfFolder()); RefreshDataBase(); } else if (Directory.Exists(pathToWork) && GUILayout.Button("Remove Folder")) { FileUtil.DeleteFileOrDirectory(GetPathOfFolder()); RefreshDataBase(); } if (!(Directory.Exists(pathToWork) && Directory.GetFiles(pathToWork).Length > 0) && GUILayout.Button("Clone Git")) { Directory.CreateDirectory(GetPathOfFolder()); QuickGit.Clone(m_pushPull.m_gitUrl, GetPathOfFolder()); RefreshDataBase(); } GUILayout.EndHorizontal(); // UnityPackageEditorDrawer.DrawPackageDownUpButton(GetPathOfFolder(), m_pushPull.m_gitUrl, true); GitLinkOnDisk gd = new GitLinkOnDisk(GetPathOfFolder()); GitEditorDrawer.DisplayGitCommands(gd); m_folderFoldout = EditorGUILayout.Foldout(m_folderFoldout, "Folder & Git"); if (m_folderFoldout) { DisplayCopyPastField(); GUILayout.BeginHorizontal(); GUILayout.Label("Folder", GUILayout.Width(40)); m_pushPull.m_relativeFolderPath = GUILayout.TextArea(m_pushPull.m_relativeFolderPath); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Namespace", GUILayout.Width(70)); m_pushPull.m_packageNamespaceId = GUILayout.TextArea(m_pushPull.m_packageNamespaceId); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Git", GUILayout.Width(40)); m_pushPull.m_gitUrl = GUILayout.TextArea(m_pushPull.m_gitUrl); GUILayout.EndHorizontal(); } //m_upDownFoldout = EditorGUILayout.Foldout(m_upDownFoldout, "Pull Push"); //if (m_upDownFoldout) //{ //} GUILayout.Space(6); } EditorGUILayout.EndScrollView(); }
public static void DrawPackageEditor(UnityPathSelectionInfo selection, PackageJsonFileStream packageTarget, PackageBuildInformation package) { string path = packageTarget.GetAbsolutePath(); GitLinkOnDisk gitLinked = packageTarget.GetLinkedGit(); GUILayout.BeginHorizontal(); if (GUILayout.Button("Create package.json")) { LoadSamplesFromDirectoryToPackage(selection, ref package); string json = PackageBuilder.GetPackageAsJson(package); packageTarget.Set(json, true); AssetDatabase.Refresh(); } if (GUILayout.Button("Create Files & Folders")) { PackageBuilder.CreateUnityPackage(packageTarget.GetPackageProjectRoot(), package); AssetDatabase.Refresh(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (string.IsNullOrEmpty(package.m_projectName)) { package.m_projectName = UnityPaths.AlphaNumeric(Application.productName); } package.m_projectName = (GUILayout.TextField("" + package.m_projectName)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); if (string.IsNullOrEmpty(package.m_projectAlphNumId)) { // package.m_projectAlphNumId = UnityPaths.AlphaNumeric(Application.productName, true); package.m_projectAlphNumId = selection.GetSelectName(true); } if (string.IsNullOrEmpty(package.m_company)) { package.m_company = UnityPaths.AlphaNumeric(Application.companyName); } package.m_country = UnityPaths.AlphaNumeric(GUILayout.TextField("" + package.m_country)); GUILayout.Label(".", GUILayout.Width(5)); package.m_company = UnityPaths.AlphaNumeric(GUILayout.TextField("" + package.m_company)); GUILayout.Label(".", GUILayout.Width(5)); package.m_projectAlphNumId = UnityPaths.AlphaNumeric(GUILayout.TextField("" + package.m_projectAlphNumId)); GUILayout.EndHorizontal(); GUILayout.Label("Namespace ID: " + package.GetProjectNamespaceId()); GUILayout.Label("Description"); package.m_description = GUILayout.TextArea(package.m_description, GUILayout.MinHeight(100)); GUILayout.BeginHorizontal(); GUILayout.Label("Tags:", GUILayout.MaxWidth(60)); package.m_keywords = GUILayout.TextField(string.Join(",", package.m_keywords)).Split(','); GUILayout.EndHorizontal(); GUILayout.Label("Author"); GUILayout.BeginHorizontal(); GUILayout.Label("Name: ", GUILayout.MaxWidth(60)); package.m_author.m_name = GUILayout.TextField(package.m_author.m_name); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Mail: ", GUILayout.MaxWidth(60)); package.m_author.m_mail = GUILayout.TextField(package.m_author.m_mail); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Url: ", GUILayout.MaxWidth(60)); package.m_author.m_url = GUILayout.TextField(package.m_author.m_url); GUILayout.EndHorizontal(); GUILayout.Label("Repository Info"); GUILayout.BeginHorizontal(); GUILayout.Label("Git Url: ", GUILayout.MaxWidth(60)); package.m_repositoryLink.m_url = GUILayout.TextField(gitLinked.GetUrl()); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Revision: ", GUILayout.MaxWidth(60)); package.m_repositoryLink.m_revision = GUILayout.TextField(gitLinked.GetLastRevision()); GUILayout.EndHorizontal(); GUILayout.Space(10); GUILayout.Label("Direct dependence"); DrawEditableDependency(ref package.m_otherPackageDependency); GUILayout.Space(10); GUILayout.Label("Relative dependence"); DrawEditableDependency(ref package.m_otherPackageRelation); SampleDirectoryStream sample = SampleUtility.GetSampleFolder(selection); SampleEditor.DrawInfoAboutInterface(sample); DocumentationDirectoryStream documentation = DocumentationUtility.GetDocumentFolder(selection); DocumentationEditor.DrawInfoAboutInterface(documentation); }