You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added file system compatibility validation to prevent folder/file names that break when syncing to local systems (Windows in particular):
- Names ending with periods (.) or spaces
- Reserved Windows names (CON, PRN, AUX, NUL, COM1-9, LPT1-9)
- Invalid characters (< > : " | ? * or control characters)
The workflow now detects these issues automatically and provides specific guidance in the PR comment before closing.
Copy file name to clipboardExpand all lines: .github/scripts/validate-structure.js
+28Lines changed: 28 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -49,6 +49,34 @@ function validateFilePath(filePath) {
49
49
constnormalized=filePath.replace(/\\/g,'/');
50
50
constsegments=normalized.split('/');
51
51
52
+
// Check for invalid characters that break local file systems
53
+
for(leti=0;i<segments.length;i++){
54
+
constsegment=segments[i];
55
+
56
+
// Check for trailing periods (invalid on Windows)
57
+
if(segment.endsWith('.')){
58
+
return`Invalid folder/file name '${segment}' in path '${normalized}': Names cannot end with a period (.) as this breaks local file system sync on Windows.`;
59
+
}
60
+
61
+
// Check for trailing spaces (invalid on Windows)
62
+
if(segment.endsWith(' ')){
63
+
return`Invalid folder/file name '${segment}' in path '${normalized}': Names cannot end with a space as this breaks local file system sync on Windows.`;
return`Invalid folder/file name '${segment}' in path '${normalized}': '${nameWithoutExt}' is a reserved name on Windows and will break local file system sync.`;
71
+
}
72
+
73
+
// Check for invalid characters (Windows and general file system restrictions)
74
+
constinvalidChars=/[<>:"|?*\x00-\x1F]/;
75
+
if(invalidChars.test(segment)){
76
+
return`Invalid folder/file name '${segment}' in path '${normalized}': Contains characters that are invalid on Windows file systems (< > : " | ? * or control characters).`;
commentBody += `Your contribution contains file or folder names that will break when syncing to local file systems (especially Windows):\n\n`;
104
+
commentBody += `\`\`\`\n${output}\n\`\`\`\n\n`;
105
+
commentBody += `**Common issues:**\n`;
106
+
commentBody += `- Folder/file names ending with a period (.) - not allowed on Windows\n`;
107
+
commentBody += `- Folder/file names ending with spaces - not allowed on Windows\n`;
108
+
commentBody += `- Reserved names like CON, PRN, AUX, NUL, COM1-9, LPT1-9 - not allowed on Windows\n`;
109
+
commentBody += `- Invalid characters: < > : " | ? * or control characters\n\n`;
110
+
commentBody += `Please rename these files/folders to be compatible with all operating systems.\n\n`;
111
+
} else {
112
+
commentBody += `As a reminder, the general requirements (as outlined in the [CONTRIBUTING.md file](https://github.com/ServiceNowDevProgram/code-snippets/blob/main/CONTRIBUTING.md)) are the following: follow the folder+subfolder guidelines and include a README.md file explaining what the code snippet does.\n\n`;
commentBody += `Review your contribution against the guidelines and make the necessary adjustments. Closing this for now. Once you make additional changes, feel free to re-open this Pull Request or create a new one.`;
117
+
90
118
await github.rest.issues.createComment({
91
119
owner,
92
120
repo,
93
121
issue_number: pullNumber,
94
-
body: `Thank you for your contribution. However, it doesn't comply with our contributing guidelines. As a reminder, the general requirements (as outlined in the [CONTRIBUTING.md file](https://github.com/ServiceNowDevProgram/code-snippets/blob/main/CONTRIBUTING.md)) are the following: follow the folder+subfolder guidelines and include a README.md file explaining what the code snippet does. Review your contribution against the guidelines and make the necessary adjustments. Closing this for now. Once you make additional changes, feel free to re-open this Pull Request or create a new one.`.trim()
0 commit comments