Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 32 additions & 12 deletions repo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: `<path-to-cygwin>\bin\bash` - for example: `C:\cygwin64\bin\bash`
* Parameters: `-l repo put -f $FilePath$`

* Program: `powershell`
Comment thread
lheinman marked this conversation as resolved.
* Parameters: `repoWin.ps1 put $FilePath$`
* Keyboard Shortcut: `Ctrl + Alt + Shift + Q`
* get
* Program: `<path-to-cygwin>\bin\bash`
* Parameters: `-l repo get -f $FilePath$`

* Program: `powershell`
* Parameters: `repoWin.ps1 get $FilePath$`
* Keyboard Shortcut: `Ctrl + Alt + Shift + R`
* status
* Program: `<path-to-cygwin>\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: `<path-to-cygwin>\bin\bash`
* Parameters: `-l repo diff $FilePath$`
* Program: `bash`
* Parameters: `repo diff $FilePath$`
* Keyboard Shortcut: `Ctrl + Alt + Shift + E`

### Integration into Eclipse

Expand Down
21 changes: 20 additions & 1 deletion repo/repo
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Drive:>
if [[ $path =~ ^[A-Z]: ]]; then
# make <Drive:> lower case
drive=${BASH_REMATCH[0],,}

# strip ':' from <drive:>
# replace <Drive:> with /cygdrive/<drive>
path=${path/${BASH_REMATCH[0]}/\/cygdrive\/${drive/:/}}
fi
fi

if [ $action == "checkout" ]; then
# special checkout init steps
# path argument must be a jcr path
Expand Down Expand Up @@ -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`
Comment thread
lheinman marked this conversation as resolved.
else
tmpDir=`mktemp -d -t repo.XXX`
fi

# store list of excludes in a file for use by commands later
excludes=$tmpDir/.excludes
Expand Down
33 changes: 33 additions & 0 deletions repo/repoWin.ps1
Original file line number Diff line number Diff line change
@@ -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'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why this logic can't be in repo too?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting this code in repo results in stripping all backslashes. For path:
repo: does not exist: C:DevgitDigitalPlatformuisrcmaincontentjcr_rootappschipotlecomponentsstructurepagev1pagepartialsgascript.html
for cmdPath:
/bin/bash: C:githubtoolsrepo/repo: No such file or directory


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
}