public static RepositoryInformation GetRepositoryInformationForPath(string path, string gitPath = null) { var repositoryInformation = new RepositoryInformation(path, gitPath); if (repositoryInformation.IsGitRepository) { return(repositoryInformation); } return(null); }
private void GitCloneCMD(string download) { int percent_per_user = Convert.ToInt32(100 / usernames.Count()); for (int i = 0; i < usernames.Count(); i++) { string username = usernames[i]; Console.WriteLine(username); System.Diagnostics.Process process = new System.Diagnostics.Process(); System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); if (!Directory.Exists(download + @"\" + username)) { DirectoryInfo di = Directory.CreateDirectory(download + @"\" + username); } else if (Directory.Exists(download + @"\" + username + @"\" + repositoryName)) { DirectoryInfo di1 = new DirectoryInfo(download + @"\" + username + @"\" + repositoryName); setAttributesNormal(di1); Directory.Delete(download + @"\" + username + @"\" + repositoryName, true); } progressValue = 100; startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; startInfo.WorkingDirectory = download + @"\" + username; startInfo.FileName = "cmd.exe"; startInfo.Arguments = "/C git clone https://github.com/" + username + "/" + repositoryName; process.StartInfo = startInfo; process.Start(); process.WaitForExit(); RepositoryInformation repoInfo = RepositoryInformation.GetRepositoryInformationForPath(download + @"\" + username + @"\" + repositoryName); string tot_log = ""; for (int j = 0; j < repoInfo.Log.Count(); j++) { string commit = repoInfo.Log.ElementAt(j); tot_log += commit + System.Environment.NewLine + System.Environment.NewLine; } User user = new User(username, repoInfo.Log.Count(), repoInfo.Log, repoInfo.HasUncommittedChanges, repoInfo.HasUnpushedCommits, tot_log); for (int j = 0; j < repoInfo.Log.Count(); j++) { string commit = repoInfo.Log.ElementAt(j); user.addCommitDateTime(GetCommitDateTime(commit)); user.addCommitMessage(GetCommitMessage(commit)); } users.Add(user); dataGridView1.Rows.Add(new String[] { user.username, Convert.ToString(user.commitCount), Convert.ToString(user.hasUncommitedChanges), Convert.ToString(user.hasUnpushedCommits), user.commit_date_times[0], user.commit_messages[0] }); } SaveExcelSheet(download); }