Merge pull request #3802 from anaisbetts/disallow-unc-paths

Disallow UNC paths
This commit is contained in:
Caleb Owens 2024-05-21 12:27:34 +01:00 committed by GitHub
commit 0085c0901d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 31 additions and 1 deletions

1
.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
*.sh eol=lf

View File

@ -4,5 +4,6 @@
"trailingComma": "none",
"printWidth": 100,
"plugins": ["prettier-plugin-svelte", "prettier-plugin-tailwindcss"],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }],
"endOfLine": "auto"
}

View File

@ -107,6 +107,8 @@ export class ProjectService {
const path = await this.promptForDirectory();
if (!path) return;
if (!this.validateProjectPath(path)) return;
try {
const project = await this.add(path);
if (!project) return;
@ -118,6 +120,32 @@ export class ProjectService {
}
}
validateProjectPath(path: string, showErrors = true) {
if (/^\\\\wsl.localhost/i.test(path)) {
if (showErrors) {
showError(
'Use the Linux version of GitButler',
'For WSL2 projects, install the Linux version of GitButler inside of your WSL2 distro'
);
}
return false;
}
if (/^\\\\/i.test(path)) {
if (showErrors) {
showError(
'UNC Paths are not directly supported',
'Using git across a network is not recommended. Either clone the repo locally, or use the NET USE command to map a network drive'
);
}
return false;
}
return true;
}
getLastOpenedProject() {
return get(this.persistedId);
}