예제 #1
0
        public void cloneRepos()
        {
            CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US");

            Thread.CurrentThread.CurrentCulture   = culture;
            Thread.CurrentThread.CurrentUICulture = culture;
            setForkedRepos();
            //setPullRequests();

            List <string> projects = new List <string>();
            List <string> parents  = new List <string>();

            foreach (ForkedRepo repo in forkedRepos)
            {
                if (!projects.Contains(repo.ParentRepo))
                {
                    projects.Add(repo.ParentRepo);
                    parents.Add(repo.ParentRepo);
                }
                projects.Add(repo.ForkName);
            }



            //now clone repos
            string folderName = ConfigurationManager.AppSettings["clonedProjects"];
            string commands   = ConfigurationManager.AppSettings["commands"];


            //string[] doneProjects = new string[] { "LineageOS/android_packages_apps_Contacts", "LightningFastRom/android_packages_apps_Contacts", "sdhz152/android_packages_apps_Contacts", "Michenux/YourAppIdea", "wendersonferreira/YourAppIdea", "friederbluemle/YourAppIdea", "PatilShreyas/MaterialDialog-Android", "tetrapi/MaterialDialog-Android", "xuexiangjys/TemplateAppProject", "myie9/TemplateAppProject", "badoo/Chateau", "wiyarmir/Chateau", "segler-alex/RadioDroid", "kar10s/RadioDroid", "morckx/RadioDroid", "werman/RadioDroid", "robotmedia/AndroidBillingLibrary", "masconsult/AndroidBillingLibrary", "guetux/AndroidBillingLibrary", "hpique/AndroidBillingLibrary", "serso/android-billing", "azhon/AppUpdate", "hongyantao/AppUpdate", "burgessjp/ThemeSkinning", "humanheima/ThemeSkinning", "msdx/ThemeSkinning", "athkalia/Just-Another-Android-App", "MaTriXy/Just-Another-Android-App", "segmentio/analytics-android", "friederbluemle/analytics-android", "super-collider/analytics-android", "TorreyKahuna/analytics-android", "rayleeriver/analytics-android", "amplitude/analytics-android", "google/bundletool" };
            string[] finalProjects = MiningUtility.GetFinalProjects();
            try
            {
                List <ForkedRepo> repos = MiningUtility.GetForkedRepos();
                var repoParents         = from tcp in repos
                                          select tcp.ParentRepo;
                repoParents = repoParents.Distinct();
                int parentCount   = 0;
                int parentsNumber = parents.Count();
                foreach (string parent in repoParents)
                {
                    parentCount++;
                    if (parent == null || parent == "null")
                    {
                        continue;
                    }
                    if (!finalProjects.Contains(parent))
                    {
                        continue;
                    }


                    //get ecosystem projects
                    var ecosystemProjects = from tcp in repos.Where(p => p.ForkName == parent || p.ParentRepo == parent)
                                            select tcp.ForkName;
                    List <string> ecoProjects = ecosystemProjects.ToList();
                    ecoProjects.Add(parent);
                    ecoProjects = ecoProjects.Distinct().ToList();
                    //create parent folder
                    string parentFolder = string.Format($"{parentCount}_{parent.Split('/')[1]}");//if parent is muke/android, and count is 12, the folder will be 12_android
                    string parentPath   = string.Format($"E:\\grouped\\{parentFolder}");
                    //now copy every ecosystem project to parent directory
                    int projectCount   = 0;
                    int projectsNumber = ecoProjects.Count();
                    foreach (string project in ecoProjects)
                    {
                        projectCount++;
                        if (!finalProjects.Contains(project))
                        {
                            continue;
                        }
                        string projectFolder = string.Format($"{parentPath}\\{project.Replace("/", "\\")}");
                        string cloneURL      = string.Format($"https://github.com/{project}.git");

                        Repository.Clone(cloneURL, projectFolder);
                        Console.WriteLine($"Ecosystem: {parent}, number:{parentCount}/{parentsNumber - 1};Pair:{projectCount}/{projectsNumber}");
                    }
                }

                //foreach (string project in projects)
                //{
                //    if (!finalProjects.Contains(project))
                //    {
                //        continue;
                //    }
                //    //string projectSHortName = project.Split('/')[1];
                //    string projectFolder = string.Format($"{folderName}\\{project.Replace("/", "\\")}");
                //    string cloneURL = string.Format($"https://github.com/{project}.git");
                //    //projectURLs.TryGetValue(project, out cloneURL);
                //    //DirectoryInfo directoryInfo = new DirectoryInfo(projectFolder);
                //    //if (directoryInfo.Exists)
                //    //{
                //    //    directoryInfo.Delete(true);
                //    //}

                //        Console.WriteLine($"cloning {project}");
                //        try
                //        {


                //            string repoPath =   Repository.Clone(cloneURL, projectFolder);



                //        }
                //        catch (Exception ex)
                //        {
                //            Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
                //        }


                //}
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
            finally
            {
            }
        }
예제 #2
0
 public void setForkedRepos()
 {
     forkedRepos = MiningUtility.GetForkedRepos();
 }