-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some git attributes to avoid using CRLF on Win
- Loading branch information
1 parent
431061f
commit 61c2615
Showing
6 changed files
with
218 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
git config core.eol lf | ||
git config core.autocrlf input | ||
|
||
git config core.hooksPath .githooks/windows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Updates html files with cache busting urls including file hashes. | ||
|
||
# Actual file processing | ||
$htmlfiles = Get-ChildItem -Path . -Recurse -Filter "*.html" | Resolve-path -relative | ||
foreach ($htmlfile in $htmlfiles) { | ||
Write-Host "[info] Processing '${htmlfile}' for cache busting..." -ForegroundColor Blue | ||
|
||
$resfiles = (@(Get-ChildItem -Path . -Recurse -Filter "*.css") + (Get-ChildItem -Path . -Recurse -Filter "*.js")) | Resolve-Path -relative | ||
|
||
if ($args[0] -eq "gitadd") { | ||
$resfiles = (git status -s | Select-String -Pattern "[A-Z] .+") | ForEach-Object { -split $_.Line | Select-Object -Last 1 } | ||
} | ||
|
||
foreach ($resfile in $resfiles) { | ||
$resfile = $resfile -replace '\\', '/' -replace '\./', '' | ||
# Check if resource is used in html file | ||
if ($null -ne (Select-String -Path $htmlfile -Pattern $resfile)) { | ||
$hash = (Get-FileHash $resfile -Algorithm SHA1).Hash | ||
|
||
# This is just for cache busting... | ||
# If 7 first characters of SHA1 is okay for git, it should be more than enough for us | ||
$hash = $hash.Substring(0, 7).ToLower() | ||
|
||
(Get-Content -Raw -Path $htmlfile).replace('\r\n', "\n") -replace "$resfile(\?v=[a-z0-9]+)?", "${resfile}?v=$hash" | Set-Content $htmlfile | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters