Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script path cache bust #956

Merged
merged 3 commits into from
Sep 22, 2015
Merged
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
4 changes: 4 additions & 0 deletions src/app/FakeLib/EnvironmentHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ let inline combinePathsNoTrim path1 path2 = Path.Combine(path1, path2)
let inline (@@) path1 path2 = combinePaths path1 path2
let inline (</>) path1 path2 = combinePathsNoTrim path1 path2

// Normalizes path for different OS
let inline normalizePath (path : string) =
path.Replace('\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar)

/// Retrieves all environment variables from the given target
let environVars target =
[ for e in Environment.GetEnvironmentVariables target ->
Expand Down
4 changes: 3 additions & 1 deletion src/app/FakeLib/FSIHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ let rec getAllScripts scriptPath : seq<Script> =

let getScriptHash pathsAndContents =
let fullContents = getAllScriptContents pathsAndContents |> String.concat "\n"
let paths = pathsAndContents |> Seq.map(fun x -> x.Location |> EnvironmentHelper.normalizePath) |> String.concat "\n"

let hasher = HashLib.HashFactory.Checksum.CreateCRC32a()
hasher.ComputeString(fullContents).ToString()
hasher.ComputeString(fullContents + paths).ToString()

module private Cache =
let xname name = XName.Get(name)
Expand Down
3 changes: 1 addition & 2 deletions src/app/FakeLib/Globbing/Globbing.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/// This module contains a file pattern globbing implementation.
module Fake.Globbing

open Fake.EnvironmentHelper
open System
open System.Collections.Generic
open System.IO
Expand Down Expand Up @@ -58,8 +59,6 @@ let private isDrive =
let regex = Regex(@"^[A-Za-z]:$", RegexOptions.Compiled)
fun dir -> regex.IsMatch dir

let inline private normalizePath (p : string) =
p.Replace('\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar)
let inline private normalizeOutputPath (p : string) =
p.Replace('\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar)
.TrimEnd(Path.DirectorySeparatorChar)
Expand Down
6 changes: 3 additions & 3 deletions src/test/Test.FAKECore/ChangeWatcherSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public class when_calculating_directories_to_watch
var dirsToWatch = ChangeWatcher.calcDirsToWatch(fileIncludes);

dirsToWatch.Length.ShouldEqual(2);
dirsToWatch.ShouldContain(Fake.Globbing.normalizePath(@"C:\Project\test1\bin"));
dirsToWatch.ShouldContain(Fake.Globbing.normalizePath(@"C:\Project\test2\bin"));
dirsToWatch.ShouldContain(Fake.EnvironmentHelper.normalizePath(@"C:\Project\test1\bin"));
dirsToWatch.ShouldContain(Fake.EnvironmentHelper.normalizePath(@"C:\Project\test2\bin"));
};

It should_only_take_the_most_root_path_when_multiple_directories_share_a_root =
Expand All @@ -29,7 +29,7 @@ public class when_calculating_directories_to_watch
var dirsToWatch = ChangeWatcher.calcDirsToWatch(fileIncludes);

dirsToWatch.Length.ShouldEqual(1);
dirsToWatch.ShouldContain(Fake.Globbing.normalizePath(@"C:\Project\tests"));
dirsToWatch.ShouldContain(Fake.EnvironmentHelper.normalizePath(@"C:\Project\tests"));
};
}
}