diff --git a/Scripts/clean-repo.ps1 b/Scripts/clean-repo.ps1 index 251ee68f..3570ccdf 100755 --- a/Scripts/clean-repo.ps1 +++ b/Scripts/clean-repo.ps1 @@ -8,22 +8,21 @@ param($RepoDir = "$PWD") try { - $RepoDir = resolve-path "$RepoDir" if (-not(test-path "$RepoDir" -pathType container)) { throw "Can't access directory: $RepoDir" } - set-location "$RepoDir" - - "โณ Cleaning Git repository ๐Ÿ“‚$RepoDir from untracked files..." + $RepoDirName = (get-item "$RepoDir").Name + + "๐Ÿงน Cleaning Git repository ๐Ÿ“‚$RepoDirName from untracked files..." $Null = (git --version) if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } - & git clean -fdx # force + recurse into dirs + don't use the standard ignore rules + & git -C "$RepoDir" clean -fdx # force + recurse into dirs + don't use the standard ignore rules if ($lastExitCode -ne "0") { throw "'git clean -fdx' failed" } - & git submodule foreach --recursive git clean -fdx + & git -C "$RepoDir" submodule foreach --recursive git clean -fdx if ($lastExitCode -ne "0") { throw "'git clean -fdx' in submodules failed" } - "โœ”๏ธ cleaned Git repository ๐Ÿ“‚$RepoDir" + "โœ”๏ธ cleaned Git repository ๐Ÿ“‚$RepoDirName" exit 0 } catch { write-error "โš ๏ธ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" diff --git a/Scripts/clean-repos.ps1 b/Scripts/clean-repos.ps1 index 72a4314a..13ca4842 100755 --- a/Scripts/clean-repos.ps1 +++ b/Scripts/clean-repos.ps1 @@ -11,23 +11,20 @@ try { $StopWatch = [system.diagnostics.stopwatch]::startNew() if (-not(test-path "$ParentDir" -pathType container)) { throw "Can't access directory: $ParentDir" } - set-location $ParentDir $Null = (git --version) if ($lastExitCode -ne "0") { throw "Can't execute 'git' - make sure Git is installed and available" } [int]$Count = 0 get-childItem "$ParentDir" -attributes Directory | foreach-object { - "Cleaning Git repository ๐Ÿ“‚$($_.Name) from untracked files ..." - set-location $_.FullName + "๐Ÿงน Cleaning Git repository ๐Ÿ“‚$($_.Name) from untracked files ..." - & git clean -fdx # force + recurse into dirs + don't use the standard ignore rules + & git -C "$_.FullName" clean -fdx # force + recurse into dirs + don't use the standard ignore rules if ($lastExitCode -ne "0") { throw "'git clean -fdx' failed" } - & git submodule foreach --recursive git clean -fdx + & git -C "$._FullName" submodule foreach --recursive git clean -fdx if ($lastExitCode -ne "0") { throw "'git clean -fdx' in submodules failed" } - set-location .. $Count++ }