Path: blob/master/editor/version_control/version_control_editor_plugin.cpp
9903 views
/**************************************************************************/1/* version_control_editor_plugin.cpp */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#include "version_control_editor_plugin.h"3132#include "core/config/project_settings.h"33#include "core/os/keyboard.h"34#include "core/os/time.h"35#include "editor/docks/editor_dock_manager.h"36#include "editor/docks/filesystem_dock.h"37#include "editor/editor_interface.h"38#include "editor/editor_node.h"39#include "editor/editor_string_names.h"40#include "editor/file_system/editor_file_system.h"41#include "editor/gui/editor_bottom_panel.h"42#include "editor/script/script_editor_plugin.h"43#include "editor/settings/editor_command_palette.h"44#include "editor/settings/editor_settings.h"45#include "editor/themes/editor_scale.h"46#include "scene/gui/flow_container.h"47#include "scene/gui/line_edit.h"48#include "scene/gui/separator.h"4950#define CHECK_PLUGIN_INITIALIZED() \51ERR_FAIL_NULL_MSG(EditorVCSInterface::get_singleton(), "No VCS plugin is initialized. Select a Version Control Plugin from Project menu.");5253VersionControlEditorPlugin *VersionControlEditorPlugin::singleton = nullptr;5455void VersionControlEditorPlugin::_bind_methods() {56// No binds required so far.57}5859void VersionControlEditorPlugin::_create_vcs_metadata_files() {60String dir = "res://";61EditorVCSInterface::create_vcs_metadata_files(EditorVCSInterface::VCSMetadata(metadata_selection->get_selected()), dir);62}6364void VersionControlEditorPlugin::_notification(int p_what) {65if (p_what == NOTIFICATION_READY) {66String installed_plugin = GLOBAL_GET("editor/version_control/plugin_name");67bool has_autoload_enable = GLOBAL_GET("editor/version_control/autoload_on_startup");6869if (installed_plugin != "" && has_autoload_enable) {70if (_load_plugin(installed_plugin)) {71_set_credentials();72}73}74}75}7677void VersionControlEditorPlugin::_populate_available_vcs_names() {78set_up_choice->clear();79for (const StringName &available_plugin : available_plugins) {80set_up_choice->add_item(available_plugin);81}82}8384VersionControlEditorPlugin *VersionControlEditorPlugin::get_singleton() {85return singleton ? singleton : memnew(VersionControlEditorPlugin);86}8788void VersionControlEditorPlugin::popup_vcs_metadata_dialog() {89metadata_dialog->popup_centered();90}9192void VersionControlEditorPlugin::popup_vcs_set_up_dialog(const Control *p_gui_base) {93fetch_available_vcs_plugin_names();94if (!available_plugins.is_empty()) {95Size2 popup_size = Size2(400, 100);96Size2 window_size = p_gui_base->get_viewport_rect().size;97popup_size = popup_size.min(window_size * 0.5);9899_populate_available_vcs_names();100101set_up_dialog->popup_centered_clamped(popup_size * EDSCALE);102} else {103// TODO: Give info to user on how to fix this error.104EditorNode::get_singleton()->show_warning(TTR("No VCS plugins are available in the project. Install a VCS plugin to use VCS integration features."), TTR("Error"));105}106}107108void VersionControlEditorPlugin::_initialize_vcs() {109ERR_FAIL_COND_MSG(EditorVCSInterface::get_singleton(), EditorVCSInterface::get_singleton()->get_vcs_name() + " is already active.");110111const int id = set_up_choice->get_selected_id();112String selected_plugin = set_up_choice->get_item_text(id);113114if (_load_plugin(selected_plugin)) {115ProjectSettings::get_singleton()->set("editor/version_control/autoload_on_startup", true);116ProjectSettings::get_singleton()->set("editor/version_control/plugin_name", selected_plugin);117ProjectSettings::get_singleton()->save();118}119}120121void VersionControlEditorPlugin::_set_vcs_ui_state(bool p_enabled) {122set_up_dialog->get_ok_button()->set_disabled(!p_enabled);123set_up_choice->set_disabled(p_enabled);124toggle_vcs_choice->set_pressed_no_signal(p_enabled);125}126127void VersionControlEditorPlugin::_set_credentials() {128CHECK_PLUGIN_INITIALIZED();129130String username = set_up_username->get_text();131String password = set_up_password->get_text();132String ssh_public_key = set_up_ssh_public_key_path->get_text();133String ssh_private_key = set_up_ssh_private_key_path->get_text();134String ssh_passphrase = set_up_ssh_passphrase->get_text();135136EditorVCSInterface::get_singleton()->set_credentials(137username,138password,139ssh_public_key,140ssh_private_key,141ssh_passphrase);142143EditorSettings::get_singleton()->set_setting("version_control/username", username);144EditorSettings::get_singleton()->set_setting("version_control/ssh_public_key_path", ssh_public_key);145EditorSettings::get_singleton()->set_setting("version_control/ssh_private_key_path", ssh_private_key);146}147148bool VersionControlEditorPlugin::_load_plugin(const String &p_name) {149Object *extension_instance = ClassDB::instantiate(p_name);150ERR_FAIL_NULL_V_MSG(extension_instance, false, "Received a nullptr VCS extension instance during construction.");151152EditorVCSInterface *vcs_plugin = Object::cast_to<EditorVCSInterface>(extension_instance);153ERR_FAIL_NULL_V_MSG(vcs_plugin, false, vformat("Could not cast VCS extension instance to %s.", EditorVCSInterface::get_class_static()));154155String res_dir = OS::get_singleton()->get_resource_dir();156157ERR_FAIL_COND_V_MSG(!vcs_plugin->initialize(res_dir), false, "Could not initialize " + p_name);158159EditorVCSInterface::set_singleton(vcs_plugin);160161register_editor();162EditorFileSystem::get_singleton()->connect(SNAME("filesystem_changed"), callable_mp(this, &VersionControlEditorPlugin::_refresh_stage_area));163164_refresh_stage_area();165_refresh_commit_list();166_refresh_branch_list();167_refresh_remote_list();168169return true;170}171172void VersionControlEditorPlugin::_update_set_up_warning(const String &p_new_text) {173bool empty_settings = set_up_username->get_text().strip_edges().is_empty() &&174set_up_password->get_text().is_empty() &&175set_up_ssh_public_key_path->get_text().strip_edges().is_empty() &&176set_up_ssh_private_key_path->get_text().strip_edges().is_empty() &&177set_up_ssh_passphrase->get_text().is_empty();178179if (empty_settings) {180set_up_warning_text->add_theme_color_override(SceneStringName(font_color), EditorNode::get_singleton()->get_editor_theme()->get_color(SNAME("warning_color"), EditorStringName(Editor)));181set_up_warning_text->set_text(TTR("Remote settings are empty. VCS features that use the network may not work."));182} else {183set_up_warning_text->set_text("");184}185}186187void VersionControlEditorPlugin::_refresh_branch_list() {188CHECK_PLUGIN_INITIALIZED();189190List<String> branch_list = EditorVCSInterface::get_singleton()->get_branch_list();191branch_select->clear();192193branch_select->set_disabled(branch_list.is_empty());194195String current_branch = EditorVCSInterface::get_singleton()->get_current_branch_name();196197int i = 0;198for (List<String>::ConstIterator itr = branch_list.begin(); itr != branch_list.end(); ++itr, ++i) {199branch_select->add_icon_item(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("VcsBranches"), EditorStringName(EditorIcons)), *itr, i);200201if (*itr == current_branch) {202branch_select->select(i);203}204}205}206207String VersionControlEditorPlugin::_get_date_string_from(int64_t p_unix_timestamp, int64_t p_offset_minutes) const {208return vformat(209"%s %s",210Time::get_singleton()->get_datetime_string_from_unix_time(p_unix_timestamp + p_offset_minutes * 60, true),211Time::get_singleton()->get_offset_string_from_offset_minutes(p_offset_minutes));212}213214void VersionControlEditorPlugin::_set_commit_list_size(int p_index) {215_refresh_commit_list();216}217218void VersionControlEditorPlugin::_refresh_commit_list() {219CHECK_PLUGIN_INITIALIZED();220221commit_list->get_root()->clear_children();222223List<EditorVCSInterface::Commit> commit_info_list = EditorVCSInterface::get_singleton()->get_previous_commits(commit_list_size_button->get_selected_metadata());224225for (const EditorVCSInterface::Commit &commit : commit_info_list) {226TreeItem *item = commit_list->create_item();227228// Only display the first line of a commit message229int line_ending = commit.msg.find_char('\n');230String commit_display_msg = commit.msg.substr(0, line_ending);231String commit_date_string = _get_date_string_from(commit.unix_timestamp, commit.offset_minutes);232233Dictionary meta_data;234meta_data[SNAME("commit_id")] = commit.id;235meta_data[SNAME("commit_title")] = commit_display_msg;236meta_data[SNAME("commit_subtitle")] = commit.msg.substr(line_ending).strip_edges();237meta_data[SNAME("commit_unix_timestamp")] = commit.unix_timestamp;238meta_data[SNAME("commit_author")] = commit.author;239meta_data[SNAME("commit_date_string")] = commit_date_string;240241item->set_text(0, commit_display_msg);242item->set_text(1, commit.author.strip_edges());243item->set_metadata(0, meta_data);244}245}246247void VersionControlEditorPlugin::_refresh_remote_list() {248CHECK_PLUGIN_INITIALIZED();249250List<String> remotes = EditorVCSInterface::get_singleton()->get_remotes();251252String current_remote = remote_select->get_selected_metadata();253remote_select->clear();254255remote_select->set_disabled(remotes.is_empty());256257int i = 0;258for (List<String>::ConstIterator itr = remotes.begin(); itr != remotes.end(); ++itr, ++i) {259remote_select->add_icon_item(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("ArrowUp"), EditorStringName(EditorIcons)), *itr, i);260remote_select->set_item_metadata(i, *itr);261262if (*itr == current_remote) {263remote_select->select(i);264}265}266}267268void VersionControlEditorPlugin::_commit() {269CHECK_PLUGIN_INITIALIZED();270271String msg = commit_message->get_text().strip_edges();272273ERR_FAIL_COND_MSG(msg.is_empty(), "No commit message was provided.");274275EditorVCSInterface::get_singleton()->commit(msg);276277version_control_dock_button->set_pressed(false);278279commit_message->release_focus();280commit_button->release_focus();281commit_message->set_text("");282283_refresh_stage_area();284_refresh_commit_list();285_refresh_branch_list();286_clear_diff();287}288289void VersionControlEditorPlugin::_branch_item_selected(int p_index) {290CHECK_PLUGIN_INITIALIZED();291292String branch_name = branch_select->get_item_text(p_index);293EditorVCSInterface::get_singleton()->checkout_branch(branch_name);294295EditorFileSystem::get_singleton()->scan_changes();296ScriptEditor::get_singleton()->reload_scripts();297298_refresh_branch_list();299_refresh_commit_list();300_refresh_stage_area();301_clear_diff();302303_update_opened_tabs();304}305306void VersionControlEditorPlugin::_remote_selected(int p_index) {307_refresh_remote_list();308}309310void VersionControlEditorPlugin::_ssh_public_key_selected(const String &p_path) {311set_up_ssh_public_key_path->set_text(p_path);312}313314void VersionControlEditorPlugin::_ssh_private_key_selected(const String &p_path) {315set_up_ssh_private_key_path->set_text(p_path);316}317318void VersionControlEditorPlugin::_popup_file_dialog(const Variant &p_file_dialog_variant) {319FileDialog *file_dialog = Object::cast_to<FileDialog>(p_file_dialog_variant);320ERR_FAIL_NULL(file_dialog);321322file_dialog->popup_centered_ratio();323}324325void VersionControlEditorPlugin::_create_branch() {326CHECK_PLUGIN_INITIALIZED();327328String new_branch_name = branch_create_name_input->get_text().strip_edges();329330EditorVCSInterface::get_singleton()->create_branch(new_branch_name);331EditorVCSInterface::get_singleton()->checkout_branch(new_branch_name);332333branch_create_name_input->clear();334_refresh_branch_list();335}336337void VersionControlEditorPlugin::_create_remote() {338CHECK_PLUGIN_INITIALIZED();339340String new_remote_name = remote_create_name_input->get_text().strip_edges();341String new_remote_url = remote_create_url_input->get_text().strip_edges();342343EditorVCSInterface::get_singleton()->create_remote(new_remote_name, new_remote_url);344345remote_create_name_input->clear();346remote_create_url_input->clear();347_refresh_remote_list();348}349350void VersionControlEditorPlugin::_update_branch_create_button(const String &p_new_text) {351branch_create_ok->set_disabled(p_new_text.strip_edges().is_empty());352}353354void VersionControlEditorPlugin::_update_remote_create_button(const String &p_new_text) {355remote_create_ok->set_disabled(p_new_text.strip_edges().is_empty());356}357358int VersionControlEditorPlugin::_get_item_count(Tree *p_tree) {359if (!p_tree->get_root()) {360return 0;361}362return p_tree->get_root()->get_children().size();363}364365void VersionControlEditorPlugin::_refresh_stage_area() {366CHECK_PLUGIN_INITIALIZED();367368staged_files->get_root()->clear_children();369unstaged_files->get_root()->clear_children();370371List<EditorVCSInterface::StatusFile> status_files = EditorVCSInterface::get_singleton()->get_modified_files_data();372for (const EditorVCSInterface::StatusFile &sf : status_files) {373if (sf.area == EditorVCSInterface::TREE_AREA_STAGED) {374_add_new_item(staged_files, sf.file_path, sf.change_type);375} else if (sf.area == EditorVCSInterface::TREE_AREA_UNSTAGED) {376_add_new_item(unstaged_files, sf.file_path, sf.change_type);377}378}379380staged_files->queue_redraw();381unstaged_files->queue_redraw();382383int total_changes = status_files.size();384String commit_tab_title = TTR("Commit") + (total_changes > 0 ? " (" + itos(total_changes) + ")" : "");385version_commit_dock->set_name(commit_tab_title);386}387388void VersionControlEditorPlugin::_discard_file(const String &p_file_path, EditorVCSInterface::ChangeType p_change) {389CHECK_PLUGIN_INITIALIZED();390391if (p_change == EditorVCSInterface::CHANGE_TYPE_NEW) {392Ref<DirAccess> dir = DirAccess::create(DirAccess::ACCESS_RESOURCES);393dir->remove(p_file_path);394} else {395CHECK_PLUGIN_INITIALIZED();396EditorVCSInterface::get_singleton()->discard_file(p_file_path);397}398// FIXIT: The project.godot file shows weird behavior399EditorFileSystem::get_singleton()->update_file(p_file_path);400}401402void VersionControlEditorPlugin::_confirm_discard_all() {403discard_all_confirm->popup_centered();404}405406void VersionControlEditorPlugin::_discard_all() {407TreeItem *file_entry = unstaged_files->get_root()->get_first_child();408while (file_entry) {409String file_path = file_entry->get_meta(SNAME("file_path"));410EditorVCSInterface::ChangeType change = (EditorVCSInterface::ChangeType)(int)file_entry->get_meta(SNAME("change_type"));411_discard_file(file_path, change);412413file_entry = file_entry->get_next();414}415_refresh_stage_area();416}417418void VersionControlEditorPlugin::_add_new_item(Tree *p_tree, const String &p_file_path, EditorVCSInterface::ChangeType p_change) {419String change_text = p_file_path + " (" + change_type_to_strings[p_change] + ")";420421TreeItem *new_item = p_tree->create_item();422new_item->set_text(0, change_text);423new_item->set_icon(0, change_type_to_icon[p_change]);424new_item->set_meta(SNAME("file_path"), p_file_path);425new_item->set_meta(SNAME("change_type"), p_change);426new_item->set_custom_color(0, change_type_to_color[p_change]);427428new_item->add_button(0, EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("File"), EditorStringName(EditorIcons)), BUTTON_TYPE_OPEN, false, TTR("Open in editor"));429if (p_tree == unstaged_files) {430new_item->add_button(0, EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("Close"), EditorStringName(EditorIcons)), BUTTON_TYPE_DISCARD, false, TTR("Discard changes"));431}432}433434void VersionControlEditorPlugin::_fetch() {435CHECK_PLUGIN_INITIALIZED();436437EditorVCSInterface::get_singleton()->fetch(remote_select->get_selected_metadata());438_refresh_branch_list();439}440441void VersionControlEditorPlugin::_pull() {442CHECK_PLUGIN_INITIALIZED();443444EditorVCSInterface::get_singleton()->pull(remote_select->get_selected_metadata());445_refresh_stage_area();446_refresh_branch_list();447_refresh_commit_list();448_clear_diff();449_update_opened_tabs();450}451452void VersionControlEditorPlugin::_push() {453CHECK_PLUGIN_INITIALIZED();454455EditorVCSInterface::get_singleton()->push(remote_select->get_selected_metadata(), false);456}457458void VersionControlEditorPlugin::_force_push() {459CHECK_PLUGIN_INITIALIZED();460461EditorVCSInterface::get_singleton()->push(remote_select->get_selected_metadata(), true);462}463464void VersionControlEditorPlugin::_update_opened_tabs() {465Vector<EditorData::EditedScene> open_scenes = EditorNode::get_editor_data().get_edited_scenes();466for (int i = 0; i < open_scenes.size(); i++) {467if (open_scenes[i].root == nullptr) {468continue;469}470EditorNode::get_singleton()->reload_scene(open_scenes[i].path);471}472}473474void VersionControlEditorPlugin::_move_all(Object *p_tree) {475Tree *tree = Object::cast_to<Tree>(p_tree);476477TreeItem *file_entry = tree->get_root()->get_first_child();478while (file_entry) {479_move_item(tree, file_entry);480481file_entry = file_entry->get_next();482}483_refresh_stage_area();484}485486void VersionControlEditorPlugin::_load_diff(Object *p_tree) {487CHECK_PLUGIN_INITIALIZED();488489version_control_dock_button->set_pressed(true);490491Tree *tree = Object::cast_to<Tree>(p_tree);492if (tree == staged_files) {493show_commit_diff_header = false;494String file_path = tree->get_selected()->get_meta(SNAME("file_path"));495diff_title->set_text(TTR("Staged Changes"));496diff_content = EditorVCSInterface::get_singleton()->get_diff(file_path, EditorVCSInterface::TREE_AREA_STAGED);497} else if (tree == unstaged_files) {498show_commit_diff_header = false;499String file_path = tree->get_selected()->get_meta(SNAME("file_path"));500diff_title->set_text(TTR("Unstaged Changes"));501diff_content = EditorVCSInterface::get_singleton()->get_diff(file_path, EditorVCSInterface::TREE_AREA_UNSTAGED);502} else if (tree == commit_list) {503show_commit_diff_header = true;504Dictionary meta_data = tree->get_selected()->get_metadata(0);505String commit_id = meta_data[SNAME("commit_id")];506String commit_title = meta_data[SNAME("commit_title")];507diff_title->set_text(commit_title);508diff_content = EditorVCSInterface::get_singleton()->get_diff(commit_id, EditorVCSInterface::TREE_AREA_COMMIT);509}510_display_diff(0);511}512513void VersionControlEditorPlugin::_clear_diff() {514diff->clear();515diff_content.clear();516diff_title->set_text("");517}518519void VersionControlEditorPlugin::_item_activated(Object *p_tree) {520Tree *tree = Object::cast_to<Tree>(p_tree);521522_move_item(tree, tree->get_selected());523_refresh_stage_area();524}525526void VersionControlEditorPlugin::_move_item(Tree *p_tree, TreeItem *p_item) {527CHECK_PLUGIN_INITIALIZED();528529if (p_tree == staged_files) {530EditorVCSInterface::get_singleton()->unstage_file(p_item->get_meta(SNAME("file_path")));531} else {532EditorVCSInterface::get_singleton()->stage_file(p_item->get_meta(SNAME("file_path")));533}534}535536void VersionControlEditorPlugin::_cell_button_pressed(Object *p_item, int p_column, int p_id, int p_mouse_button_index) {537TreeItem *item = Object::cast_to<TreeItem>(p_item);538String file_path = item->get_meta(SNAME("file_path"));539EditorVCSInterface::ChangeType change = (EditorVCSInterface::ChangeType)(int)item->get_meta(SNAME("change_type"));540541if (p_id == BUTTON_TYPE_OPEN && change != EditorVCSInterface::CHANGE_TYPE_DELETED) {542Ref<DirAccess> dir = DirAccess::create(DirAccess::ACCESS_RESOURCES);543if (!dir->file_exists(file_path)) {544return;545}546547file_path = "res://" + file_path;548if (ResourceLoader::get_resource_type(file_path) == "PackedScene") {549EditorNode::get_singleton()->load_scene(file_path);550} else if (file_path.ends_with(".gd")) {551EditorNode::get_singleton()->load_resource(file_path);552ScriptEditor::get_singleton()->reload_scripts();553} else {554FileSystemDock::get_singleton()->navigate_to_path(file_path);555}556557} else if (p_id == BUTTON_TYPE_DISCARD) {558_discard_file(file_path, change);559_refresh_stage_area();560}561}562563void VersionControlEditorPlugin::_display_diff(int p_idx) {564DiffViewType diff_view = (DiffViewType)diff_view_type_select->get_selected();565566diff->clear();567568if (show_commit_diff_header) {569Dictionary meta_data = commit_list->get_selected()->get_metadata(0);570String commit_id = meta_data[SNAME("commit_id")];571String commit_subtitle = meta_data[SNAME("commit_subtitle")];572String commit_date = meta_data[SNAME("commit_date")];573String commit_author = meta_data[SNAME("commit_author")];574String commit_date_string = meta_data[SNAME("commit_date_string")];575576diff->push_font(EditorNode::get_singleton()->get_editor_theme()->get_font(SNAME("doc_bold"), EditorStringName(EditorFonts)));577diff->push_color(EditorNode::get_singleton()->get_editor_theme()->get_color(SNAME("accent_color"), EditorStringName(Editor)));578diff->add_text(TTR("Commit:") + " " + commit_id);579diff->add_newline();580diff->add_text(TTR("Author:") + " " + commit_author);581diff->add_newline();582diff->add_text(TTR("Date:") + " " + commit_date_string);583diff->add_newline();584if (!commit_subtitle.is_empty()) {585diff->add_text(TTR("Subtitle:") + " " + commit_subtitle);586diff->add_newline();587}588diff->add_newline();589diff->pop();590diff->pop();591}592593for (const EditorVCSInterface::DiffFile &diff_file : diff_content) {594diff->push_font(EditorNode::get_singleton()->get_editor_theme()->get_font(SNAME("doc_bold"), EditorStringName(EditorFonts)));595diff->push_color(EditorNode::get_singleton()->get_editor_theme()->get_color(SNAME("accent_color"), EditorStringName(Editor)));596diff->add_text(TTR("File:") + " " + diff_file.new_file);597diff->pop();598diff->pop();599600diff->push_font(EditorNode::get_singleton()->get_editor_theme()->get_font(SNAME("status_source"), EditorStringName(EditorFonts)));601for (EditorVCSInterface::DiffHunk hunk : diff_file.diff_hunks) {602String old_start = String::num_int64(hunk.old_start);603String new_start = String::num_int64(hunk.new_start);604String old_lines = String::num_int64(hunk.old_lines);605String new_lines = String::num_int64(hunk.new_lines);606607diff->add_newline();608diff->append_text("[center]@@ " + old_start + "," + old_lines + " " + new_start + "," + new_lines + " @@[/center]");609diff->add_newline();610611switch (diff_view) {612case DIFF_VIEW_TYPE_SPLIT:613_display_diff_split_view(hunk.diff_lines);614break;615case DIFF_VIEW_TYPE_UNIFIED:616_display_diff_unified_view(hunk.diff_lines);617break;618}619diff->add_newline();620}621diff->pop();622623diff->add_newline();624}625}626627void VersionControlEditorPlugin::_display_diff_split_view(List<EditorVCSInterface::DiffLine> &p_diff_content) {628LocalVector<EditorVCSInterface::DiffLine> parsed_diff;629630for (EditorVCSInterface::DiffLine diff_line : p_diff_content) {631String line = diff_line.content.strip_edges(false, true);632633if (diff_line.new_line_no >= 0 && diff_line.old_line_no >= 0) {634diff_line.new_text = line;635diff_line.old_text = line;636parsed_diff.push_back(diff_line);637} else if (diff_line.new_line_no == -1) {638diff_line.new_text = "";639diff_line.old_text = line;640parsed_diff.push_back(diff_line);641} else if (diff_line.old_line_no == -1) {642int32_t j = parsed_diff.size() - 1;643while (j >= 0 && parsed_diff[j].new_line_no == -1) {644j--;645}646647if (j == (int32_t)parsed_diff.size() - 1) {648// no lines are modified649diff_line.new_text = line;650diff_line.old_text = "";651parsed_diff.push_back(diff_line);652} else {653// lines are modified654EditorVCSInterface::DiffLine modified_line = parsed_diff[j + 1];655modified_line.new_text = line;656modified_line.new_line_no = diff_line.new_line_no;657parsed_diff[j + 1] = modified_line;658}659}660}661662diff->push_table(6);663/*664[cell]Old Line No[/cell]665[cell]prefix[/cell]666[cell]Old Code[/cell]667668[cell]New Line No[/cell]669[cell]prefix[/cell]670[cell]New Line[/cell]671*/672673diff->set_table_column_expand(2, true);674diff->set_table_column_expand(5, true);675676for (uint32_t i = 0; i < parsed_diff.size(); i++) {677EditorVCSInterface::DiffLine diff_line = parsed_diff[i];678679bool has_change = diff_line.status != " ";680static const Color red = EditorNode::get_singleton()->get_editor_theme()->get_color(SNAME("error_color"), EditorStringName(Editor));681static const Color green = EditorNode::get_singleton()->get_editor_theme()->get_color(SNAME("success_color"), EditorStringName(Editor));682static const Color white = EditorNode::get_singleton()->get_editor_theme()->get_color(SceneStringName(font_color), SNAME("Label")) * Color(1, 1, 1, 0.6);683684if (diff_line.old_line_no >= 0) {685diff->push_cell();686diff->push_color(has_change ? red : white);687diff->add_text(String::num_int64(diff_line.old_line_no));688diff->pop();689diff->pop();690691diff->push_cell();692diff->push_color(has_change ? red : white);693diff->add_text(has_change ? "-|" : " |");694diff->pop();695diff->pop();696697diff->push_cell();698diff->push_color(has_change ? red : white);699diff->add_text(diff_line.old_text);700diff->pop();701diff->pop();702703} else {704diff->push_cell();705diff->pop();706707diff->push_cell();708diff->pop();709710diff->push_cell();711diff->pop();712}713714if (diff_line.new_line_no >= 0) {715diff->push_cell();716diff->push_color(has_change ? green : white);717diff->add_text(String::num_int64(diff_line.new_line_no));718diff->pop();719diff->pop();720721diff->push_cell();722diff->push_color(has_change ? green : white);723diff->add_text(has_change ? "+|" : " |");724diff->pop();725diff->pop();726727diff->push_cell();728diff->push_color(has_change ? green : white);729diff->add_text(diff_line.new_text);730diff->pop();731diff->pop();732} else {733diff->push_cell();734diff->pop();735736diff->push_cell();737diff->pop();738739diff->push_cell();740diff->pop();741}742}743diff->pop();744}745746void VersionControlEditorPlugin::_display_diff_unified_view(List<EditorVCSInterface::DiffLine> &p_diff_content) {747diff->push_table(4);748diff->set_table_column_expand(3, true);749750/*751[cell]Old Line No[/cell]752[cell]New Line No[/cell]753[cell]status[/cell]754[cell]code[/cell]755*/756for (const EditorVCSInterface::DiffLine &diff_line : p_diff_content) {757String line = diff_line.content.strip_edges(false, true);758759Color color;760if (diff_line.status == "+") {761color = EditorNode::get_singleton()->get_editor_theme()->get_color(SNAME("success_color"), EditorStringName(Editor));762} else if (diff_line.status == "-") {763color = EditorNode::get_singleton()->get_editor_theme()->get_color(SNAME("error_color"), EditorStringName(Editor));764} else {765color = EditorNode::get_singleton()->get_editor_theme()->get_color(SceneStringName(font_color), SNAME("Label"));766color *= Color(1, 1, 1, 0.6);767}768769diff->push_cell();770diff->push_color(color);771diff->push_indent(1);772diff->add_text(diff_line.old_line_no >= 0 ? String::num_int64(diff_line.old_line_no) : "");773diff->pop();774diff->pop();775diff->pop();776777diff->push_cell();778diff->push_color(color);779diff->push_indent(1);780diff->add_text(diff_line.new_line_no >= 0 ? String::num_int64(diff_line.new_line_no) : "");781diff->pop();782diff->pop();783diff->pop();784785diff->push_cell();786diff->push_color(color);787diff->add_text(diff_line.status != "" ? diff_line.status + "|" : " |");788diff->pop();789diff->pop();790791diff->push_cell();792diff->push_color(color);793diff->add_text(line);794diff->pop();795diff->pop();796}797798diff->pop();799}800801void VersionControlEditorPlugin::_update_commit_button() {802commit_button->set_disabled(commit_message->get_text().strip_edges().is_empty());803}804805void VersionControlEditorPlugin::_remove_branch() {806CHECK_PLUGIN_INITIALIZED();807808EditorVCSInterface::get_singleton()->remove_branch(branch_to_remove);809branch_to_remove.clear();810811_refresh_branch_list();812}813814void VersionControlEditorPlugin::_remove_remote() {815CHECK_PLUGIN_INITIALIZED();816817EditorVCSInterface::get_singleton()->remove_remote(remote_to_remove);818remote_to_remove.clear();819820_refresh_remote_list();821}822823void VersionControlEditorPlugin::_extra_option_selected(int p_index) {824CHECK_PLUGIN_INITIALIZED();825826switch ((ExtraOption)p_index) {827case EXTRA_OPTION_FORCE_PUSH:828_force_push();829break;830case EXTRA_OPTION_CREATE_BRANCH:831branch_create_confirm->popup_centered();832break;833case EXTRA_OPTION_CREATE_REMOTE:834remote_create_confirm->popup_centered();835break;836}837}838839void VersionControlEditorPlugin::_popup_branch_remove_confirm(int p_index) {840branch_to_remove = extra_options_remove_branch_list->get_item_text(p_index);841842branch_remove_confirm->set_text(vformat(TTR("Do you want to remove the %s branch?"), branch_to_remove));843branch_remove_confirm->popup_centered();844}845846void VersionControlEditorPlugin::_popup_remote_remove_confirm(int p_index) {847remote_to_remove = extra_options_remove_remote_list->get_item_text(p_index);848849remote_remove_confirm->set_text(vformat(TTR("Do you want to remove the %s remote?"), branch_to_remove));850remote_remove_confirm->popup_centered();851}852853void VersionControlEditorPlugin::_update_extra_options() {854extra_options_remove_branch_list->clear();855for (int i = 0; i < branch_select->get_item_count(); i++) {856extra_options_remove_branch_list->add_icon_item(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("VcsBranches"), EditorStringName(EditorIcons)), branch_select->get_item_text(branch_select->get_item_id(i)));857}858extra_options_remove_branch_list->update_canvas_items();859860extra_options_remove_remote_list->clear();861for (int i = 0; i < remote_select->get_item_count(); i++) {862extra_options_remove_remote_list->add_icon_item(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("ArrowUp"), EditorStringName(EditorIcons)), remote_select->get_item_text(remote_select->get_item_id(i)));863}864extra_options_remove_remote_list->update_canvas_items();865}866867bool VersionControlEditorPlugin::_is_staging_area_empty() {868return staged_files->get_root()->get_child_count() == 0;869}870871void VersionControlEditorPlugin::_commit_message_gui_input(const Ref<InputEvent> &p_event) {872if (!commit_message->has_focus()) {873return;874}875if (commit_message->get_text().strip_edges().is_empty()) {876// Do not allow empty commit messages.877return;878}879const Ref<InputEventKey> k = p_event;880881if (k.is_valid() && k->is_pressed()) {882if (ED_IS_SHORTCUT("version_control/commit", p_event)) {883if (_is_staging_area_empty()) {884// Stage all files only when no files were previously staged.885_move_all(unstaged_files);886}887888_commit();889890commit_message->accept_event();891}892}893}894895void VersionControlEditorPlugin::_toggle_vcs_integration(bool p_toggled) {896if (p_toggled) {897_initialize_vcs();898} else {899shut_down();900}901}902903void VersionControlEditorPlugin::fetch_available_vcs_plugin_names() {904available_plugins.clear();905ClassDB::get_direct_inheriters_from_class(EditorVCSInterface::get_class_static(), &available_plugins);906}907908void VersionControlEditorPlugin::register_editor() {909EditorDockManager::get_singleton()->add_dock(version_commit_dock, "", EditorDockManager::DOCK_SLOT_RIGHT_UL, ED_SHORTCUT_AND_COMMAND("docks/open_version_control", TTRC("Open Version Control Dock")));910911version_control_dock_button = EditorNode::get_bottom_panel()->add_item(TTRC("Version Control"), version_control_dock, ED_SHORTCUT_AND_COMMAND("bottom_panels/toggle_version_control_bottom_panel", TTRC("Toggle Version Control Bottom Panel")));912913_set_vcs_ui_state(true);914}915916void VersionControlEditorPlugin::shut_down() {917if (!EditorVCSInterface::get_singleton()) {918return;919}920921if (EditorFileSystem::get_singleton()->is_connected(SNAME("filesystem_changed"), callable_mp(this, &VersionControlEditorPlugin::_refresh_stage_area))) {922EditorFileSystem::get_singleton()->disconnect(SNAME("filesystem_changed"), callable_mp(this, &VersionControlEditorPlugin::_refresh_stage_area));923}924925EditorVCSInterface::get_singleton()->shut_down();926memdelete(EditorVCSInterface::get_singleton());927EditorVCSInterface::set_singleton(nullptr);928929EditorDockManager::get_singleton()->remove_dock(version_commit_dock);930EditorNode::get_bottom_panel()->remove_item(version_control_dock);931932_set_vcs_ui_state(false);933}934935VersionControlEditorPlugin::VersionControlEditorPlugin() {936singleton = this;937938version_control_actions = memnew(PopupMenu);939940metadata_dialog = memnew(ConfirmationDialog);941metadata_dialog->set_title(TTR("Create Version Control Metadata"));942metadata_dialog->set_min_size(Size2(200, 40));943metadata_dialog->get_ok_button()->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_create_vcs_metadata_files));944EditorInterface::get_singleton()->get_base_control()->add_child(metadata_dialog);945946VBoxContainer *metadata_vb = memnew(VBoxContainer);947metadata_dialog->add_child(metadata_vb);948949HBoxContainer *metadata_hb = memnew(HBoxContainer);950metadata_hb->set_custom_minimum_size(Size2(200, 20));951metadata_vb->add_child(metadata_hb);952953Label *l = memnew(Label);954l->set_text(TTR("Create VCS metadata files for:"));955metadata_hb->add_child(l);956957metadata_selection = memnew(OptionButton);958metadata_selection->set_custom_minimum_size(Size2(100, 20));959metadata_selection->add_item("None", (int)EditorVCSInterface::VCSMetadata::NONE);960metadata_selection->add_item("Git", (int)EditorVCSInterface::VCSMetadata::GIT);961metadata_selection->select((int)EditorVCSInterface::VCSMetadata::GIT);962metadata_hb->add_child(metadata_selection);963964l = memnew(Label);965l->set_text(TTR("Existing VCS metadata files will be overwritten."));966metadata_vb->add_child(l);967968set_up_dialog = memnew(AcceptDialog);969set_up_dialog->set_title(TTR("Local Settings"));970set_up_dialog->set_min_size(Size2(600, 100));971set_up_dialog->add_cancel_button("Cancel");972set_up_dialog->set_hide_on_ok(true);973EditorInterface::get_singleton()->get_base_control()->add_child(set_up_dialog);974975Button *set_up_apply_button = set_up_dialog->get_ok_button();976set_up_apply_button->set_text(TTR("Apply"));977set_up_apply_button->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_set_credentials));978979set_up_vbc = memnew(VBoxContainer);980set_up_vbc->set_alignment(BoxContainer::ALIGNMENT_CENTER);981set_up_dialog->add_child(set_up_vbc);982983HBoxContainer *set_up_hbc = memnew(HBoxContainer);984set_up_hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);985set_up_vbc->add_child(set_up_hbc);986987Label *set_up_vcs_label = memnew(Label);988set_up_vcs_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);989set_up_vcs_label->set_text(TTR("VCS Provider"));990set_up_hbc->add_child(set_up_vcs_label);991992set_up_choice = memnew(OptionButton);993set_up_choice->set_h_size_flags(Control::SIZE_EXPAND_FILL);994set_up_hbc->add_child(set_up_choice);995996HBoxContainer *toggle_vcs_hbc = memnew(HBoxContainer);997toggle_vcs_hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);998set_up_vbc->add_child(toggle_vcs_hbc);9991000Label *toggle_vcs_label = memnew(Label);1001toggle_vcs_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);1002toggle_vcs_label->set_text(TTR("Connect to VCS"));1003toggle_vcs_hbc->add_child(toggle_vcs_label);10041005toggle_vcs_choice = memnew(CheckButton);1006toggle_vcs_choice->set_h_size_flags(Control::SIZE_EXPAND_FILL);1007toggle_vcs_choice->set_pressed_no_signal(false);1008toggle_vcs_choice->connect(SceneStringName(toggled), callable_mp(this, &VersionControlEditorPlugin::_toggle_vcs_integration));1009toggle_vcs_hbc->add_child(toggle_vcs_choice);10101011set_up_vbc->add_child(memnew(HSeparator));10121013set_up_settings_vbc = memnew(VBoxContainer);1014set_up_settings_vbc->set_alignment(BoxContainer::ALIGNMENT_CENTER);1015set_up_vbc->add_child(set_up_settings_vbc);10161017Label *remote_login = memnew(Label);1018remote_login->set_h_size_flags(Control::SIZE_EXPAND_FILL);1019remote_login->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);1020remote_login->set_text(TTR("Remote Login"));1021set_up_settings_vbc->add_child(remote_login);10221023HBoxContainer *set_up_username_input = memnew(HBoxContainer);1024set_up_username_input->set_h_size_flags(Control::SIZE_EXPAND_FILL);1025set_up_settings_vbc->add_child(set_up_username_input);10261027Label *set_up_username_label = memnew(Label);1028set_up_username_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);1029set_up_username_label->set_text(TTR("Username"));1030set_up_username_input->add_child(set_up_username_label);10311032set_up_username = memnew(LineEdit);1033set_up_username->set_h_size_flags(Control::SIZE_EXPAND_FILL);1034set_up_username->set_text(EDITOR_GET("version_control/username"));1035set_up_username->connect(SceneStringName(text_changed), callable_mp(this, &VersionControlEditorPlugin::_update_set_up_warning));1036set_up_username_input->add_child(set_up_username);10371038HBoxContainer *set_up_password_input = memnew(HBoxContainer);1039set_up_password_input->set_h_size_flags(Control::SIZE_EXPAND_FILL);1040set_up_settings_vbc->add_child(set_up_password_input);10411042Label *set_up_password_label = memnew(Label);1043set_up_password_label->set_text(TTR("Password"));1044set_up_password_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);1045set_up_password_input->add_child(set_up_password_label);10461047set_up_password = memnew(LineEdit);1048set_up_password->set_h_size_flags(Control::SIZE_EXPAND_FILL);1049set_up_password->set_secret(true);1050set_up_password->connect(SceneStringName(text_changed), callable_mp(this, &VersionControlEditorPlugin::_update_set_up_warning));1051set_up_password_input->add_child(set_up_password);10521053const String home_dir = OS::get_singleton()->has_environment("HOME") ? OS::get_singleton()->get_environment("HOME") : OS::get_singleton()->get_system_dir(OS::SYSTEM_DIR_DOCUMENTS);10541055HBoxContainer *set_up_ssh_public_key_input = memnew(HBoxContainer);1056set_up_ssh_public_key_input->set_h_size_flags(Control::SIZE_EXPAND_FILL);1057set_up_settings_vbc->add_child(set_up_ssh_public_key_input);10581059Label *set_up_ssh_public_key_label = memnew(Label);1060set_up_ssh_public_key_label->set_text(TTR("SSH Public Key Path"));1061set_up_ssh_public_key_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);1062set_up_ssh_public_key_input->add_child(set_up_ssh_public_key_label);10631064HBoxContainer *set_up_ssh_public_key_input_hbc = memnew(HBoxContainer);1065set_up_ssh_public_key_input_hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);1066set_up_ssh_public_key_input->add_child(set_up_ssh_public_key_input_hbc);10671068set_up_ssh_public_key_path = memnew(LineEdit);1069set_up_ssh_public_key_path->set_h_size_flags(Control::SIZE_EXPAND_FILL);1070set_up_ssh_public_key_path->set_accessibility_name(TTRC("SSH Public Key Path"));1071set_up_ssh_public_key_path->set_text(EDITOR_GET("version_control/ssh_public_key_path"));1072set_up_ssh_public_key_path->connect(SceneStringName(text_changed), callable_mp(this, &VersionControlEditorPlugin::_update_set_up_warning));1073set_up_ssh_public_key_input_hbc->add_child(set_up_ssh_public_key_path);10741075set_up_ssh_public_key_file_dialog = memnew(FileDialog);1076set_up_ssh_public_key_file_dialog->set_access(FileDialog::ACCESS_FILESYSTEM);1077set_up_ssh_public_key_file_dialog->set_file_mode(FileDialog::FILE_MODE_OPEN_FILE);1078set_up_ssh_public_key_file_dialog->set_show_hidden_files(true);1079set_up_ssh_public_key_file_dialog->set_current_dir(home_dir);1080set_up_ssh_public_key_file_dialog->connect(SNAME("file_selected"), callable_mp(this, &VersionControlEditorPlugin::_ssh_public_key_selected));1081set_up_ssh_public_key_input_hbc->add_child(set_up_ssh_public_key_file_dialog);10821083Button *select_public_path_button = memnew(Button);1084select_public_path_button->set_button_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon("Folder"));1085select_public_path_button->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_popup_file_dialog).bind(set_up_ssh_public_key_file_dialog));1086select_public_path_button->set_tooltip_text(TTR("Select SSH public key path"));1087select_public_path_button->set_accessibility_name(TTRC("Select SSH public key path"));1088set_up_ssh_public_key_input_hbc->add_child(select_public_path_button);10891090HBoxContainer *set_up_ssh_private_key_input = memnew(HBoxContainer);1091set_up_ssh_private_key_input->set_h_size_flags(Control::SIZE_EXPAND_FILL);1092set_up_settings_vbc->add_child(set_up_ssh_private_key_input);10931094Label *set_up_ssh_private_key_label = memnew(Label);1095set_up_ssh_private_key_label->set_text(TTR("SSH Private Key Path"));1096set_up_ssh_private_key_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);1097set_up_ssh_private_key_input->add_child(set_up_ssh_private_key_label);10981099HBoxContainer *set_up_ssh_private_key_input_hbc = memnew(HBoxContainer);1100set_up_ssh_private_key_input_hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);1101set_up_ssh_private_key_input->add_child(set_up_ssh_private_key_input_hbc);11021103set_up_ssh_private_key_path = memnew(LineEdit);1104set_up_ssh_private_key_path->set_h_size_flags(Control::SIZE_EXPAND_FILL);1105set_up_ssh_private_key_path->set_text(EDITOR_GET("version_control/ssh_private_key_path"));1106set_up_ssh_private_key_path->connect(SceneStringName(text_changed), callable_mp(this, &VersionControlEditorPlugin::_update_set_up_warning));1107set_up_ssh_private_key_path->set_accessibility_name(TTRC("SSH Private Key Path"));1108set_up_ssh_private_key_input_hbc->add_child(set_up_ssh_private_key_path);11091110set_up_ssh_private_key_file_dialog = memnew(FileDialog);1111set_up_ssh_private_key_file_dialog->set_access(FileDialog::ACCESS_FILESYSTEM);1112set_up_ssh_private_key_file_dialog->set_file_mode(FileDialog::FILE_MODE_OPEN_FILE);1113set_up_ssh_private_key_file_dialog->set_show_hidden_files(true);1114set_up_ssh_private_key_file_dialog->set_current_dir(home_dir);1115set_up_ssh_private_key_file_dialog->connect("file_selected", callable_mp(this, &VersionControlEditorPlugin::_ssh_private_key_selected));1116set_up_ssh_private_key_input_hbc->add_child(set_up_ssh_private_key_file_dialog);11171118Button *select_private_path_button = memnew(Button);1119select_private_path_button->set_button_icon(EditorNode::get_singleton()->get_gui_base()->get_editor_theme_icon("Folder"));1120select_private_path_button->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_popup_file_dialog).bind(set_up_ssh_private_key_file_dialog));1121select_private_path_button->set_tooltip_text(TTR("Select SSH private key path"));1122set_up_ssh_private_key_input_hbc->add_child(select_private_path_button);11231124HBoxContainer *set_up_ssh_passphrase_input = memnew(HBoxContainer);1125set_up_ssh_passphrase_input->set_h_size_flags(Control::SIZE_EXPAND_FILL);1126set_up_settings_vbc->add_child(set_up_ssh_passphrase_input);11271128Label *set_up_ssh_passphrase_label = memnew(Label);1129set_up_ssh_passphrase_label->set_text(TTR("SSH Passphrase"));1130set_up_ssh_passphrase_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);1131set_up_ssh_passphrase_input->add_child(set_up_ssh_passphrase_label);11321133set_up_ssh_passphrase = memnew(LineEdit);1134set_up_ssh_passphrase->set_h_size_flags(Control::SIZE_EXPAND_FILL);1135set_up_ssh_passphrase->set_secret(true);1136set_up_ssh_passphrase->connect(SceneStringName(text_changed), callable_mp(this, &VersionControlEditorPlugin::_update_set_up_warning));1137set_up_ssh_passphrase->set_accessibility_name(TTRC("SSH Passphrase"));1138set_up_ssh_passphrase_input->add_child(set_up_ssh_passphrase);11391140set_up_warning_text = memnew(Label);1141set_up_warning_text->set_focus_mode(Control::FOCUS_ACCESSIBILITY);1142set_up_warning_text->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_CENTER);1143set_up_warning_text->set_h_size_flags(Control::SIZE_EXPAND_FILL);1144set_up_settings_vbc->add_child(set_up_warning_text);11451146version_commit_dock = memnew(VBoxContainer);1147version_commit_dock->set_visible(false);1148version_commit_dock->set_name(TTR("Commit"));11491150VBoxContainer *unstage_area = memnew(VBoxContainer);1151unstage_area->set_v_size_flags(Control::SIZE_EXPAND_FILL);1152unstage_area->set_h_size_flags(Control::SIZE_EXPAND_FILL);1153version_commit_dock->add_child(unstage_area);11541155HBoxContainer *unstage_title = memnew(HBoxContainer);1156unstage_area->add_child(unstage_title);11571158Label *unstage_label = memnew(Label);1159unstage_label->set_text(TTR("Unstaged Changes"));1160unstage_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);1161unstage_title->add_child(unstage_label);11621163refresh_button = memnew(Button);1164refresh_button->set_tooltip_text(TTR("Detect new changes"));1165refresh_button->set_theme_type_variation(SceneStringName(FlatButton));1166refresh_button->set_button_icon(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("Reload"), EditorStringName(EditorIcons)));1167refresh_button->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_refresh_stage_area));1168refresh_button->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_refresh_commit_list));1169refresh_button->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_refresh_branch_list));1170refresh_button->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_refresh_remote_list));1171unstage_title->add_child(refresh_button);11721173discard_all_confirm = memnew(AcceptDialog);1174discard_all_confirm->set_title(TTR("Discard all changes"));1175discard_all_confirm->set_min_size(Size2i(400, 50));1176discard_all_confirm->set_text(TTR("This operation is IRREVERSIBLE. Your changes will be deleted FOREVER."));1177discard_all_confirm->set_hide_on_ok(true);1178discard_all_confirm->set_ok_button_text(TTR("Permanentally delete my changes"));1179discard_all_confirm->add_cancel_button();1180version_commit_dock->add_child(discard_all_confirm);11811182discard_all_confirm->get_ok_button()->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_discard_all));11831184discard_all_button = memnew(Button);1185discard_all_button->set_tooltip_text(TTR("Discard all changes"));1186discard_all_button->set_button_icon(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("Close"), EditorStringName(EditorIcons)));1187discard_all_button->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_confirm_discard_all));1188discard_all_button->set_theme_type_variation(SceneStringName(FlatButton));1189unstage_title->add_child(discard_all_button);11901191stage_all_button = memnew(Button);1192stage_all_button->set_accessibility_name(TTRC("Stage all changes"));1193stage_all_button->set_theme_type_variation(SceneStringName(FlatButton));1194stage_all_button->set_button_icon(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("MoveDown"), EditorStringName(EditorIcons)));1195stage_all_button->set_tooltip_text(TTR("Stage all changes"));1196unstage_title->add_child(stage_all_button);11971198unstaged_files = memnew(Tree);1199unstaged_files->set_h_size_flags(Tree::SIZE_EXPAND_FILL);1200unstaged_files->set_v_size_flags(Tree::SIZE_EXPAND_FILL);1201unstaged_files->set_select_mode(Tree::SELECT_ROW);1202unstaged_files->connect(SceneStringName(item_selected), callable_mp(this, &VersionControlEditorPlugin::_load_diff).bind(unstaged_files));1203unstaged_files->connect(SNAME("item_activated"), callable_mp(this, &VersionControlEditorPlugin::_item_activated).bind(unstaged_files));1204unstaged_files->connect(SNAME("button_clicked"), callable_mp(this, &VersionControlEditorPlugin::_cell_button_pressed));1205unstaged_files->create_item();1206unstaged_files->set_hide_root(true);1207unstage_area->add_child(unstaged_files);12081209VBoxContainer *stage_area = memnew(VBoxContainer);1210stage_area->set_v_size_flags(Control::SIZE_EXPAND_FILL);1211stage_area->set_h_size_flags(Control::SIZE_EXPAND_FILL);1212version_commit_dock->add_child(stage_area);12131214HBoxContainer *stage_title = memnew(HBoxContainer);1215stage_area->add_child(stage_title);12161217Label *stage_label = memnew(Label);1218stage_label->set_text(TTR("Staged Changes"));1219stage_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);1220stage_title->add_child(stage_label);12211222unstage_all_button = memnew(Button);1223unstage_all_button->set_accessibility_name(TTRC("Unstage all changes"));1224unstage_all_button->set_theme_type_variation(SceneStringName(FlatButton));1225unstage_all_button->set_button_icon(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("MoveUp"), EditorStringName(EditorIcons)));1226unstage_all_button->set_tooltip_text(TTR("Unstage all changes"));1227stage_title->add_child(unstage_all_button);12281229staged_files = memnew(Tree);1230staged_files->set_h_size_flags(Tree::SIZE_EXPAND_FILL);1231staged_files->set_v_size_flags(Tree::SIZE_EXPAND_FILL);1232staged_files->set_select_mode(Tree::SELECT_ROW);1233staged_files->connect(SceneStringName(item_selected), callable_mp(this, &VersionControlEditorPlugin::_load_diff).bind(staged_files));1234staged_files->connect(SNAME("button_clicked"), callable_mp(this, &VersionControlEditorPlugin::_cell_button_pressed));1235staged_files->connect(SNAME("item_activated"), callable_mp(this, &VersionControlEditorPlugin::_item_activated).bind(staged_files));1236staged_files->create_item();1237staged_files->set_hide_root(true);1238stage_area->add_child(staged_files);12391240// Editor crashes if bind is null1241unstage_all_button->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_move_all).bind(staged_files));1242stage_all_button->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_move_all).bind(unstaged_files));12431244version_commit_dock->add_child(memnew(HSeparator));12451246VBoxContainer *commit_area = memnew(VBoxContainer);1247version_commit_dock->add_child(commit_area);12481249Label *commit_label = memnew(Label);1250commit_label->set_text(TTR("Commit Message"));1251commit_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);1252commit_area->add_child(commit_label);12531254commit_message = memnew(TextEdit);1255commit_message->set_accessibility_name(TTRC("Commit Message"));1256commit_message->set_h_size_flags(Control::SIZE_EXPAND_FILL);1257commit_message->set_h_grow_direction(Control::GrowDirection::GROW_DIRECTION_BEGIN);1258commit_message->set_v_grow_direction(Control::GrowDirection::GROW_DIRECTION_END);1259commit_message->set_custom_minimum_size(Size2(200, 100));1260commit_message->set_line_wrapping_mode(TextEdit::LINE_WRAPPING_BOUNDARY);1261commit_message->connect(SceneStringName(text_changed), callable_mp(this, &VersionControlEditorPlugin::_update_commit_button));1262commit_message->connect(SceneStringName(gui_input), callable_mp(this, &VersionControlEditorPlugin::_commit_message_gui_input));1263commit_area->add_child(commit_message);12641265ED_SHORTCUT("version_control/commit", TTRC("Commit"), KeyModifierMask::CMD_OR_CTRL | Key::ENTER);12661267commit_button = memnew(Button);1268commit_button->set_text(TTR("Commit Changes"));1269commit_button->set_disabled(true);1270commit_button->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_commit));1271commit_area->add_child(commit_button);12721273version_commit_dock->add_child(memnew(HSeparator));12741275HBoxContainer *commit_list_hbc = memnew(HBoxContainer);1276version_commit_dock->add_child(commit_list_hbc);12771278Label *commit_list_label = memnew(Label);1279commit_list_label->set_text(TTR("Commit List"));1280commit_list_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);1281commit_list_hbc->add_child(commit_list_label);12821283commit_list_size_button = memnew(OptionButton);1284commit_list_size_button->set_tooltip_text(TTR("Commit list size"));1285commit_list_size_button->add_item("10");1286commit_list_size_button->set_item_metadata(0, 10);1287commit_list_size_button->add_item("20");1288commit_list_size_button->set_item_metadata(1, 20);1289commit_list_size_button->add_item("30");1290commit_list_size_button->set_item_metadata(2, 30);1291commit_list_size_button->connect(SceneStringName(item_selected), callable_mp(this, &VersionControlEditorPlugin::_set_commit_list_size));1292commit_list_hbc->add_child(commit_list_size_button);12931294commit_list = memnew(Tree);1295commit_list->set_h_size_flags(Control::SIZE_EXPAND_FILL);1296commit_list->set_v_grow_direction(Control::GrowDirection::GROW_DIRECTION_END);1297commit_list->set_custom_minimum_size(Size2(200, 160));1298commit_list->create_item();1299commit_list->set_hide_root(true);1300commit_list->set_select_mode(Tree::SELECT_ROW);1301commit_list->set_columns(2); // Commit msg, author1302commit_list->set_column_custom_minimum_width(0, 40);1303commit_list->set_column_custom_minimum_width(1, 20);1304commit_list->set_theme_type_variation("TreeSecondary");1305commit_list->connect(SceneStringName(item_selected), callable_mp(this, &VersionControlEditorPlugin::_load_diff).bind(commit_list));1306version_commit_dock->add_child(commit_list);13071308version_commit_dock->add_child(memnew(HSeparator));13091310HFlowContainer *menu_bar = memnew(HFlowContainer);1311menu_bar->set_h_size_flags(Control::SIZE_EXPAND_FILL);1312menu_bar->set_v_size_flags(Control::SIZE_FILL);1313version_commit_dock->add_child(menu_bar);13141315branch_select = memnew(OptionButton);1316branch_select->set_tooltip_text(TTR("Branches"));1317branch_select->set_h_size_flags(Control::SIZE_EXPAND_FILL);1318branch_select->set_clip_text(true);1319branch_select->connect(SceneStringName(item_selected), callable_mp(this, &VersionControlEditorPlugin::_branch_item_selected));1320branch_select->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_refresh_branch_list));1321menu_bar->add_child(branch_select);13221323branch_create_confirm = memnew(AcceptDialog);1324branch_create_confirm->set_title(TTR("Create New Branch"));1325branch_create_confirm->set_min_size(Size2(400, 100));1326branch_create_confirm->set_hide_on_ok(true);1327version_commit_dock->add_child(branch_create_confirm);13281329branch_create_ok = branch_create_confirm->get_ok_button();1330branch_create_ok->set_text(TTR("Create"));1331branch_create_ok->set_disabled(true);1332branch_create_ok->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_create_branch));13331334branch_remove_confirm = memnew(AcceptDialog);1335branch_remove_confirm->set_title(TTR("Remove Branch"));1336branch_remove_confirm->add_cancel_button();1337version_commit_dock->add_child(branch_remove_confirm);13381339Button *branch_remove_ok = branch_remove_confirm->get_ok_button();1340branch_remove_ok->set_text(TTR("Remove"));1341branch_remove_ok->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_remove_branch));13421343VBoxContainer *branch_create_vbc = memnew(VBoxContainer);1344branch_create_vbc->set_alignment(BoxContainer::ALIGNMENT_CENTER);1345branch_create_confirm->add_child(branch_create_vbc);13461347HBoxContainer *branch_create_hbc = memnew(HBoxContainer);1348branch_create_hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);1349branch_create_vbc->add_child(branch_create_hbc);13501351Label *branch_create_name_label = memnew(Label);1352branch_create_name_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);1353branch_create_name_label->set_text(TTR("Branch Name"));1354branch_create_hbc->add_child(branch_create_name_label);13551356branch_create_name_input = memnew(LineEdit);1357branch_create_name_input->set_accessibility_name(TTRC("Branch Name"));1358branch_create_name_input->set_h_size_flags(Control::SIZE_EXPAND_FILL);1359branch_create_name_input->connect(SceneStringName(text_changed), callable_mp(this, &VersionControlEditorPlugin::_update_branch_create_button));1360branch_create_hbc->add_child(branch_create_name_input);13611362remote_select = memnew(OptionButton);1363remote_select->set_tooltip_text(TTR("Remotes"));1364remote_select->set_h_size_flags(Control::SIZE_EXPAND_FILL);1365remote_select->set_clip_text(true);1366remote_select->connect(SceneStringName(item_selected), callable_mp(this, &VersionControlEditorPlugin::_remote_selected));1367remote_select->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_refresh_remote_list));1368menu_bar->add_child(remote_select);13691370remote_create_confirm = memnew(AcceptDialog);1371remote_create_confirm->set_title(TTR("Create New Remote"));1372remote_create_confirm->set_min_size(Size2(400, 100));1373remote_create_confirm->set_hide_on_ok(true);1374version_commit_dock->add_child(remote_create_confirm);13751376remote_create_ok = remote_create_confirm->get_ok_button();1377remote_create_ok->set_text(TTR("Create"));1378remote_create_ok->set_disabled(true);1379remote_create_ok->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_create_remote));13801381remote_remove_confirm = memnew(AcceptDialog);1382remote_remove_confirm->set_title(TTR("Remove Remote"));1383remote_remove_confirm->add_cancel_button();1384version_commit_dock->add_child(remote_remove_confirm);13851386Button *remote_remove_ok = remote_remove_confirm->get_ok_button();1387remote_remove_ok->set_text(TTR("Remove"));1388remote_remove_ok->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_remove_remote));13891390VBoxContainer *remote_create_vbc = memnew(VBoxContainer);1391remote_create_vbc->set_alignment(BoxContainer::ALIGNMENT_CENTER);1392remote_create_confirm->add_child(remote_create_vbc);13931394HBoxContainer *remote_create_name_hbc = memnew(HBoxContainer);1395remote_create_name_hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);1396remote_create_vbc->add_child(remote_create_name_hbc);13971398Label *remote_create_name_label = memnew(Label);1399remote_create_name_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);1400remote_create_name_label->set_text(TTR("Remote Name"));1401remote_create_name_hbc->add_child(remote_create_name_label);14021403remote_create_name_input = memnew(LineEdit);1404remote_create_name_input->set_accessibility_name(TTRC("Remote Name"));1405remote_create_name_input->set_h_size_flags(Control::SIZE_EXPAND_FILL);1406remote_create_name_input->connect(SceneStringName(text_changed), callable_mp(this, &VersionControlEditorPlugin::_update_remote_create_button));1407remote_create_name_hbc->add_child(remote_create_name_input);14081409HBoxContainer *remote_create_hbc = memnew(HBoxContainer);1410remote_create_hbc->set_h_size_flags(Control::SIZE_EXPAND_FILL);1411remote_create_vbc->add_child(remote_create_hbc);14121413Label *remote_create_url_label = memnew(Label);1414remote_create_url_label->set_h_size_flags(Control::SIZE_EXPAND_FILL);1415remote_create_url_label->set_text(TTR("Remote URL"));1416remote_create_hbc->add_child(remote_create_url_label);14171418remote_create_url_input = memnew(LineEdit);1419remote_create_url_input->set_accessibility_name(TTRC("Remote URL"));1420remote_create_url_input->set_h_size_flags(Control::SIZE_EXPAND_FILL);1421remote_create_url_input->connect(SceneStringName(text_changed), callable_mp(this, &VersionControlEditorPlugin::_update_remote_create_button));1422remote_create_hbc->add_child(remote_create_url_input);14231424fetch_button = memnew(Button);1425fetch_button->set_theme_type_variation(SceneStringName(FlatButton));1426fetch_button->set_tooltip_text(TTR("Fetch"));1427fetch_button->set_button_icon(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("Reload"), EditorStringName(EditorIcons)));1428fetch_button->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_fetch));1429menu_bar->add_child(fetch_button);14301431pull_button = memnew(Button);1432pull_button->set_theme_type_variation(SceneStringName(FlatButton));1433pull_button->set_tooltip_text(TTR("Pull"));1434pull_button->set_button_icon(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("MoveDown"), EditorStringName(EditorIcons)));1435pull_button->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_pull));1436menu_bar->add_child(pull_button);14371438push_button = memnew(Button);1439push_button->set_theme_type_variation(SceneStringName(FlatButton));1440push_button->set_tooltip_text(TTR("Push"));1441push_button->set_button_icon(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("MoveUp"), EditorStringName(EditorIcons)));1442push_button->connect(SceneStringName(pressed), callable_mp(this, &VersionControlEditorPlugin::_push));1443menu_bar->add_child(push_button);14441445extra_options = memnew(MenuButton);1446extra_options->set_accessibility_name(TTRC("Extra options"));1447extra_options->set_button_icon(EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("GuiTabMenuHl"), EditorStringName(EditorIcons)));1448extra_options->get_popup()->connect(SNAME("about_to_popup"), callable_mp(this, &VersionControlEditorPlugin::_update_extra_options));1449extra_options->get_popup()->connect(SceneStringName(id_pressed), callable_mp(this, &VersionControlEditorPlugin::_extra_option_selected));1450menu_bar->add_child(extra_options);14511452extra_options->get_popup()->add_item(TTR("Force Push"), EXTRA_OPTION_FORCE_PUSH);1453extra_options->get_popup()->add_separator();1454extra_options->get_popup()->add_item(TTR("Create New Branch"), EXTRA_OPTION_CREATE_BRANCH);14551456extra_options_remove_branch_list = memnew(PopupMenu);1457extra_options_remove_branch_list->connect(SceneStringName(id_pressed), callable_mp(this, &VersionControlEditorPlugin::_popup_branch_remove_confirm));1458extra_options->get_popup()->add_submenu_node_item(TTR("Remove Branch"), extra_options_remove_branch_list);14591460extra_options->get_popup()->add_separator();1461extra_options->get_popup()->add_item(TTR("Create New Remote"), EXTRA_OPTION_CREATE_REMOTE);14621463extra_options_remove_remote_list = memnew(PopupMenu);1464extra_options_remove_remote_list->connect(SceneStringName(id_pressed), callable_mp(this, &VersionControlEditorPlugin::_popup_remote_remove_confirm));1465extra_options->get_popup()->add_submenu_node_item(TTR("Remove Remote"), extra_options_remove_remote_list);14661467change_type_to_strings[EditorVCSInterface::CHANGE_TYPE_NEW] = TTR("New");1468change_type_to_strings[EditorVCSInterface::CHANGE_TYPE_MODIFIED] = TTR("Modified");1469change_type_to_strings[EditorVCSInterface::CHANGE_TYPE_RENAMED] = TTR("Renamed");1470change_type_to_strings[EditorVCSInterface::CHANGE_TYPE_DELETED] = TTR("Deleted");1471change_type_to_strings[EditorVCSInterface::CHANGE_TYPE_TYPECHANGE] = TTR("Typechange");1472change_type_to_strings[EditorVCSInterface::CHANGE_TYPE_UNMERGED] = TTR("Unmerged");14731474change_type_to_color[EditorVCSInterface::CHANGE_TYPE_NEW] = EditorNode::get_singleton()->get_editor_theme()->get_color(SNAME("success_color"), EditorStringName(Editor));1475change_type_to_color[EditorVCSInterface::CHANGE_TYPE_MODIFIED] = EditorNode::get_singleton()->get_editor_theme()->get_color(SNAME("warning_color"), EditorStringName(Editor));1476change_type_to_color[EditorVCSInterface::CHANGE_TYPE_RENAMED] = EditorNode::get_singleton()->get_editor_theme()->get_color(SNAME("warning_color"), EditorStringName(Editor));1477change_type_to_color[EditorVCSInterface::CHANGE_TYPE_DELETED] = EditorNode::get_singleton()->get_editor_theme()->get_color(SNAME("error_color"), EditorStringName(Editor));1478change_type_to_color[EditorVCSInterface::CHANGE_TYPE_TYPECHANGE] = EditorNode::get_singleton()->get_editor_theme()->get_color(SceneStringName(font_color), EditorStringName(Editor));1479change_type_to_color[EditorVCSInterface::CHANGE_TYPE_UNMERGED] = EditorNode::get_singleton()->get_editor_theme()->get_color(SNAME("warning_color"), EditorStringName(Editor));14801481change_type_to_icon[EditorVCSInterface::CHANGE_TYPE_NEW] = EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("StatusSuccess"), EditorStringName(EditorIcons));1482change_type_to_icon[EditorVCSInterface::CHANGE_TYPE_MODIFIED] = EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("StatusWarning"), EditorStringName(EditorIcons));1483change_type_to_icon[EditorVCSInterface::CHANGE_TYPE_RENAMED] = EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("StatusWarning"), EditorStringName(EditorIcons));1484change_type_to_icon[EditorVCSInterface::CHANGE_TYPE_TYPECHANGE] = EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("StatusWarning"), EditorStringName(EditorIcons));1485change_type_to_icon[EditorVCSInterface::CHANGE_TYPE_DELETED] = EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("StatusError"), EditorStringName(EditorIcons));1486change_type_to_icon[EditorVCSInterface::CHANGE_TYPE_UNMERGED] = EditorNode::get_singleton()->get_editor_theme()->get_icon(SNAME("StatusWarning"), EditorStringName(EditorIcons));14871488version_control_dock = memnew(VBoxContainer);1489version_control_dock->set_v_size_flags(Control::SIZE_EXPAND_FILL);1490version_control_dock->set_custom_minimum_size(Size2(0, 300) * EDSCALE);1491version_control_dock->hide();14921493HBoxContainer *diff_heading = memnew(HBoxContainer);1494diff_heading->set_h_size_flags(Control::SIZE_EXPAND_FILL);1495diff_heading->set_tooltip_text(TTR("View file diffs before committing them to the latest version"));1496version_control_dock->add_child(diff_heading);14971498diff_title = memnew(Label);1499diff_title->set_focus_mode(Control::FOCUS_ACCESSIBILITY);1500diff_title->set_h_size_flags(Control::SIZE_EXPAND_FILL);1501diff_heading->add_child(diff_title);15021503Label *view = memnew(Label);1504view->set_text(TTR("View:"));1505diff_heading->add_child(view);15061507diff_view_type_select = memnew(OptionButton);1508diff_view_type_select->set_accessibility_name(TTRC("View:"));1509diff_view_type_select->add_item(TTR("Split"), DIFF_VIEW_TYPE_SPLIT);1510diff_view_type_select->add_item(TTR("Unified"), DIFF_VIEW_TYPE_UNIFIED);1511diff_view_type_select->connect(SceneStringName(item_selected), callable_mp(this, &VersionControlEditorPlugin::_display_diff));1512diff_heading->add_child(diff_view_type_select);15131514diff = memnew(RichTextLabel);1515diff->set_h_size_flags(TextEdit::SIZE_EXPAND_FILL);1516diff->set_v_size_flags(TextEdit::SIZE_EXPAND_FILL);1517diff->set_use_bbcode(true);1518diff->set_selection_enabled(true);1519diff->set_context_menu_enabled(true);1520version_control_dock->add_child(diff);15211522_update_set_up_warning("");1523}15241525VersionControlEditorPlugin::~VersionControlEditorPlugin() {1526shut_down();1527memdelete(version_commit_dock);1528memdelete(version_control_dock);1529memdelete(version_control_actions);1530}153115321533