public RepositoriesStarredViewModel(IApplicationService applicationService) : base(applicationService) { Title = "Starred"; LoadCommand = ReactiveCommand.CreateAsyncTask(t => RepositoryCollection.SimpleCollectionLoad( applicationService.Client.AuthenticatedUser.Repositories.GetStarred(), t as bool?)); }
private static async Task <IEnumerable <string> > SearchOnThePage(IEnumerable <string> pageItems, string branch) { var repoCollection = new RepositoryCollection(); foreach (var githubRepo in pageItems) { if (Uri.IsWellFormedUriString(githubRepo, UriKind.Absolute)) { var uri = new Uri(githubRepo); if (uri.Segments.Count() < 3) { continue; } var user = uri.Segments[1].Replace("/", ""); var repo = uri.Segments[2].Replace("/", "").Replace(".git", ""); Console.WriteLine($"user {user}, repo {repo}"); if (string.IsNullOrEmpty(user) || string.IsNullOrEmpty(repo)) { Console.WriteLine($"Bad repo - {user}/{repo}"); continue; } repoCollection.Add(user, repo); } } var data = await SearchInGitHubAsync(repoCollection, branch); return(data); }
public OrganizationRepositoriesViewModel(IApplicationService applicationService) : base(applicationService) { ShowRepositoryOwner = false; LoadCommand = ReactiveCommand.CreateAsyncTask(t => RepositoryCollection.SimpleCollectionLoad(applicationService.Client.Organizations[Name].Repositories.GetAll(), t as bool?)); }
public static void Main() { BuildConfiguration(); var repositories = new RepositoryCollection(); repositories.AddRepository(new WebRepository(Configuration["WebRepository:HostName"])); repositories.AddRepository(new FileRepository(Configuration["FileRepository:DataPath"])); var environmentsJson = repositories.GetEnvironments(); var machinesJson = repositories.GetMachines(); var success = false; try { var environments = JsonConvert.DeserializeObject <IList <Environment> >(environmentsJson); var machines = JsonConvert.DeserializeObject <IList <Machine> >(machinesJson); var xml = RdgBuilder.BuildXml(Configuration["Name"], environments, machines); File.WriteAllText($"{Configuration["Name"]}.rdg", xml, Encoding.UTF8); success = true; } catch (Exception e) { Console.WriteLine(e); } Console.WriteLine("File creation {0}", success ? "successful!" : "failed."); Console.WriteLine("Press any key to exit..."); Console.ReadLine(); }
public async Task <IEnumerable <Article> > GetArticles() { string repo = "oakcool/oakideas.blogs"; string branch = "master"; List <Article> articles = new List <Article>(); var client = new GitHubClient(new ProductHeaderValue("oakideas-simplex")); RepositoryCollection repos = new RepositoryCollection { repo }; var request = new SearchCodeRequest() { Repos = repos, // we may want to restrict the file based on file extension Extensions = new[] { "info" } }; var result = await client.Search.SearchCode(request); HttpClient httpClient = new HttpClient(); foreach (var item in result.Items) { var data = await httpClient.GetStringAsync($"https://raw.githubusercontent.com/{repo}/{branch}/{item.Path}"); var article = JsonConvert.DeserializeObject <Article>(data); article.URL = item.HtmlUrl; articles.Add(article); } return(articles); }
public OrganizationRepositoriesViewModel(IApplicationService applicationService) : base(applicationService) { this.WhenAnyValue(x => x.Name).Subscribe(x => Title = x ?? "Repositories"); ShowRepositoryOwner = false; LoadCommand = ReactiveCommand.CreateAsyncTask(t => RepositoryCollection.SimpleCollectionLoad(applicationService.Client.Organizations[Name].Repositories.GetAll(), t as bool?)); }
public RepositoryGroup(string name) { Verify.Argument.IsNeitherNullNorWhitespace(name, nameof(name)); _name = name; _repositories = new RepositoryCollection(); _groups = new RepositoryGroupCollection(); }
public RepositoryGroup(string name) { Verify.Argument.IsNeitherNullNorWhitespace(name, "name"); _name = name; _repositories = new RepositoryCollection(); _groups = new RepositoryGroupCollection(); }
public void can_find_git_repos() { var repos = RepositoryCollection.FindRepositories(_path, RepositoryType.Git); Assert.True(repos.Any(x => x.Name == "Clean")); Assert.True(repos.Any(x => x.Name == "Dirty")); Assert.True(repos.Any(x => x.Name == "OnLocalBranch")); }
public RepositoryForksViewModel(IApplicationService applicationService) : base(applicationService) { LoadCommand = ReactiveCommand.CreateAsyncTask(t => { var forks = applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].GetForks(); return(RepositoryCollection.SimpleCollectionLoad(forks, t as bool?)); }); }
public void can_add_repos_and_check_status() { var repos = new RepositoryCollection(); var branchedRepo = new GitRepository(dir("OnLocalBranch")); branchedRepo.RefreshLocalStatus(); repos.Add(branchedRepo); Assert.AreEqual(RepoStatus.Clean, repos.WorstStatus()); }
public DislikedRepositoriesViewModel(IApplicationService applicationService) { this.WhenActivated(d => { var repos = applicationService.Account.StumbledRepositories.Query .Where(x => x.Liked == false) .OrderByDescending(x => x.CreatedAt); RepositoryCollection.Reset(repos); }); }
/// <summary> /// Populate the people collection with information from the GEDCOM file. /// </summary> public bool Import(PeopleCollection peopleCollection, SourceCollection sourceCollection, RepositoryCollection repositoryCollection, string gedcomFilePath, bool disableCharacterCheck) { // Clear current content. peopleCollection.Clear(); sourceCollection.Clear(); repositoryCollection.Clear(); // First convert the GEDCOM file to an XML file so it's easier to parse, // the temp XML file is deleted when importing is complete. string xmlFilePath = Path.GetTempFileName(); bool loaded = false; // if user canceled the load try { this.people = peopleCollection; this.sources = sourceCollection; this.repositories = repositoryCollection; // Convert the GEDCOM file to a temp XML file. GedcomConverter.ConvertToXml(gedcomFilePath, xmlFilePath, true, disableCharacterCheck); doc = new XmlDocument(); doc.Load(xmlFilePath); // Get list of people. XmlNodeList list = doc.SelectNodes("/root/INDI"); // Import data from the temp XML file to the people collection. ImportPeople(list); ImportFamilies(); ImportSources(); ImportRepositories(); // The collection requires a primary-person, use the first // person added to the collection as the primary-person. if (peopleCollection.Count > 0) { peopleCollection.Current = peopleCollection[0]; } // Update IDs to match Family.Show standards UpdatePeopleIDs(); UpdateSourceIDs(); UpdateRepositoryIDs(); loaded = true; } finally { //Delete the temp XML file. File.Delete(xmlFilePath); } return(loaded); }
public RepositoryListWindow(Window owner, RepositoryCollection collection) { InitializeComponent(); this.Owner = owner; this.collection = collection; itemList.ItemsSource = collection; itemList_SelectionChanged(this, null); }
/// <summary> /// Get a repository collection from a text string. /// </summary> /// <param name="text">The text to parse.</param> /// <returns>The repository collection (or null).</returns> static protected RepositoryCollection GetRepositories(string text) { var repositories = new RepositoryCollection(); foreach (string part in GetNonEmptyItems(text)) { repositories.Add(part); } return(repositories.Count > 0 ? repositories : null); }
public UserRepositoriesViewModel(IApplicationService applicationService) : base(applicationService) { ShowRepositoryOwner = false; LoadCommand = ReactiveCommand.CreateAsyncTask(t => { var request = string.Equals(applicationService.Account.Username, Username, StringComparison.OrdinalIgnoreCase) ? applicationService.Client.AuthenticatedUser.Repositories.GetAll() : applicationService.Client.Users[Username].Repositories.GetAll(); return(RepositoryCollection.SimpleCollectionLoad(request, t as bool?)); }); }
public async Task <IEnumerable <string> > Query(Dependent dep) { var repoColl = new RepositoryCollection(); repoColl.Add(dep.User, dep.Repository); SearchCodeResult?projs = null; for (int i = 0; i < 10; i++) { try { System.Console.WriteLine($"{dep} searching for project files"); projs = await _githubClientProvider.Client.Search.SearchCode(new SearchCodeRequest() { Extensions = new string[] { "csproj" }, Repos = repoColl }); await PrintAndWaitForReset(); if (projs.IncompleteResults) { System.Console.WriteLine($"{dep} failed to retrieve contained projects. Trying again"); } else if (projs.Items.Count == 0) { System.Console.WriteLine($"{dep} contained projects returned zero. Trying again"); } else { break; } await Task.Delay(5000); } catch (HttpRequestException) { System.Console.WriteLine($"{dep} failed to retrieve patcher listings. Trying again"); } } if (projs?.IncompleteResults ?? true) { throw new ArgumentException($"{dep} failed to retrieve patcher listings"); } var ret = projs.Items .OrderBy(i => i.Name) .Select(i => i.Path) .ToArray(); System.Console.WriteLine($"{dep} retrieved project files:{Environment.NewLine} {string.Join($"{Environment.NewLine} ", ret)}"); return(ret); }
public UnitFactory() { if (factory == null || factory.Count == 0) { RepositoryConfiguration configuration = RepositoryConfiguration.GetConfig(); RepositoryCollection col = configuration.RepositoryCollection; IEnumerable <Repository> Repo = col.Cast <Repository>(); factory = new Dictionary <string, Type>(); foreach (Repository item in Repo) { Type type = Type.GetType(item.DataBase); factory.Add(item.RepositoryName, type); } } }
private static RepositoryCollection createRepositoryCollection(IEnumerable <string> repos) { if (repos == null || !repos.Any()) { return(null); } var coll = new RepositoryCollection(); foreach (var repo in repos) { coll.Add(repo); } return(coll); }
private SearchCodeResult FindNuSpecInRepo(Repository repo, int page) { var repositoryCollection = new RepositoryCollection { repo.Owner.Login + "/" + repo.Name }; // Search API is rate limited by something unknown to OctoKit.net (see https://developer.github.com/v3/rate_limit/) Thread.Sleep(c_MillisecondsTimeout); return(_gitHubClient.Search.SearchCode(new SearchCodeRequest("filename:*.nuspec") { PerPage = ResultsPerPage, Page = page, Repos = repositoryCollection }).Result); }
private void SearchButton_Click(object sender, EventArgs e) { if (UsernameToSearch.Text.ToString() == Prompts.UsernameToSearchPrompt) { Utility.ShowErrorMessage("Please enter a GitHub account to search."); return; } ClearTables(); string usernameCredential = YourGitHubUsername.Text.ToString().Trim(); string passwordCredential = YourGitHubPassword.Text.ToString().Trim(); string usernameToSearchFor = UsernameToSearch.Text.ToString().Trim(); try { GitHubFactory.CreateGitHubClient(usernameCredential, passwordCredential); User user = GitHubFactory.CreateUser(usernameToSearchFor); RepositoryCollection repositoryCollection = GitHubFactory.CreateRepositoryCollection(usernameToSearchFor); // user info foreach (var property in user.GetType().GetProperties()) { string[] data = { property.Name, property.GetValue(user, null).ToString() }; PopulateTable(UserInfoTable, data); } Console.WriteLine(repositoryCollection.ToString()); // repositories info PopulateTable(RepositoryInfoTable, repositoryCollection.GetMostUsedLanguages()); PopulateTable(RepositoryInfoTable, repositoryCollection.GetLargestRepo()); PopulateTable(RepositoryInfoTable, repositoryCollection.GetMostRecentActiveRepo()); } catch (Exception ex) { if (ex is Octokit.RateLimitExceededException) { Utility.ShowErrorMessage("Already hit access rate limit of GitHub API. " + "Please consider login with your GitHub credentials to continue, or come back later."); } else { Utility.ShowErrorMessage(ex.ToString()); } } }
/// <summary> /// Export the data from the People collection to the specified GEDCOM file. /// </summary> public void Export(PeopleCollection peopleCollection, SourceCollection sourceCollection, RepositoryCollection repositoryCollection, string gedcomFilePath, string familyxFilePath, string language) { this.people = peopleCollection; this.sources = sourceCollection; this.repositories = repositoryCollection; using (writer = new StreamWriter(gedcomFilePath)) { WriteLine(0, "HEAD", ""); ExportSummary(gedcomFilePath, familyxFilePath, language); ExportPeople(); ExportFamilies(); ExportSources(); ExportRepositories(); WriteLine(0, "TRLR", ""); } }
public static async Task <StatusReportModel> GenerateReportModelAsync(GitHubClient github, DataStore data, Data.Team team, string milestone, DateTime startDate, DateTime endDate, ILoggerFactory loggerFactory) { var logger = loggerFactory.CreateLogger <StatusReport>(); var model = new StatusReportModel(); model.Name = team.Name; model.ReportDate = endDate.ToString("yyyy-MM-dd"); var cache = new GitHubCache(github, data, loggerFactory.CreateLogger <GitHubCache>()); // Establish the time window. Exclude the endDate. var range = new DateRange(startDate, endDate.AddDays(-1)); logger.LogInformation("Using date range {Range}", range); var releaseMilestone = data.GetMilestone(milestone); model.Milestone = new List <MilestoneDates>() { ComputeMilestoneDates(data, endDate, releaseMilestone, logger) }; var repos = new RepositoryCollection(); foreach (var repo in data.Organization.Repositories) { repos.Add(repo.Owner, repo.Name); } await GeneratePullRequestInfoAsync(github, data, team, model, cache, range, repos, logger); await GenerateIssueInfoAsync(github, team, repos, milestone, model, logger); // Try to render burndown data var burndown = await data.LoadBurndownAsync(milestone); // Check for burndown data for the end date if (!burndown.Weeks.Any(w => w.EndDate.Year == endDate.Year && w.EndDate.Month == endDate.Month && w.EndDate.Day == endDate.Day)) { logger.LogWarning("No burndown data is associated with today's date! The burndown data in this report may be out-of-date."); } model.Burndown = GenerateBurndownModel(team, burndown); return(model); }
public async Task <SearchCodeResult> Search(SearchCodeRequest search) { CheckInitialised(); var repos = new RepositoryCollection(); foreach (var repo in search.Repos) { repos.Add(repo.owner, repo.name); } var result = await _client.Search.SearchCode( new Octokit.SearchCodeRequest(search.Term) { Repos = repos, In = new[] { CodeInQualifier.Path }, PerPage = search.PerPage }); return(new SearchCodeResult(result.TotalCount)); }
private void GetRepositories() { if (RepositoryCollection != null && RepositoryCollection.Any()) { RepositoryCollection.Clear(); } if (_repositoryTypeDictionary != null && _repositoryTypeDictionary.Any()) { _repositoryTypeDictionary.Clear(); } using (var session = DbService.Instance.SessionFactory.OpenSession()) { var repositories = session.QueryOver <Repository>().List <Repository>(); repositories.ForEach(repository => { RepositoryCollection.Add(repository.Name); _repositoryTypeDictionary.Add(repository.Name, repository.Type); }); } }
public async Task <SearchCodeResult> Search(SearchCodeRequest search) { CheckInitialised(); return(await ExceptionHandler(async() => { var repos = new RepositoryCollection(); foreach (var repo in search.Repos) { repos.Add(repo.Owner, repo.Name); } var result = await _client.Search.SearchCode( new Octokit.SearchCodeRequest() { Repos = repos, Extensions = search.Extensions, In = new[] { CodeInQualifier.Path }, PerPage = search.PerPage }); return new SearchCodeResult(result.TotalCount); })); }
public GitHubScanner( ProjectFileParser projectFileParser, string organization, string accessToken, string repos) { _projectFileParser = projectFileParser; var proxy = new WebProxy(); var connection = new Connection( new ProductHeaderValue(AppName), new HttpClientAdapter(() => HttpMessageHandlerFactory.CreateDefault(proxy))); var token = accessToken ?? throw new InvalidOperationException( $"Access token can't be empty. For unauthenticated requests rate limit = 60 calls per hour!"); _client = new GitHubClient(new ProductHeaderValue(AppName)) { Credentials = new Credentials(token), }; if (string.IsNullOrWhiteSpace(organization)) { throw new ArgumentNullException(nameof(organization)); } _organization = organization; if (!string.IsNullOrWhiteSpace(repos)) { _repos = new RepositoryCollection(); var reposArr = repos.Split(',', StringSplitOptions.RemoveEmptyEntries); foreach (var repo in reposArr) { var trimmedRepo = repo.Trim(); _repos.Add(organization, trimmedRepo); } } }
/// <summary> /// Export all the data from the Repository collection to the specified html file. /// </summary> public void ExportRepositories(string fileName, string familyFileName, RepositoryCollection repository) { tw = new StreamWriter(fileName); //write the necessary html code for a html document tw.WriteLine(Header()); tw.WriteLine(CSS()); tw.WriteLine(CSSprinting(4)); tw.WriteLine("</head><body>"); tw.WriteLine("<h2>" + Microsoft.FamilyShowLib.Properties.Resources.FamilyShow + "</h2>"); tw.WriteLine("<i>" + Microsoft.FamilyShowLib.Properties.Resources.SummaryOfRepositoriesForFile + " " + familyFileName + "</i><br/><br/>"); //Write the table headers tw.WriteLine(NormalRepositoryColumns()); foreach (Repository r in repository) { tw.WriteLine("<tr><td><a name=\"" + r.Id + "\"></a>" + r.Id + "</td><td>" + r.RepositoryName + "</td><td>" + r.RepositoryAddress + "</td></tr>"); } tw.WriteLine(Footer()); tw.Close(); }
public static async Task <Issue> FindExistingPullRequestToUpdate( GitHubClient client, User currentUser, Repository upstreamRepo, Repository forkRepo, string forkBranch) { // Search for candidate PRs (same author, still open, etc.) var fromBaseRef = $"{forkRepo.Owner.Login}:{forkBranch}"; var searchInRepos = new RepositoryCollection(); searchInRepos.Add(upstreamRepo.Owner.Login, upstreamRepo.Name); var searchRequest = new SearchIssuesRequest { Repos = searchInRepos, Type = IssueTypeQualifier.PullRequest, Author = currentUser.Login, State = ItemState.Open }; var searchResults = await client.Search.SearchIssues(searchRequest); // Of the candidates, find the highest-numbered one that is requesting a // pull from the same fork and branch. GitHub only allows there to be one // of these at any given time, but we're more likely to find it faster // by searching from newest to oldest. var candidates = searchResults.Items.OrderByDescending(item => item.Number); foreach (var prInfo in candidates) { var pr = await client.PullRequest.Get(upstreamRepo.Id, prInfo.Number); if (pr.Head?.Repository?.Id == forkRepo.Id && pr.Head?.Ref == forkBranch) { return(prInfo); } } return(null); }
public async Task<ActionResult> Stats() { var vm = new StatsViewModel(); var issueSearch = new SearchIssuesRequest { Comments = Range.GreaterThan(25), Created = DateRange.GreaterThan(new DateTime(DateTime.Now.Year, 01, 01)), SortField = IssueSearchSort.Comments, Language = Language.Ruby, Order = SortDirection.Descending }; var mostCommented = await _githubClient.Search.SearchIssues(issueSearch); vm.MostCommentedIssue = mostCommented.Items.OrderByDescending(x=> x.Comments).Take(10).ToList(); var repoSearch = new SearchRepositoriesRequest { Created = DateRange.GreaterThan(new DateTime(DateTime.Now.Year, 01, 01)), Language = Language.CSharp, SortField = RepoSearchSort.Stars, Order = SortDirection.Descending }; var mostStarred = await _githubClient.Search.SearchRepo(repoSearch); vm.MostStarred = mostStarred.Items.Take(10).ToList(); var repo = new RepositoryCollection(); repo.Add("rails", "rails"); issueSearch = new SearchIssuesRequest { Repos = repo, Created = DateRange.GreaterThan(new DateTime(DateTime.Now.Year, 01, 01)), }; var railsIssues = await _githubClient.Search.SearchIssues(issueSearch); var dic = new Dictionary<DayOfWeek, List<Issue>>(); foreach (var issue in railsIssues.Items) { if(dic.ContainsKey(issue.CreatedAt.DayOfWeek)) { dic[issue.CreatedAt.DayOfWeek].Add(issue); } else { dic.Add(issue.CreatedAt.DayOfWeek, new List<Issue> { issue }); } } vm.RailsIssues = dic; return View(vm); }
static async Task Main(string[] args) { var currentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location).Replace("MainApp\\bin\\Debug", ""); var credsFilePath = currentDirectory + "Creds.txt"; string username = string.Empty; string password = string.Empty; Console.WriteLine("Welcome to the Github Repo PR Extractor\n"); if (!File.Exists(credsFilePath)) { Console.Write("Would you like us to save your username or password? \nYou won't have to enter it next time (y/n):- "); var saveCredentials = Console.ReadLine(); Console.Write("Please enter your BD email address:- "); username = Console.ReadLine(); Console.Write("Please enter your password:- "); password = Console.ReadLine(); if (saveCredentials.ToLower() == "y") { CreateCredsFile(username, password, credsFilePath); Console.WriteLine("\n\nALERT!! A Creds.txt file is created with your credentials. Keep them safe"); } } else { Console.WriteLine("Logging you in!!"); var creds = File.ReadAllLines(credsFilePath); username = creds[0]; password = creds[1]; Console.WriteLine($"Welcome {username}\n"); } var prodHeader = new ProductHeaderValue(GitHubIdentity); var credentials = new Credentials(username, password); var enterpriseUrl = "https://github-rd.carefusion.com/vanguard"; var client = new GitHubClient(prodHeader, new Uri(enterpriseUrl)) { Credentials = credentials }; var repoNameFile = "RepositoryNames.txt"; var repoNamePath = currentDirectory + repoNameFile; var allRepoNames = File.ReadAllLines(repoNamePath); try { Console.WriteLine("Please mention the start date (dd/MM/yyyy)"); StartDate = DateTime.Parse(Console.ReadLine()); Console.WriteLine("Please mention the end date (dd/MM/yyyy)"); EndDate = DateTime.Parse(Console.ReadLine()); } catch { Console.WriteLine("You were wrong. Try again!!"); Console.ReadKey(); Environment.Exit(0); } var excelWorkbookName = "PRsList " + StartDate.ToShortDateString() + " to " + EndDate.ToShortDateString(); var excelWorkSheetName = "PRDetails"; var excelWorkbookPath = currentDirectory + excelWorkbookName; var excelExport = new ExcelExport(excelWorkbookPath, excelWorkSheetName); var rc = new RepositoryCollection(); foreach (var repoName in allRepoNames) { rc.Add($"vanguard/{repoName}"); } var searchIssuesRequest = new SearchIssuesRequest { Merged = new DateRange(StartDate, EndDate), Type = IssueTypeQualifier.PullRequest, Repos = rc, SortField = IssueSearchSort.Merged, Page = 1, PerPage = 100 }; var filteredPrs = await client.Search.SearchIssues(searchIssuesRequest); var totalNumberOfPrs = filteredPrs.TotalCount; Console.WriteLine($"Found {totalNumberOfPrs} of PRs within our range\n"); var totalFilteredPRs = (List <Issue>)filteredPrs.Items; // Max page size is 100 while ((totalNumberOfPrs / (searchIssuesRequest.Page * 100)) >= 1) { // 403 = 1 * 100, 2 * 100, 3 * 100, 4 * 100, 5 * 3 searchIssuesRequest.PerPage = ((totalNumberOfPrs - searchIssuesRequest.Page * 100) < 100) ? (totalNumberOfPrs - searchIssuesRequest.Page * 100) : 100; searchIssuesRequest.Page += 1; filteredPrs = await client.Search.SearchIssues(searchIssuesRequest); totalFilteredPRs.AddRange(filteredPrs.Items); } var prsToBeAdded = new List <Issue>(); Console.WriteLine("Checking if any PRs have any review comments..."); foreach (var filteredPr in totalFilteredPRs) { var reviewCommentsCount = (await client.PullRequest.ReviewComment.GetAll("vanguard", filteredPr.GetName(), filteredPr.Number)).Count; if (reviewCommentsCount > 0) { prsToBeAdded.Add(filteredPr); } } if (prsToBeAdded.Any()) { Console.WriteLine($"Found {prsToBeAdded.Count} PRs with CR Comments"); excelExport.GenerateExcel <Issue>(prsToBeAdded); excelExport.SaveAndCloseExcel(); } else { Console.WriteLine("No PR found in our range with CR comments.\nHave a Nice Day!!"); Console.ReadKey(); } }
private static async Task Test(string saveFilepath, string startDateStr, string endDateStr) { try { var tokenAuth = new Credentials(gitHubToken); var client = new GitHubClient(new ProductHeaderValue("GuardRex-Pull-Request-ETL-Application")); client.Credentials = tokenAuth; var startDate = DateTime.Today.AddDays(-6); if (startDateStr.Length != 0) { var tempDate = Convert.ToDateTime(startDateStr); startDate = new DateTime(tempDate.Year, tempDate.Month, tempDate.Day, 0, 0, 0); } var endDate = new DateTime(DateTime.Today.ToLocalTime().Year, DateTime.Today.ToLocalTime().Month, DateTime.Today.ToLocalTime().Day, 23, 59, 59); if (endDateStr.Length != 0) { var tempDate = Convert.ToDateTime(endDateStr); endDate = new DateTime(tempDate.Year, tempDate.Month, tempDate.Day, 23, 59, 59); } saveFilepath = Path.Combine(saveFilepath, $"Data_{startDate.Month}-{startDate.Day}-{startDate.Year}_{endDate.Month}-{endDate.Day}-{endDate.Year}.txt"); RepositoryCollection repos = new RepositoryCollection { "dotnet/docs", "aspnet/Docs" }; var searchIssuesRequest = new SearchIssuesRequest { Repos = repos, Type = IssueTypeQualifier.PullRequest, State = ItemState.Closed, Assignee = gitHubUserLogin, Closed = new DateRange(startDate, endDate) }; var searchResults = await client.Search.SearchIssues(searchIssuesRequest); using (StreamWriter writer = File.CreateText(saveFilepath)) { writer.WriteLine("Pull Requests"); writer.WriteLine("-------------"); if (searchResults.TotalCount > 0) { foreach (var pr in searchResults.Items) { writer.WriteLine($"{pr.Title} - {pr.PullRequest.HtmlUrl}"); } } else { writer.WriteLine("None"); } } Console.WriteLine(); Console.WriteLine($"Start Date: {startDate} UTC End Date: {endDate} UTC PRs written: {searchResults.Items.Count}"); /* * Console.WriteLine(); * var apiInfo = client.GetLastApiInfo(); * var rateLimit = apiInfo?.RateLimit; * var howManyRequestsCanIMakePerHour = rateLimit?.Limit; * var howManyRequestsDoIHaveLeft = rateLimit?.Remaining; * var whenDoesTheLimitReset = rateLimit?.Reset; * Console.WriteLine($"Requests allowed per hour: {howManyRequestsCanIMakePerHour}"); * Console.WriteLine($"Requests Remaining: {howManyRequestsDoIHaveLeft}"); * Console.WriteLine($"Time limit resets in: {whenDoesTheLimitReset}"); */ } catch (Exception ex) { Console.WriteLine(ex.ToString()); } Console.WriteLine(); Console.WriteLine("Press any key to close ..."); Console.ReadLine(); }
public SearchCodeRequest(string term) : base(term) { Repos = new RepositoryCollection(); }
public HistoryViewModel(IApplicationService applicationService) { ApplicationService = applicationService; RepositoryCollection.Reset(ApplicationService.Account.StumbledRepositories.Query.OrderByDescending(x => x.CreatedAt)); }
public RepositoryManagerService(int maxRecentRepositories = 10) { _maxRecentREpositories = maxRecentRepositories; _recent = new RepositoryCollection(); _local = new RepositoryGroup("ROOT"); }
/// <summary> /// Initializes a new instance of the <see cref="SearchCodeRequest"/> class. /// </summary> public SearchCodeRequest() : base() { Repos = new RepositoryCollection(); }