Пример #1
0
    private void ProposeToCreateLocalGit()
    {
        if (GUILayout.Button("Create Local"))
        {
            QuickGit.CreateLocal(m_absoluteSelection);
        }
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Clone"))
        {
            QuickGit.Clone(m_gitLinkToClone, m_absoluteSelection);
        }
        m_gitLinkToClone = GUILayout.TextField(
            m_gitLinkToClone);


        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("GitLab"))
        {
            Application.OpenURL("https://gitlab.com/dashboard/projects");
        }
        if (GUILayout.Button("GitHub"))
        {
            Application.OpenURL("https://github.com/");
        }

        GUILayout.EndHorizontal();
    }
    public static void ProposeCloneProject(UnityPathSelectionInfo selector, ref string cloneProposed)
    {
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Clone"))
        {
            QuickGit.Clone(cloneProposed, selector.GetAbsolutePath(true));
        }
        cloneProposed = GUILayout.TextField(
            cloneProposed);


        GUILayout.EndHorizontal();
    }
Пример #3
0
    private void ProposeToCreateLocalGit()
    {
        if (GUILayout.Button("Create Local"))
        {
            QuickGit.CreateLocal(m_absoluteSelection);
        }
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Clone"))
        {
            QuickGit.Clone(m_gitLinkToClone, m_absoluteSelection);
        }
        m_gitLinkToClone = GUILayout.TextField(
            m_gitLinkToClone);


        GUILayout.EndHorizontal();
    }
Пример #4
0
    public static void Down(string directory, string gitUrl, bool affectManifest = true)
    {
        string directoryPath = directory;

        Directory.CreateDirectory(directoryPath);
        if (!Directory.Exists(directoryPath + "/.git"))
        {
            QuickGit.Clone(gitUrl, directoryPath);
        }
        else
        {
            QuickGit.Pull(directoryPath);
        }

        if (affectManifest && !string.IsNullOrEmpty(gitUrl))
        {
            UnityPackageUtility.RemovePackage(gitUrl);
        }
    }
Пример #5
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        PackagePullPushMono myScript = (PackagePullPushMono)target;
        string gitPath      = myScript.GetProjectPathInUnity() + "/.git";
        string projectPath  = myScript.GetProjectPathInUnity();
        string gitFolderUrl = "";

        QuickGit.GetGitUrl(projectPath, out gitFolderUrl);
        bool   isGitFolderDefine      = !string.IsNullOrEmpty(gitFolderUrl);
        string projectPathTmp         = projectPath + "tmp";
        string requiredPathFile       = projectPath + "/requiredpackages.json";
        ListOfClassicPackages package = ListOfClassicPackages.FromJsonPath(requiredPathFile);

        if (string.IsNullOrEmpty(myScript.GetGitLink()))
        {
            return;
        }
        GUILayout.Label("Commands", EditorStyles.boldLabel);
        bool isLinkValide       = myScript.IsGitLinkValide();
        bool isDirectoryCreated = myScript.IsDirectoryCreated();

        GUILayout.BeginHorizontal();
        var disableStyle = new GUIStyle(GUI.skin.button);

        disableStyle.normal.textColor = new Color(0.6627451f, 0.6627451f, 0.6627451f);
        var enableStyle = new GUIStyle(GUI.skin.button);

        enableStyle.normal.textColor = new Color(0f, 0.4f, 0f);
        if (GUILayout.Button("Down", isDirectoryCreated?disableStyle: enableStyle))
        {
            if (!isDirectoryCreated)
            {
                UnityPackageUtility.Down(projectPath, myScript.GetGitLink(), myScript.m_affectPackageManager);
            }
        }
        if (GUILayout.Button("Up", (isDirectoryCreated && isGitFolderDefine) ? enableStyle : disableStyle))
        {
            if (isGitFolderDefine)
            {
                UnityPackageUtility.Up(projectPath, myScript.m_namespaceId, myScript.GetGitLink(), myScript.m_affectPackageManager);
            }
        }
        GUILayout.EndHorizontal();
        GUILayout.Space(6);


        GUILayout.BeginHorizontal();
        //if (isLinkValide && !isDirectoryCreated && GUILayout.Button("Clone"))
        //{
        //    myScript.PullProject();
        //}
        if (isGitFolderDefine && GUILayout.Button("Pull"))
        {
            myScript.UpdateProject();
        }
        if (isGitFolderDefine && GUILayout.Button("Pull & Push"))
        {
            myScript.PullAndPush();
        }
        if (isDirectoryCreated && GUILayout.Button("Remove Project"))
        {
            RemoveFolderWithUnityTool(myScript);
        }
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        if (isDirectoryCreated && GUILayout.Button("Open Folder"))
        {
            myScript.OpenDirectory();
        }
        if (isDirectoryCreated && isGitFolderDefine && GUILayout.Button("Open Cmd"))
        {
            myScript.OpenStatusInCommentLine();
        }
        if (isLinkValide && GUILayout.Button("Open Git Server"))
        {
            Application.OpenURL(myScript.GetGitLink());
        }
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();

        if (isDirectoryCreated && isGitFolderDefine && GUILayout.Button("Remove Git Info"))
        {
            FileUtil.DeleteFileOrDirectory(gitPath);
        }
        if (isDirectoryCreated && !isGitFolderDefine && GUILayout.Button("Add Git Info"))
        {
            Directory.CreateDirectory(projectPathTmp);
            FileUtil.ReplaceDirectory(projectPath, projectPathTmp);
            FileUtil.DeleteFileOrDirectory(projectPath);
            Directory.CreateDirectory(projectPath);

            //QuickGit.CreateLocal(projectPath);
            // QuickGit.PushLocalToGitLab(projectPath, myScript.m_gitUserName, GetProjectDatedNameId(myScript), out gitUrl);
            QuickGit.Clone(myScript.GetGitLink(), projectPath);
            FileUtil.ReplaceDirectory(gitPath, projectPathTmp + "/.git");
            FileUtil.DeleteFileOrDirectory(projectPath);
            FileUtil.ReplaceDirectory(projectPathTmp, projectPath);
            FileUtil.DeleteFileOrDirectory(projectPathTmp);

            //FileUtil.ReplaceDirectory(projectPathTmp, projectPath);
            // FileUtil.DeleteFileOrDirectory(projectPathTmp);
        }

        GUILayout.EndHorizontal();


        if (package.m_packageLinks.Length > 0)
        {
            GUILayout.Label("Required Unitypackage:", EditorStyles.boldLabel);
        }
        GUILayout.BeginHorizontal();
        for (int i = 0; i < package.m_packageLinks.Length; i++)
        {
            ClassicUnityPackageLink link = package.m_packageLinks[i];
            string path = package.m_packageLinks[i].m_pathOrLink;

            if (link.IsUnityPackage())
            {
                if (link.IsWebPath() && GUILayout.Button("Web: " + link.m_name))
                {
                    string pathUnityPackage = Application.dataPath + "/../Temp/lastpackagedownloaded.unitypackage";
                    using (var client = new WebClient())
                    {
                        File.WriteAllBytes(pathUnityPackage, client.DownloadData(path));
                    }
                    Application.OpenURL(pathUnityPackage);
                    // FileUtil.DeleteFileOrDirectory(pathUnityPackage);
                }
                else if (link.IsWindowPath() && GUILayout.Button("Local: " + link.m_name))
                {
                    Application.OpenURL(path);
                }
            }

            if (link.IsAssetStoreLink() && GUILayout.Button("Store: " + link.m_name))
            {
                Application.OpenURL(path);
            }
        }
        GUILayout.EndHorizontal();
    }
Пример #6
0
    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();
    }
Пример #7
0
 public void PullProject()
 {
     Directory.CreateDirectory(GetProjectPathInUnity());
     QuickGit.Clone(m_gitLink, GetProjectPathInUnity());
 }