1
0

dump_commits_since.ps1 709 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/usr/bin/env pwsh
  2. [cmdletbinding()]
  3. param(
  4. [Parameter(Mandatory=$true)]
  5. [DateTime]$since,
  6. [Nullable[DateTime]]$until,
  7. [Parameter(Mandatory=$true)]
  8. [string]$repo);
  9. $r = @()
  10. $page = 1
  11. $qParams = @{
  12. "since" = $since.ToString("o");
  13. "per_page" = 100
  14. "page" = $page
  15. }
  16. if ($until -ne $null) {
  17. $qParams["until"] = $until.ToString("o")
  18. }
  19. $url = "https://api.github.com/repos/{0}/commits" -f $repo
  20. while ($null -ne $url)
  21. {
  22. $resp = Invoke-WebRequest $url -UseBasicParsing -Body $qParams
  23. if($resp.Content.Length -eq 2) {
  24. break
  25. }
  26. $page += 1
  27. $qParams["page"] = $page
  28. $j = ConvertFrom-Json $resp.Content
  29. $r += $j
  30. }
  31. return $r