Skip to content

Commit

Permalink
Merge pull request awslabs#88 from costleya/master
Browse files Browse the repository at this point in the history
Simply Installation on Windows. Update README.
  • Loading branch information
mtdowling committed Aug 10, 2018
2 parents b296988 + 635895a commit e324284
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 4 deletions.
10 changes: 10 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# Force the bash scripts to be checked out with LF line endings.
git-secrets text eol=lf
git-secrets.1 text eol=lf
test/bats/bin/* text eol=lf
test/bats/libexec/* text eol=lf
*.bats text eol=lf
*.bash text eol=lf
22 changes: 18 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,29 @@ Installing git-secrets
~~~~~~~~~~~~~~~~~~~~~~

``git-secrets`` must be placed somewhere in your PATH so that it is picked up
by ``git`` when running ``git secrets``. You can use ``install`` target of the
provided Makefile to install ``git secrets`` and the man page. You can
customize the install path using the PREFIX and MANPREFIX variables.
by ``git`` when running ``git secrets``.

**\*nix (Linux/OSX)**

You can use ``install`` target of the provided Makefile to install
``git secrets`` and the man page. You can customize the install path
using the PREFIX and MANPREFIX variables.

::

make install

Or, installing with Homebrew (for OS X users).
**Windows**

Run the provided install.ps1 powershell script. This will copy the needed files
to an installation directory ("%USERPROFILE%/.git-secrets" by default) and add
the directory to the current user PATH.

::

PS > ./install.ps1

**Homebrew (for OS X users).**

::

Expand Down
48 changes: 48 additions & 0 deletions install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Param([string]$InstallationDirectory = $($Env:USERPROFILE + "\.git-secrets"))

Write-Host "Checking to see if installation directory already exists..."
if (-not (Test-Path $InstallationDirectory))
{
Write-Host "Creating installation directory."
New-Item -ItemType Directory -Path $InstallationDirectory | Out-Null
}
else
{
Write-Host "Installation directory already exists."
}

Write-Host "Copying files."
Copy-Item ./git-secrets -Destination $InstallationDirectory -Force
Copy-Item ./git-secrets.1 -Destination $InstallationDirectory -Force

Write-Host "Checking if directory already exists in Path..."
$currentPath = [Environment]::GetEnvironmentVariable("PATH", "User")
if ($currentPath -notlike "*$InstallationDirectory*")
{
Write-Host "Adding to path."
$newPath = $currentPath
if(-not ($newPath.EndsWith(";")))
{
$newPath = $newPath + ";"
}
$newPath = $newPath + $InstallationDirectory
[Environment]::SetEnvironmentVariable("PATH", $newPath, "User")
}
else
{
Write-Host "Already in Path."
}

# Adding to Session
Write-Host "Adding to user session."
$currentSessionPath = $Env:Path
if ($currentSessionPath -notlike "*$InstallationDirectory*")
{
if(-not ($currentSessionPath.EndsWith(";")))
{
$currentSessionPath = $currentSessionPath + ";"
}
$Env:Path = $currentSessionPath + $InstallationDirectory
}

Write-Host "Done."

0 comments on commit e324284

Please sign in to comment.