Last active
          June 11, 2022 14:51 
        
      - 
      
 - 
        
Save kbilsted/9b0e74a8e77d67a2edef39c5d38c5e12 to your computer and use it in GitHub Desktop.  
Revisions
- 
        
kbilsted revised this gist
Jun 11, 2022 . 1 changed file with 0 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,9 +4,6 @@ $git="C:\Program Files\Git\bin\git.exe" $gitHubApiKey = convertto-securestring "ghp_sdafsdfsdaf..." -asplaintext -force function PullOrCloneAll($path="c:\src") { cd $path  - 
        
kbilsted revised this gist
Jun 11, 2022 . No changes.There are no files selected for viewing
 - 
        
kbilsted revised this gist
Jun 11, 2022 . 1 changed file with 12 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,9 @@ # remember to change the $gitHubApiKey # remember to change the $uri username $git="C:\Program Files\Git\bin\git.exe" $gitHubApiKey = convertto-securestring "ghp_sdafsdfsdaf..." -asplaintext -force [Net.ServicePointManager]::SecurityProtocol = "Tls12, Tls11, Tls, Ssl3" @@ -27,7 +31,7 @@ function PullOrCloneAll($path="c:\src") } function FetchRepoList() { $uri = "https://api.github.com:443/users/kbilsted/repos?page=&per_page=100" $all = @() $page = 0 @@ -40,7 +44,7 @@ function FetchRepoList() $page += 1 $urin = $uri.replace("?page=","?page="+$page) $repositories = (Invoke-RestMethod -Uri $urin -Token $gitHubApiKey) Foreach($repo IN $repositories) { @@ -96,4 +100,8 @@ function Clone($repo) { Write-Host("Clonning..."); & $git clone -v --recurse-submodules --progress $repo.Clone_Url $repo.Name # alternatively replace "Clone_Url" with "ssh_url" } (Get-Host).Version pullorcloneall  - 
        
kbilsted revised this gist
Aug 15, 2021 . No changes.There are no files selected for viewing
 - 
        
kbilsted created this gist
Aug 15, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,99 @@ $git="C:\Program Files\Git\bin\git.exe" $gitHubApiKey = "asdjklasdjadsjkasdjklasdjklasdjkl" [Net.ServicePointManager]::SecurityProtocol = "Tls12, Tls11, Tls, Ssl3" function PullOrCloneAll($path="c:\src") { cd $path $repositories = FetchRepoList $i = 0 Foreach($repo IN $repositories) { $i += 1 Write-Host("{0,3} {1,-40} {2,-40}" -f ` $i, $repo.Name, $repo.Clone_Url) if(test-path $repo.Name) { Pull($repo); } else { Clone($repo); } } } function FetchRepoList() { $uri = "https://api.github.com:443/users/XXXXXXXXXX/repos?page=&per_page=100&access_token="+$gitHubApiKey $all = @() $page = 0 $any = $TRUE while($any) { $any = $FALSE $page += 1 $urin = $uri.replace("?page=","?page="+$page) $repositories = (Invoke-RestMethod -Uri $urin) Foreach($repo IN $repositories) { $all += $repo $any = $TRUE } } Write-Host("Found " + $All.Count + " repositories") return $all | Sort-Object -property Name } function MayPullFromRepo() { $status = & $git status --porcelain if($status.Length -gt 0) { Write-Host -ForegroundColor red "!! LOCAL CHANGES - giving up" Write-Host("'"+$status+"'" + $status.Length) return $FALSE } $branch = & $git rev-parse --abbrev-ref HEAD if($branch -ne "master") { Write-Host -ForegroundColor red "!! NOT ON MASTER - giving up" return $FALSE } return $TRUE } function Pull($repo) { cd $repo.Name if(MayPullFromRepo) { $pullresult = & $git pull --ff-only --no-stat if($pullresult -ne "Already up-to-date.") { Write-Host -ForegroundColor green "" + $pullresult } } cd $path } function Clone($repo) { Write-Host("Clonning..."); & $git clone -v --recurse-submodules --progress $repo.Clone_Url $repo.Name # alternatively replace "Clone_Url" with "ssh_url" }