Skip to content

Commit

Permalink
Fix git.ChangedFiles on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredpalmer committed Dec 4, 2021
1 parent 161e419 commit 23877bd
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
2 changes: 1 addition & 1 deletion internal/cache/cache_fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (f *fsCache) Fetch(target, hash string, _unusedOutputGlobs []string) (bool,
// Otherwise, copy it into position
err := fs.RecursiveCopyOrLinkFile(cachedFolder, target, fs.DirPermissions, true, true)
if err != nil {
return false, nil, fmt.Errorf("error moving cache from artifact into %v: %w", target, err)
return false, nil, fmt.Errorf("error moving artifact from cache into %v: %w", target, err)
}
return true, nil, nil
}
Expand Down
8 changes: 1 addition & 7 deletions internal/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,7 @@ func (c *RunCommand) Run(args []string) int {
hasRepoGlobalFileChanged := false
var changedFiles []string
if runOptions.since != "" {
changedFilesRelativeToGitRoot := git.ChangedFiles(runOptions.since, true, "")
// We need to convert relative path of changed files to git root, to relative path to cwd
for _, f := range changedFilesRelativeToGitRoot {
repoRoot := filepath.Dir(gitRepoRoot)
pathToTarget := filepath.Join(repoRoot, f)
changedFiles = append(changedFiles, strings.Replace(pathToTarget, cwd+"/", "", 1))
}
changedFiles = git.ChangedFiles(runOptions.since, true, cwd)
}

ignoreSet := make(util.Set)
Expand Down
14 changes: 10 additions & 4 deletions scripts/e2e/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,15 @@ function runSmokeTests(
assert.ok(!!chash, "No hash for c:test");
const splitMessage = chash.split(" ");
const hash = splitMessage[splitMessage.length - 1];
const logFilePath = `${
repo.subdir ? repo.subdir + "/" : ""
}node_modules/.cache/turbo/${hash}/.turbo/turbo-test.log`;
const logFilePath = path.join(
repo.subdir ? repo.subdir + "/" : "",
"node_modules",
".cache",
"turbo",
hash,
".turbo",
"turbo-test.log"
);
let text = "";
assert.not.throws(() => {
text = repo.readFileSync(logFilePath);
Expand All @@ -70,7 +76,7 @@ function runSmokeTests(
assert.ok(text.includes("testing c"), "Contains correct output");
repo.newBranch("my-feature-branch");
repo.commitFiles({
[`packages/a/test.js`]: `console.log('testingz a');`,
[path.join("packages", "a", "test.js")]: `console.log('testingz a');`,
});

const sinceResults = repo.turbo(
Expand Down
18 changes: 15 additions & 3 deletions scripts/monorepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,28 @@ importers:

addPackage(name, internalDeps = []) {
return this.commitFiles({
[`packages/${name}/build.js`]: `console.log('building ${name}');`,
[`packages/${name}/build.js`]: `
const fs = require('fs');
const path = require('path');
console.log('building ${name}');
if (!fs.existsSync(path.join(__dirname, 'dist'))){
fs.mkdirSync(path.join(__dirname, 'dist'));
}
fs.copyFileSync(
path.join(__dirname, 'build.js'),
path.join(__dirname, 'dist', 'build.js')
);
`,
[`packages/${name}/test.js`]: `console.log('testing ${name}');`,
[`packages/${name}/lint.js`]: `console.log('linting ${name}');`,
[`packages/${name}/package.json`]: {
name,
version: "0.1.0",
license: "MIT",
scripts: {
build:
"node ./build.js && mkdir -p dist && cp build.js dist/build.js;",
build: "node ./build.js",
test: "node ./test.js",
lint: "node ./lint.js",
},
Expand Down

0 comments on commit 23877bd

Please sign in to comment.