diff --git a/repo/README.md b/repo/README.md index 0597de3..0956f00 100644 --- a/repo/README.md +++ b/repo/README.md @@ -83,25 +83,45 @@ Below shortcuts are examples, your milage may vary. #### Windows: -Cygwin is required, and repo must be called explicitly using Cygwin's `bash`. +Cygwin or Windows Subsystem for Linux (WSL) are required, and repo must be called explicitly using Cygwin's or WSL's `bash`. -Make sure the folder containing `repo` is in cygwin's `$PATH` variable. Alternatively replace `-l repo` in the parameters below with the full absolute path, for example `-l c:\repoinstallfolder\repo`. +Make sure the folder containing `repo` is in Windows' `$Path` variable. Alternatively replace `repoWin.ps1` in the parameters below with the full absolute path, for example `C:\tools\repoWin.ps1`. * put - * Program: `\bin\bash` - for example: `C:\cygwin64\bin\bash` - * Parameters: `-l repo put -f $FilePath$` - + * Program: `powershell` + * Parameters: `repoWin.ps1 put $FilePath$` + * Keyboard Shortcut: `Ctrl + Alt + Shift + Q` * get - * Program: `\bin\bash` - * Parameters: `-l repo get -f $FilePath$` - + * Program: `powershell` + * Parameters: `repoWin.ps1 get $FilePath$` + * Keyboard Shortcut: `Ctrl + Alt + Shift + R` * status - * Program: `\bin\bash` - * Parameters: `-l repo st $FilePath$` + * Program: `powershell` + * Parameters: `repoWin.ps1 status $FilePath$` + * Keyboard Shortcut: `Ctrl + Alt + Shift + Y` +* diff + * Program: `powershell` + * Parameters: `repoWin.ps1 diff $FilePath$` + * Keyboard Shortcut: `Ctrl + Alt + Shift + E` + +An alternative way to run `repo` under Cygwin is to make sure the path to Cygwin installation directory is the first on the `$Path` variable list and provide the following external tools settings: +* put + * Program: `bash` (use the absolute path to `bash` here) + * Parameters: `repo put -f $FilePath$` (use the absolute path to `repo` here) + * Keyboard Shortcut: `Ctrl + Alt + Shift + Q` +* get + * Program: `bash` + * Parameters: `repo get -f $FilePath$` + * Keyboard Shortcut: `Ctrl + Alt + Shift + R` +* status + * Program: `bash` + * Parameters: `repo st $FilePath$` + * Keyboard Shortcut: `Ctrl + Alt + Shift + Y` * diff - * Program: `\bin\bash` - * Parameters: `-l repo diff $FilePath$` + * Program: `bash` + * Parameters: `repo diff $FilePath$` + * Keyboard Shortcut: `Ctrl + Alt + Shift + E` ### Integration into Eclipse diff --git a/repo/repo b/repo/repo index f907f2c..ec8d93d 100755 --- a/repo/repo +++ b/repo/repo @@ -532,6 +532,21 @@ while [ $# -gt 0 ]; do shift done +if [[ $(uname -o) == 'Cygwin' ]]; then + # replace every // backslash \\ with / slash / + path=${path//\\//} + + # if $path starts with + if [[ $path =~ ^[A-Z]: ]]; then + # make lower case + drive=${BASH_REMATCH[0],,} + + # strip ':' from + # replace with /cygdrive/ + path=${path/${BASH_REMATCH[0]}/\/cygdrive\/${drive/:/}} + fi +fi + if [ $action == "checkout" ]; then # special checkout init steps # path argument must be a jcr path @@ -653,7 +668,11 @@ packageName="repo${packageName//[^[:alpha:][:digit:].-]/}" packageVersion=$(date +"%s") # prepare zip contents in temp directory -tmpDir=`mktemp -d -t repo.XXX` +if [[ $(uname -o) == 'Cygwin' ]]; then + tmpDir=`mktemp -d -p .. -t repo.XXX` +else + tmpDir=`mktemp -d -t repo.XXX` +fi # store list of excludes in a file for use by commands later excludes=$tmpDir/.excludes diff --git a/repo/repoWin.ps1 b/repo/repoWin.ps1 new file mode 100644 index 0000000..ad41634 --- /dev/null +++ b/repo/repoWin.ps1 @@ -0,0 +1,33 @@ + +# Script for running 'repo' tool in either Windows Subsystem for Linux's or Cygwin's bash + +Param($command, $path) + +if (Test-Path $path) { + $cmdPath = Split-Path -parent $PSCommandPath + + #if Windows Subsystem for Linux (WSL) + if ( $(Get-Command bash).Source -eq "C:\WINDOWS\system32\bash.exe") { + $path = $path -replace '\\','/' + $path = $path -replace '.:',"/mnt/c" + + $cmdPath = $cmdPath -replace '\\','/' + $cmdPath = $cmdPath -replace '.:','/mnt/c' + + bash -l "$cmdPath/repo" $command -f $path + } + # if Cygwin is installed and CYGWIN environment variable pointing to its installation location is defined + elseif (Test-Path env:CYGWIN) { + $cygwin = "$($env:CYGWIN)\bin\bash.exe" + $params = '-l',"$cmdPath\repo","$command",'-f',"$path" + & $cygwin $params + } + else { + Write-Error "'bash' cannot be found. Please install either Windows Subsystem for Linux or Cygwin. If the latter, define CYGWIN environment variable pointing to the installation location." + exit 2 + } +} +else { + Write-Error "File $path not found" + exit 1 +}