Intermediate

This commit is contained in:
Twarit Waikar
2022-08-09 03:46:20 +05:30
parent acece95267
commit b603dcadaa
3 changed files with 9 additions and 4 deletions

View File

@@ -2,6 +2,7 @@
#include <cstring>
#include <git2/tree.h>
#include "godot_cpp/core/class_db.hpp"
#include "godot_cpp/classes/file.hpp"
@@ -183,18 +184,18 @@ void GitPlugin::_unstage_file(const godot::String &file_path) {
}
void GitPlugin::create_gitignore_and_gitattributes() {
if (!godot::File::file_exists("res://.gitignore")) {
if (!godot::File::file_exists(repo_project_path + "/.gitignore")) {
godot::File file;
file.open("res://.gitignore", godot::File::ModeFlags::WRITE);
file.open(repo_project_path + "/.gitignore", godot::File::ModeFlags::WRITE);
file.store_string(
"# Godot 4+ specific ignores\n"
".godot/\n");
file.close();
}
if (!godot::File::file_exists("res://.gitattributes")) {
if (!godot::File::file_exists(repo_project_path + "/.gitattributes")) {
godot::File file;
file.open("res://.gitattributes", godot::File::ModeFlags::WRITE);
file.open(repo_project_path + "/.gitattributes", godot::File::ModeFlags::WRITE);
file.store_string(
"# Set the default behavior, in case people don't have core.autocrlf set.\n"
"* text=auto\n\n"
@@ -674,6 +675,8 @@ bool GitPlugin::_initialize(const godot::String &project_path) {
ERR_FAIL_COND_V(project_path == "", false);
repo_project_path = project_path;
int init = git_libgit2_init();
if (init > 1) {
WARN_PRINT("Multiple libgit2 instances are running");

View File

@@ -27,6 +27,7 @@ public:
bool has_merge = false;
git_repository_ptr repo;
git_oid pull_merge_oid = {};
godot::String repo_project_path;
std::unordered_map<git_status_t, ChangeType> map_changes;
GitPlugin();

View File

@@ -71,3 +71,4 @@ using git_revwalk_ptr = unique_ptr_deleter<git_revwalk, git_revwalk_free>;
using git_signature_ptr = unique_ptr_deleter<git_signature, git_signature_free>;
using git_status_list_ptr = unique_ptr_deleter<git_status_list, git_status_list_free>;
using git_tree_ptr = unique_ptr_deleter<git_tree, git_tree_free>;
using git_tree_entry_ptr = unique_ptr_deleter<git_tree_entry, git_tree_entry_free>;