Skip to content

Commit

Permalink
new script
Browse files Browse the repository at this point in the history
  • Loading branch information
belav committed Oct 1, 2023
1 parent 8c6a3b1 commit 7291f2b
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 65 deletions.
65 changes: 0 additions & 65 deletions Scripts/UpdateCSharpierRepos.ps1

This file was deleted.

93 changes: 93 additions & 0 deletions Shell/UpdateCSharpierRepos.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
function CSH-UpdateCSharpierRepos()
{

$repositories = @()
$repositories += "https://github.com/dotnet/aspnetcore.git"
$repositories += "https://github.com/aspnet/AspNetWebStack.git"
$repositories += "https://github.com/AutoMapper/AutoMapper.git"
$repositories += "https://github.com/castleproject/Core.git"
$repositories += "https://github.com/dotnet/command-line-api.git"
$repositories += "https://github.com/dotnet/format.git"
$repositories += "https://github.com/dotnet/efcore.git"
$repositories += "https://github.com/moq/moq4.git"
$repositories += "https://github.com/JamesNK/Newtonsoft.Json.git"
$repositories += "https://github.com/dotnet/roslyn.git"
$repositories += "https://github.com/dotnet/runtime.git"
$repositories += "https://github.com/mono/mono.git"
$repositories += "https://github.com/increase-POS/Res-Server.git"

$tempLocation = "c:\temp\UpdateRepos"

if (-not(Test-Path $tempLocation))
{
New-Item $tempLocation -Force -ItemType Directory
}

Set-Location $tempLocation

$ErrorActionPreference = "Continue"

foreach ($repository in $repositories)
{
$repoFolder = $tempLocation + "/" + (Split-Path $repositories -Leaf).Replace(".git", "")
if (Test-Path $repoFolder)
{
Set-Location $repoFolder
& git pull origin
Set-Location $tempLocation
}
else
{
& git clone $repository
}
}

$destination = "C:\projects\csharpier-repos\"
Set-Location $destination
& git checkout main

Get-ChildItem $tempLocation | Copy-Item -Destination $destination -Filter *.cs -Recurse -Force

$items = Get-ChildItem -Recurse C:\projects\csharpier-repos -File
$count = 0
foreach ($item in $items)
{
if ($item.Name -eq ".git")
{
Remove-Item -Force -Recurse $item.FullName
}
elseif ($item.Extension -ne ".cs")
{
if ($item.Name -ne ".csharpierignore")
{
Remove-Item $item.FullName
}
}
else
{
# we don't really need all of these files, let's just cut out every other one
if ($count % 2 -eq 0)
{
Remove-Item $item.FullName
}
$count++
}
}

$items = Get-ChildItem C:\projects\csharpier-repos -Directory -Recurse
foreach ($item in $items)
{
if ($item.Name -eq ".git")
{
Remove-Item -Force -Recurse $item.FullName
}
}

Set-Location $destination

& git add .
& git commit -m "Updating repos"
& git push origin
}

Export-ModuleMember -Function CSH-*

0 comments on commit 7291f2b

Please sign in to comment.