From 852680f61825679fe6653d8c9d026e5100f70926 Mon Sep 17 00:00:00 2001 From: Doug Bunting <6431421+dougbu@users.noreply.github.com> Date: Wed, 12 Jun 2019 20:53:17 -0700 Subject: [PATCH] Add clean.cmd, clean.ps1 and clean.sh (#11154) - #10463 --- clean.cmd | 3 +++ clean.ps1 | 41 +++++++++++++++++++++++++++++++++++++++++ clean.sh | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 clean.cmd create mode 100644 clean.ps1 create mode 100755 clean.sh diff --git a/clean.cmd b/clean.cmd new file mode 100644 index 0000000000..9442e58497 --- /dev/null +++ b/clean.cmd @@ -0,0 +1,3 @@ +@ECHO OFF +SETLOCAL +PowerShell -NoProfile -NoLogo -ExecutionPolicy ByPass -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = ''; try { & '%~dp0clean.ps1' %*; exit $LASTEXITCODE } catch { write-host $_; exit 1 }" diff --git a/clean.ps1 b/clean.ps1 new file mode 100644 index 0000000000..98dd53af40 --- /dev/null +++ b/clean.ps1 @@ -0,0 +1,41 @@ +#requires -version 5 + +<# +.SYNOPSIS +Clean this repository. + +.DESCRIPTION +This script cleans this repository interactively, leaving downloaded infrastructure untouched. +Clean operation is interactive to avoid losing new but unstaged files. Press 'c' then [Enter] +to perform the proposed deletions. + +.EXAMPLE +Perform default clean operation. + + clean.ps1 + +.EXAMPLE +Clean everything but downloaded infrastructure and VS / VS Code folders. + + clean.ps1 -e .vs/ -e .vscode/ +#> + +[CmdletBinding(PositionalBinding = $false)] +param( + # Other lifecycle targets + [switch]$Help, # Show help + + # Capture the rest + [Parameter(ValueFromRemainingArguments = $true)] + [string[]]$GitArguments +) + +Set-StrictMode -Version 2 +$ErrorActionPreference = 'Stop' + +if ($Help) { + Get-Help $PSCommandPath + exit 0 +} + +git clean -dix -e .dotnet/ -e .tools/ -e src/SignalR/clients/ts/FunctionalTests/node_modules/ @GitArguments diff --git a/clean.sh b/clean.sh new file mode 100755 index 0000000000..e52a56020e --- /dev/null +++ b/clean.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# +# Functions +# +__usage() { + echo "Usage: $(basename "${BASH_SOURCE[0]}") + +Arguments: + ... Arguments passed to the 'git' command. Any number of arguments allowed. + +Description: + This script cleans the repository interactively, leaving downloaded infrastructure untouched. + Clean operation is interactive to avoid losing new but unstaged files. Press 'c' then [Enter] + to perform the proposed deletions. +" +} + +git_args=() + +while [[ $# -gt 0 ]]; do + case $1 in + -\?|-h|--help) + __usage + exit 0 + ;; + *) + git_args[${#git_args[*]}]="$1" + ;; + esac + shift +done + +# This incantation avoids unbound variable issues if git_args is empty +# https://stackoverflow.com/questions/7577052/bash-empty-array-expansion-with-set-u +git clean -dix -e .dotnet/ -e .tools/ ${git_args[@]+"${git_args[@]}"}