Skip to content

Commit e98f619

Browse files
committed
fix: Add more useful error for non-ignored symlinks
1 parent 030f74f commit e98f619

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/git.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ import {
77
CommitFilesResult,
88
} from "./interface";
99

10+
/**
11+
* @see https://isomorphic-git.org/docs/en/walk#walkerentry-mode
12+
*/
13+
const FILE_MODES = {
14+
directory: 0o40000,
15+
file: 0o100644,
16+
executableFile: 0o100755,
17+
symlink: 0o120000,
18+
} as const;
19+
1020
export const commitChangesFromRepo = async ({
1121
base,
1222
repoDirectory = process.cwd(),
@@ -50,6 +60,14 @@ export const commitChangesFromRepo = async ({
5060
) {
5161
return null;
5262
}
63+
if (
64+
(await commit?.mode()) === FILE_MODES.symlink ||
65+
(await workdir?.mode()) === FILE_MODES.symlink
66+
) {
67+
throw new Error(
68+
`Unexpected symlink at ${filepath}, GitHub API only supports files and directories. You may need to add this file to .gitignore`,
69+
);
70+
}
5371
const prevOid = await commit?.oid();
5472
const currentOid = await workdir?.oid();
5573
// Don't include files that haven't changed, and exist in both trees

0 commit comments

Comments
 (0)