public void appendProjectPathsToGHTorrentCSV()
        {
            string ghMainProjectsFile = string.Format($"{clonedProjectsFolder}\\ghprojectsMain.csv");

            string[] lines = File.ReadAllLines(ghprojectsFile);
            lines = lines.Distinct().ToArray();
            string header = string.Format($"{lines[0]};projectPath;parentPath;ecosystem;projectName");

            MiningUtility.createFileHeader(ghMainProjectsFile, header);
            StreamWriter writer = File.AppendText(ghMainProjectsFile);

            for (int i = 0; i < lines.Length; i++)
            {
                string line  = lines[i];
                int    count = i;
                try
                {
                    GHProject p = getrojectFolder(line);
                    if (p != null)
                    {
                        writer.WriteLine($"{line};{p.ProjectFolder};{p.ParentPath};{p.ProjectName};{p.ProjectName}");
                    }
                    //Task cloneTask = Task.Factory.StartNew(() => doClone(bag, line, writer, count, legnth));
                    //tasks.Add(cloneTask);

                    Console.WriteLine($"Ecosystem number:{i}/{lines.Length}");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
                }
            }
            writer.Close();
        }
        private GHProject getrojectFolder(string line)
        {
            GHProject project      = new GHProject(line.Split(';'));
            string    projectName  = project.Url.Replace("https://api.github.com/repos/", "").Trim();
            string    parentFolder = string.Format($"{project.Id}_{projectName.Split('/')[1]}");//if parent is muke/android, and count is 12, the folder will be 12_android

            string parentPath    = string.Format($"E:\\grouped\\{parentFolder}");
            string projectFolder = string.Format($"{parentPath}\\{projectName.Replace("/", "\\")}");

            project.ProjectFolder = projectFolder;
            project.ProjectName   = projectName;
            project.ParentPath    = parentPath;

            return(Directory.Exists(projectFolder)?project:null);
        }
 private static void updateRepoCommits(DataController dc, GHProject project)
 {
     try
     {
         Repository repo            = new Repository(project.ProjectFolder);
         var        repoCommits     = repo.Commits;
         int        commitCount     = repoCommits.Count();
         DateTime   lastCommitDate  = repoCommits.ElementAt(0).Committer.When.DateTime;
         DateTime   firstCommitDate = repoCommits.ElementAt(commitCount - 1).Committer.When.DateTime;
         dc.UpdateTotalCOmmits(project.ProjectName, commitCount, firstCommitDate, lastCommitDate);
         Console.WriteLine(project.ProjectFolder);
     }catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
        private static void doClone(ConcurrentBag <string> bag, string line, StreamWriter writer, int i, int linesLength)
        {
            try
            {
                GHProject project      = new GHProject(line.Split(';'));
                string    projectName  = project.Url.Replace("https://api.github.com/repos/", "").Trim();
                string    parentFolder = string.Format($"{project.Id}_{projectName.Split('/')[1]}");//if parent is muke/android, and count is 12, the folder will be 12_android

                string parentPath    = string.Format($"E:\\grouped\\{parentFolder}");
                string projectFolder = string.Format($"{parentPath}\\{projectName.Replace("/", "\\")}");
                string cloneURL      = string.Format($"https://github.com/{projectName}.git");


                Repository.Clone(cloneURL, projectFolder);
                string lineBag = string.Format($"{line};{projectFolder}");
                bag.Add(lineBag);

                Console.WriteLine($"Ecosystem: {projectName}, number:{i}/{linesLength}");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
            }
        }