コード例 #1
0
        //
        //=============================================================================
        //
        #region Populate Data

        protected override void StartDatabaseUpdate()
        {
            if (m_ProjectPrefs.BranchesDatabaseScanParameters.Count == 0)
            {
                Debug.LogError("User must define repository entry points to scan for branches with Unity projects!");
                return;
            }

            m_LastError = ListOperationResult.Success;

            // Duplicate this to be thread-safe.
            m_PendingScanParameters = new List <BranchScanParameters>(m_ProjectPrefs.BranchesDatabaseScanParameters);

            base.StartDatabaseUpdate();
        }
コード例 #2
0
        private void GatherProjectsIn(BranchScanParameters scanParams, List <BranchProject> results)
        {
            var listEntries       = new List <string>();
            var normalizedEntries = new List <string>();

            HashSet <string> branchSignatureEntries = new HashSet <string>(scanParams.BranchSignatureRootEntries);

            var lastBranch = new BranchProject()
            {
                BranchName         = "Unknown",
                BranchURL          = scanParams.EntryPointURL,
                BranchRelativePath = string.Empty,
                UnityProjectURL    = string.Empty,
            };

            Queue <string> urls = new Queue <string>();

            urls.Enqueue(scanParams.EntryPointURL);

            while (urls.Count > 0)
            {
                var url = urls.Dequeue();

                LastProcessedEntry = url.Length == scanParams.EntryPointURL.Length
                                        ? scanParams.EntryPointURL
                                        : url.Remove(0, scanParams.EntryPointURL.Length + 1);

                listEntries.Clear();
                var opResult = WiseSVNIntegration.ListURL(url, false, listEntries);

                if (opResult != ListOperationResult.Success)
                {
                    if (opResult == ListOperationResult.NotFound)
                    {
                        Debug.LogError($"{GetType().Name} failed to find url: \"{url}\".");
                    }

                    m_LastError = opResult;
                    results.Clear();
                    return;
                }

                // Folders have '/' at the end but the user shouldn't define them this way.
                normalizedEntries.Clear();
                normalizedEntries.Capacity = Mathf.Max(listEntries.Count, normalizedEntries.Capacity);
                normalizedEntries.AddRange(listEntries.Select(e => e.TrimEnd('/')));

                // Is this a branch?
                if (branchSignatureEntries.IsSubsetOf(normalizedEntries))
                {
                    lastBranch.BranchName               = Path.GetFileName(url);
                    lastBranch.BranchURL                = url;
                    lastBranch.BranchRelativePath       = url.Remove(0, scanParams.EntryPointURL.Length + 1);
                    lastBranch.UnityProjectRelativePath = null;
                    lastBranch.UnityProjectURL          = null;
                }

                // This is a Unity project folder.
                if (m_UnityProjectEntries.IsSubsetOf(normalizedEntries))
                {
                    if (!string.IsNullOrEmpty(lastBranch.UnityProjectURL))
                    {
                        // TODO: if BranchURL == UnityURL => Shouldn't be a problem.
                        //		 if BranchURL != UnityRL => take the Unity folder name from the Working Copy (or find its original name in the repository branch). Accept only that name.
                        Debug.LogError($"Multiple Unity projects found in the branch \"{lastBranch.BranchURL}\". This is still not supported.\n{lastBranch.UnityProjectURL}\n{url}");
                    }

                    lastBranch.UnityProjectURL          = url;
                    lastBranch.UnityProjectRelativePath = url.Remove(0, scanParams.EntryPointURL.Length + 1);
                    results.Add(lastBranch);

                    // No need to dig in the Unity project folder.
                    continue;
                }

                for (int i = 0; i < normalizedEntries.Count; ++i)
                {
                    // Only interested in folders.
                    if (listEntries[i].LastOrDefault() != '/')
                    {
                        continue;
                    }

                    var folderName = normalizedEntries[i];

                    if (scanParams.ExcludesFolderNames.Contains(folderName))
                    {
                        continue;
                    }

                    urls.Enqueue(url + "/" + folderName);
                }
            }
        }