Skip to content

Commit

Permalink
refactor(git): replace positional args with parameter object
Browse files Browse the repository at this point in the history
  • Loading branch information
vvagaytsev committed Sep 24, 2024
1 parent a6b5697 commit 68b2c67
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 10 deletions.
2 changes: 1 addition & 1 deletion core/src/util/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export async function findConfigPathsInPath({
log,
filter: (f) => isConfigFilename(basename(f)),
scanRoot: dir,
skipHashCalculation: true
skipHashCalculation: true,
})

return paths.map((f) => f.path)
Expand Down
43 changes: 34 additions & 9 deletions core/src/vcs/git-sub-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,12 @@ export class GitSubTreeHandler extends AbstractGitHandler {
// No need to stat unless it has no hash, is a symlink, or is modified
// Note: git ls-files always returns mode 120000 for symlinks
if (hash && entry.mode !== "120000" && !modifiedFiles.has(resolvedPath)) {
return ensureHash(output, undefined, modifiedFiles, skipHashCalculation)
return ensureHash({
file: output,
stats: undefined,
modifiedFiles,
skipHashCalculation,
})
}

try {
Expand All @@ -320,7 +325,12 @@ export class GitSubTreeHandler extends AbstractGitHandler {
gitLog.verbose(`Ignoring symlink pointing outside of ${pathDescription} at ${resolvedPath}`)
return
}
return ensureHash(output, stats, modifiedFiles, skipHashCalculation)
return ensureHash({
file: output,
stats,
modifiedFiles,
skipHashCalculation,
})
} catch (err) {
if (isErrnoException(err) && err.code === "ENOENT") {
gitLog.verbose(`Ignoring dead symlink at ${resolvedPath}`)
Expand All @@ -329,10 +339,20 @@ export class GitSubTreeHandler extends AbstractGitHandler {
throw err
}
} else {
return ensureHash(output, stats, modifiedFiles, skipHashCalculation)
return ensureHash({
file: output,
stats,
modifiedFiles,
skipHashCalculation,
})
}
} else {
return ensureHash(output, stats, modifiedFiles, skipHashCalculation)
return ensureHash({
file: output,
stats,
modifiedFiles,
skipHashCalculation,
})
}
} catch (err) {
if (isErrnoException(err) && err.code === "ENOENT") {
Expand Down Expand Up @@ -472,12 +492,17 @@ function parseGitLsFilesOutputLine(data: Buffer): GitEntry | undefined {
/**
* Make sure we have a fresh hash for each file.
*/
async function ensureHash(
file: VcsFile,
stats: fsExtra.Stats | undefined,
modifiedFiles: Set<string>,
async function ensureHash({
file,
stats,
modifiedFiles,
skipHashCalculation,
}: {
file: VcsFile
stats: fsExtra.Stats | undefined
modifiedFiles: Set<string>
skipHashCalculation: boolean
): Promise<VcsFile> {
}): Promise<VcsFile> {
if (skipHashCalculation) {
return file
}
Expand Down

0 comments on commit 68b2c67

Please sign in to comment.