Skip to content

Commit e088859

Browse files
committed
Always create a .gitignore in .godot
1 parent c0c1c68 commit e088859

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

editor/export/export_template_manager.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,17 @@ Error ExportTemplateManager::install_android_template_from_file(const String &p_
840840
f->store_line(get_android_template_identifier(p_preset));
841841
}
842842

843+
// This directory should never be committed to git.
844+
const String parent_dir_gitignore = parent_dir.path_join(".gitignore");
845+
if (!FileAccess::exists(parent_dir_gitignore)) {
846+
Ref<FileAccess> f = FileAccess::open(parent_dir_gitignore, FileAccess::WRITE);
847+
if (f.is_valid()) {
848+
f->store_line("*");
849+
} else {
850+
ERR_PRINT("Failed to create file " + parent_dir_gitignore.quote() + ".");
851+
}
852+
}
853+
843854
// Create the android build directory.
844855
Error err = da->make_dir_recursive(build_dir);
845856
ERR_FAIL_COND_V(err != OK, err);

editor/file_system/editor_paths.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,17 @@ EditorPaths::EditorPaths() {
276276
}
277277
}
278278

279+
// This directory should never be committed to git.
280+
String project_data_gitignore_file_path = project_data_dir.path_join(".gitignore");
281+
if (!FileAccess::exists(project_data_gitignore_file_path)) {
282+
Ref<FileAccess> f = FileAccess::open(project_data_gitignore_file_path, FileAccess::WRITE);
283+
if (f.is_valid()) {
284+
f->store_line("*");
285+
} else {
286+
ERR_PRINT("Failed to create file " + project_data_gitignore_file_path.quote() + ".");
287+
}
288+
}
289+
279290
Engine::get_singleton()->set_shader_cache_path(project_data_dir);
280291

281292
// Editor metadata dir.

editor/version_control/editor_vcs_interface.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,9 @@ void EditorVCSInterface::create_vcs_metadata_files(VCSMetadata p_vcs_metadata_ty
366366
ERR_FAIL_MSG("Couldn't create .gitignore in project path.");
367367
} else {
368368
f->store_line("# Godot 4+ specific ignores");
369-
f->store_line(".godot/");
370-
f->store_line("/android/");
369+
f->store_line("# The following directories are ignored in each directory's `.gitignore`.");
370+
f->store_line("#.godot/");
371+
f->store_line("#/android/");
371372
}
372373
f = FileAccess::open(p_dir.path_join(".gitattributes"), FileAccess::WRITE);
373374
if (f.is_null()) {

0 commit comments

Comments
 (0)