VCS: Add push, pull, fetch and improved diff view to VCS UI

This commit was created by merging the commits presented in #39255 for
the GSoC 2020 VCS Improvement project

VCS: Make EditorVCSInterface store less amount of internal state

VCS: Add force push checkbox + more frequent VCS updates

Add force push checkbox in the Commit dock. Also add some missing
opportunities for checking the VCS state again on from UI inputs

VCS: Fix script contents not being updated on merge conflict

VCS: Add branch creation VCS interface calls

VCS: Add VCS remote creation and remote selection menus

VCS: Show more commit information + Fix truncated commit offsets

VCS: Make VCS less noisy + Fix diff view refreshes

VCS: Fix mismatched argument names in VCS helpers

VCS: Add SSH transport support for remote operations

Also, moves the editor's VCS settings registrations to
project_settings.cpp and editor_settings.cpp

VCS: Change TTR() to vformat() for branch and remote removal text

VCS: Add VCS branch icon instead of using Tree node icon

Co-authored-by: @ChronicallySerious
This commit is contained in:
janglee 2020-06-25 15:29:31 +05:30 committed by ChronicallySerious
parent fddbbf445b
commit 0b327eb46e
15 changed files with 1941 additions and 497 deletions

View file

@ -1061,6 +1061,9 @@ ProjectSettings::ProjectSettings() {
GLOBAL_DEF("editor/script_templates_search_path", "res://script_templates");
custom_prop_info["editor/script_templates_search_path"] = PropertyInfo(Variant::STRING, "editor/script_templates_search_path", PROPERTY_HINT_DIR);
GLOBAL_DEF("editor/version_control/autoload_on_startup", false);
GLOBAL_DEF("editor/version_control/plugin_name", "");
action = Dictionary();
action["deadzone"] = Variant(0.5f);
events = Array();

View file

@ -1,99 +1,275 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="EditorVCSInterface" inherits="Object" version="3.4">
<brief_description>
Version Control System (VCS) interface which reads and writes to the local VCS in use.
Version Control System (VCS) interface, which reads and writes to the local VCS in use.
</brief_description>
<description>
Used by the editor to display VCS extracted information in the editor. The implementation of this API is included in VCS addons, which are essentially GDNative plugins that need to be put into the project folder. These VCS addons are scripts which are attached (on demand) to the object instance of [code]EditorVCSInterface[/code]. All the functions listed below, instead of performing the task themselves, they call the internally defined functions in the VCS addons to provide a plug-n-play experience.
Defines the API that the editor uses to extract information from the underlying VCS. The implementation of this API is included in VCS plugins, which are scripts that inherit [EditorVCSInterface] and are attached (on demand) to the singleton instance of [EditorVCSInterface]. Instead of performing the task themselves, all the virtual functions listed below are calling the internally overridden functions in the VCS plugins to provide a plug-n-play experience. A custom VCS plugin is supposed to inherit from [EditorVCSInterface] and override these virtual functions.
</description>
<tutorials>
</tutorials>
<methods>
<method name="commit">
<method name="_checkout_branch" qualifiers="virtual">
<return type="bool" />
<argument index="0" name="branch_name" type="String" />
<description>
Checks out a [code]branch_name[/code] in the VCS.
</description>
</method>
<method name="_commit" qualifiers="virtual">
<return type="void" />
<argument index="0" name="msg" type="String" />
<description>
Creates a version commit if the addon is initialized, else returns without doing anything. Uses the files which have been staged previously, with the commit message set to a value as provided as in the argument.
Commits the currently staged changes and applies the commit [code]msg[/code] to the resulting commit.
</description>
</method>
<method name="get_file_diff">
<method name="_create_branch" qualifiers="virtual">
<return type="void" />
<argument index="0" name="branch_name" type="String" />
<description>
Creates a new branch named [code]branch_name[/code] in the VCS.
</description>
</method>
<method name="_create_remote" qualifiers="virtual">
<return type="void" />
<argument index="0" name="remote_name" type="String" />
<argument index="1" name="remote_url" type="String" />
<description>
Creates a new remote destination with name [code]remote_name[/code] and points it to [code]remote_url[/code]. This can be both an HTTPS remote or an SSH remote.
</description>
</method>
<method name="_discard_file" qualifiers="virtual">
<return type="void" />
<argument index="0" name="file_path" type="String" />
<description>
Discards the changes made in file present at [code]file_path[/code].
</description>
</method>
<method name="_fetch" qualifiers="virtual">
<return type="void" />
<argument index="0" name="remote" type="String" />
<description>
Fetches new changes from the remote, but doesn't write changes to the current working directory. Equivalent to [code]git fetch[/code].
</description>
</method>
<method name="_get_branch_list" qualifiers="virtual">
<return type="Array" />
<description>
Gets an instance of an [Array] of [String]s containing available branch names in the VCS.
</description>
</method>
<method name="_get_current_branch_name" qualifiers="virtual">
<return type="String" />
<description>
Gets the current branch name defined in the VCS.
</description>
</method>
<method name="_get_diff" qualifiers="virtual">
<return type="Array" />
<argument index="0" name="identifier" type="String" />
<argument index="1" name="area" type="int" />
<description>
Returns an [Array] of [Dictionary] items (see [method create_diff_file], [method create_diff_hunk], [method create_diff_line], [method add_line_diffs_into_diff_hunk] and [method add_diff_hunks_into_diff_file]), each containing information about a diff. If [code]identifier[/code] is a file path, returns a file diff, and if it is a commit identifier, then returns a commit diff.
</description>
</method>
<method name="_get_line_diff" qualifiers="virtual">
<return type="Array" />
<argument index="0" name="file_path" type="String" />
<argument index="1" name="text" type="String" />
<description>
Returns an [Array] of [Dictionary] objects containing the diff output from the VCS in use, if a VCS addon is initialized, else returns an empty [Array] object. The diff contents also consist of some contextual lines which provide context to the observed line change in the file.
Each [Dictionary] object has the line diff contents under the keys:
- [code]"content"[/code] to store a [String] containing the line contents
- [code]"status"[/code] to store a [String] which contains [code]"+"[/code] in case the content is a line addition but it stores a [code]"-"[/code] in case of deletion and an empty string in the case the line content is neither an addition nor a deletion.
- [code]"new_line_number"[/code] to store an integer containing the new line number of the line content.
- [code]"line_count"[/code] to store an integer containing the number of lines in the line content.
- [code]"old_line_number"[/code] to store an integer containing the old line number of the line content.
- [code]"offset"[/code] to store the offset of the line change since the first contextual line content.
Returns an [Array] of [Dictionary] items (see [method create_diff_hunk]), each containing a line diff between a file at [code]file_path[/code] and the [code]text[/code] which is passed in.
</description>
</method>
<method name="get_modified_files_data">
<method name="_get_modified_files_data" qualifiers="virtual">
<return type="Array" />
<description>
Returns an [Array] of [Dictionary] items (see [method create_status_file]), each containing the status data of every modified file in the project folder.
</description>
</method>
<method name="_get_previous_commits" qualifiers="virtual">
<return type="Array" />
<argument index="0" name="max_commits" type="int" />
<description>
Returns an [Array] of [Dictionary] items (see [method create_commit]), each containing the data for a past commit.
</description>
</method>
<method name="_get_remotes" qualifiers="virtual">
<return type="Array" />
<description>
Returns an [Array] of [String]s, each containing the name of a remote configured in the VCS.
</description>
</method>
<method name="_get_vcs_name" qualifiers="virtual">
<return type="String" />
<description>
Returns the name of the underlying VCS provider.
</description>
</method>
<method name="_initialize" qualifiers="virtual">
<return type="bool" />
<argument index="0" name="project_path" type="String" />
<description>
Initializes the VCS plugin when called from the editor. Returns whether or not the plugin was successfully initialized. A VCS project is initialized at [code]project_path[/code].
</description>
</method>
<method name="_pull" qualifiers="virtual">
<return type="void" />
<argument index="0" name="remote" type="String" />
<description>
Pulls changes from the remote. This can give rise to merge conflicts.
</description>
</method>
<method name="_push" qualifiers="virtual">
<return type="void" />
<argument index="0" name="remote" type="String" />
<argument index="1" name="force" type="bool" />
<description>
Pushes changes to the [code]remote[/code]. Optionally, if [code]force[/code] is set to true, a force push will override the change history already present on the remote.
</description>
</method>
<method name="_remove_branch" qualifiers="virtual">
<return type="void" />
<argument index="0" name="branch_name" type="String" />
<description>
Remove a branch from the local VCS.
</description>
</method>
<method name="_remove_remote" qualifiers="virtual">
<return type="void" />
<argument index="0" name="remote_name" type="String" />
<description>
Remove a remote from the local VCS.
</description>
</method>
<method name="_set_credentials" qualifiers="virtual">
<return type="void" />
<argument index="0" name="username" type="String" />
<argument index="1" name="password" type="String" />
<argument index="2" name="ssh_public_key_path" type="String" />
<argument index="3" name="ssh_private_key_path" type="String" />
<argument index="4" name="ssh_passphrase" type="String" />
<description>
Set user credentials in the underlying VCS. [code]username[/code] and [code]password[/code] are used only during HTTPS authentication unless not already mentioned in the remote URL. [code]ssh_public_key_path[/code], [code]ssh_private_key_path[/code], and [code]ssh_passphrase[/code] are only used during SSH authentication.
</description>
</method>
<method name="_shut_down" qualifiers="virtual">
<return type="bool" />
<description>
Shuts down VCS plugin instance. Called when the user either closes the editor or shuts down the VCS plugin through the editor UI.
</description>
</method>
<method name="_stage_file" qualifiers="virtual">
<return type="void" />
<argument index="0" name="file_path" type="String" />
<description>
Stages the file present at [code]file_path[/code] to the staged area.
</description>
</method>
<method name="_unstage_file" qualifiers="virtual">
<return type="void" />
<argument index="0" name="file_path" type="String" />
<description>
Unstages the file present at [code]file_path[/code] from the staged area to the unstaged area.
</description>
</method>
<method name="add_diff_hunks_into_diff_file">
<return type="Dictionary" />
<argument index="0" name="diff_file" type="Dictionary" />
<argument index="1" name="diff_hunks" type="Array" />
<description>
Returns a [Dictionary] containing the path of the detected file change mapped to an integer signifying what kind of change the corresponding file has experienced.
The following integer values are being used to signify that the detected file is:
- [code]0[/code]: New to the VCS working directory
- [code]1[/code]: Modified
- [code]2[/code]: Renamed
- [code]3[/code]: Deleted
- [code]4[/code]: Typechanged
Helper function to add an array of [code]diff_hunks[/code] into a [code]diff_file[/code].
</description>
</method>
<method name="get_project_name">
<return type="String" />
<method name="add_line_diffs_into_diff_hunk">
<return type="Dictionary" />
<argument index="0" name="diff_hunk" type="Dictionary" />
<argument index="1" name="line_diffs" type="Array" />
<description>
Returns the project name of the VCS working directory.
Helper function to add an array of [code]line_diffs[/code] into a [code]diff_hunk[/code].
</description>
</method>
<method name="get_vcs_name">
<return type="String" />
<method name="create_commit">
<return type="Dictionary" />
<argument index="0" name="msg" type="String" />
<argument index="1" name="author" type="String" />
<argument index="2" name="id" type="String" />
<argument index="3" name="date" type="String" />
<description>
Returns the name of the VCS if the VCS has been initialized, else return an empty string.
Helper function to create a commit [Dictionary] item. [code]msg[/code] is the commit message of the commit. [code]author[/code] is a human-readable string containing the author's details, e.g. the email and name configured in the VCS. [code]id[/code] is the identifier of the commit, in whichever format your VCS may provide an identifier to commits. [code]date[/code] is directly added to the commit item and displayed in the editor, and hence, it shall be a well-formatted, human-readable date string.
</description>
</method>
<method name="initialize">
<return type="bool" />
<argument index="0" name="project_root_path" type="String" />
<method name="create_diff_file">
<return type="Dictionary" />
<argument index="0" name="new_file" type="String" />
<argument index="1" name="old_file" type="String" />
<description>
Initializes the VCS addon if not already. Uses the argument value as the path to the working directory of the project. Creates the initial commit if required. Returns [code]true[/code] if no failure occurs, else returns [code]false[/code].
Helper function to create a [code]Dictionary[/code] for storing old and new diff file paths.
</description>
</method>
<method name="is_addon_ready">
<return type="bool" />
<method name="create_diff_hunk">
<return type="Dictionary" />
<argument index="0" name="old_start" type="int" />
<argument index="1" name="new_start" type="int" />
<argument index="2" name="old_lines" type="int" />
<argument index="3" name="new_lines" type="int" />
<description>
Returns [code]true[/code] if the addon is ready to respond to function calls, else returns [code]false[/code].
Helper function to create a [code]Dictionary[/code] for storing diff hunk data. [code]old_start[/code] is the starting line number in old file. [code]new_start[/code] is the starting line number in new file. [code]old_lines[/code] is the number of lines in the old file. [code]new_lines[/code] is the number of lines in the new file.
</description>
</method>
<method name="is_vcs_initialized">
<return type="bool" />
<method name="create_diff_line">
<return type="Dictionary" />
<argument index="0" name="new_line_no" type="int" />
<argument index="1" name="old_line_no" type="int" />
<argument index="2" name="content" type="String" />
<argument index="3" name="status" type="String" />
<description>
Returns [code]true[/code] if the VCS addon has been initialized, else returns [code]false[/code].
Helper function to create a [code]Dictionary[/code] for storing a line diff. [code]new_line_no[/code] is the line number in the new file (can be [code]-1[/code] if the line is deleted). [code]old_line_no[/code] is the line number in the old file (can be [code]-1[/code] if the line is added). [code]content[/code] is the diff text. [code]content[/code] is the diff text. [code]status[/code] is a single character string which stores the line origin.
</description>
</method>
<method name="shut_down">
<return type="bool" />
<description>
Shuts down the VCS addon to allow cleanup code to run on call. Returns [code]true[/code] is no failure occurs, else returns [code]false[/code].
</description>
</method>
<method name="stage_file">
<return type="void" />
<method name="create_status_file">
<return type="Dictionary" />
<argument index="0" name="file_path" type="String" />
<argument index="1" name="change_type" type="int" enum="EditorVCSInterface.ChangeType" />
<argument index="2" name="area" type="int" enum="EditorVCSInterface.TreeArea" />
<description>
Stages the file which should be committed when [method EditorVCSInterface.commit] is called. Argument should contain the absolute path.
Helper function to create a [code]Dictionary[/code] used by editor to read the status of a file.
</description>
</method>
<method name="unstage_file">
<method name="popup_error">
<return type="void" />
<argument index="0" name="file_path" type="String" />
<argument index="0" name="msg" type="String" />
<description>
Unstages the file which was staged previously to be committed, so that it is no longer committed when [method EditorVCSInterface.commit] is called. Argument should contain the absolute path.
Pops up an error message in the edior.
</description>
</method>
</methods>
<constants>
<constant name="CHANGE_TYPE_NEW" value="0" enum="ChangeType">
A new file has been added.
</constant>
<constant name="CHANGE_TYPE_MODIFIED" value="1" enum="ChangeType">
An earlier added file has been modified.
</constant>
<constant name="CHANGE_TYPE_RENAMED" value="2" enum="ChangeType">
An earlier added file has been renamed.
</constant>
<constant name="CHANGE_TYPE_DELETED" value="3" enum="ChangeType">
An earlier added file has been deleted.
</constant>
<constant name="CHANGE_TYPE_TYPECHANGE" value="4" enum="ChangeType">
An earlier added file has been typechanged.
</constant>
<constant name="CHANGE_TYPE_UNMERGED" value="5" enum="ChangeType">
A file is left unmerged.
</constant>
<constant name="TREE_AREA_COMMIT" value="0" enum="TreeArea">
A commit is encountered from the commit area.
</constant>
<constant name="TREE_AREA_STAGED" value="1" enum="TreeArea">
A file is encountered from the staged area.
</constant>
<constant name="TREE_AREA_UNSTAGED" value="2" enum="TreeArea">
A file is encountered from the unstaged area.
</constant>
</constants>
</class>

View file

@ -517,6 +517,12 @@
<member name="editor/search_in_file_extensions" type="PoolStringArray" setter="" getter="" default="PoolStringArray( &quot;gd&quot;, &quot;gdshader&quot;, &quot;shader&quot; )">
Text-based file extensions to include in the script editor's "Find in Files" feature. You can add e.g. [code]tscn[/code] if you wish to also parse your scene files, especially if you use built-in scripts which are serialized in the scene files.
</member>
<member name="editor/version_control/autoload_on_startup" type="bool" setter="" getter="" default="false">
Load the previously opened VCS plugin when the editor starts up. This is set to [code]true[/code] whenever a new VCS plugin is initialized.
</member>
<member name="editor/version_control/plugin_name" type="String" setter="" getter="" default="&quot;&quot;">
Last loaded VCS plugin name. Used to autoload the plugin when the editor starts up.
</member>
<member name="gui/common/default_scroll_deadzone" type="int" setter="" getter="" default="0">
Default value for [member ScrollContainer.scroll_deadzone], which will be used for all [ScrollContainer]s unless overridden.
</member>

View file

@ -59,6 +59,12 @@
Opens the script create dialog. The script will extend [code]base_name[/code]. The file extension can be omitted from [code]base_path[/code]. It will be added based on the selected scripting language.
</description>
</method>
<method name="reload_scripts">
<return type="void" />
<description>
Reload all currently opened scripts from disk in case the file contents are newer.
</description>
</method>
</methods>
<signals>
<signal name="editor_script_changed">

View file

@ -5932,6 +5932,11 @@ EditorNode::EditorNode() {
EDITOR_DEF("interface/inspector/default_color_picker_mode", 0);
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "interface/inspector/default_color_picker_mode", PROPERTY_HINT_ENUM, "RGB,HSV,RAW", PROPERTY_USAGE_DEFAULT));
EDITOR_DEF("run/auto_save/save_before_running", true);
EDITOR_DEF("version_control/username", "");
EDITOR_DEF("version_control/ssh_public_key_path", "");
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "version_control/ssh_public_key_path", PROPERTY_HINT_GLOBAL_FILE));
EDITOR_DEF("version_control/ssh_private_key_path", "");
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "version_control/ssh_private_key_path", PROPERTY_HINT_GLOBAL_FILE));
theme_base = memnew(Control);
add_child(theme_base);

View file

@ -30,133 +30,301 @@
#include "editor_vcs_interface.h"
#include "editor_node.h"
EditorVCSInterface *EditorVCSInterface::singleton = nullptr;
void EditorVCSInterface::_bind_methods() {
// Proxy end points that act as fallbacks to unavailability of a function in the VCS addon
ClassDB::bind_method(D_METHOD("_initialize", "project_root_path"), &EditorVCSInterface::_initialize);
ClassDB::bind_method(D_METHOD("_is_vcs_initialized"), &EditorVCSInterface::_is_vcs_initialized);
ClassDB::bind_method(D_METHOD("_get_vcs_name"), &EditorVCSInterface::_get_vcs_name);
ClassDB::bind_method(D_METHOD("_shut_down"), &EditorVCSInterface::_shut_down);
ClassDB::bind_method(D_METHOD("_get_project_name"), &EditorVCSInterface::_get_project_name);
ClassDB::bind_method(D_METHOD("_get_modified_files_data"), &EditorVCSInterface::_get_modified_files_data);
ClassDB::bind_method(D_METHOD("_commit", "msg"), &EditorVCSInterface::_commit);
ClassDB::bind_method(D_METHOD("_get_file_diff", "file_path"), &EditorVCSInterface::_get_file_diff);
ClassDB::bind_method(D_METHOD("_stage_file", "file_path"), &EditorVCSInterface::_stage_file);
ClassDB::bind_method(D_METHOD("_unstage_file", "file_path"), &EditorVCSInterface::_unstage_file);
ClassDB::bind_method(D_METHOD("is_addon_ready"), &EditorVCSInterface::is_addon_ready);
// API methods that redirect calls to the proxy end points
ClassDB::bind_method(D_METHOD("initialize", "project_root_path"), &EditorVCSInterface::initialize);
ClassDB::bind_method(D_METHOD("is_vcs_initialized"), &EditorVCSInterface::is_vcs_initialized);
ClassDB::bind_method(D_METHOD("get_modified_files_data"), &EditorVCSInterface::get_modified_files_data);
ClassDB::bind_method(D_METHOD("stage_file", "file_path"), &EditorVCSInterface::stage_file);
ClassDB::bind_method(D_METHOD("unstage_file", "file_path"), &EditorVCSInterface::unstage_file);
ClassDB::bind_method(D_METHOD("commit", "msg"), &EditorVCSInterface::commit);
ClassDB::bind_method(D_METHOD("get_file_diff", "file_path"), &EditorVCSInterface::get_file_diff);
ClassDB::bind_method(D_METHOD("shut_down"), &EditorVCSInterface::shut_down);
ClassDB::bind_method(D_METHOD("get_project_name"), &EditorVCSInterface::get_project_name);
ClassDB::bind_method(D_METHOD("get_vcs_name"), &EditorVCSInterface::get_vcs_name);
void EditorVCSInterface::popup_error(String p_msg) {
// TRANSLATORS: %s refers to the name of a version control system (e.g. "Git").
EditorNode::get_singleton()->show_warning(p_msg.strip_edges(), vformat(TTR("%s Error"), get_vcs_name()));
}
bool EditorVCSInterface::_initialize(String p_project_root_path) {
WARN_PRINT("Selected VCS addon does not implement an initialization function. This warning will be suppressed.");
return true;
bool EditorVCSInterface::initialize(String p_project_path) {
return call("_initialize", p_project_path);
}
bool EditorVCSInterface::_is_vcs_initialized() {
return false;
void EditorVCSInterface::set_credentials(String p_username, String p_password, String p_ssh_public_key, String p_ssh_private_key, String p_ssh_passphrase) {
call("_set_credentials", p_username, p_password, p_ssh_public_key, p_ssh_private_key, p_ssh_passphrase);
}
Dictionary EditorVCSInterface::_get_modified_files_data() {
return Dictionary();
List<String> EditorVCSInterface::get_remotes() {
List<String> remotes;
Array result = call("_get_remotes");
for (int i = 0; i < result.size(); i++) {
remotes.push_back(result[i]);
}
return remotes;
}
void EditorVCSInterface::_stage_file(String p_file_path) {
}
List<EditorVCSInterface::StatusFile> EditorVCSInterface::get_modified_files_data() {
List<EditorVCSInterface::StatusFile> status_files;
void EditorVCSInterface::_unstage_file(String p_file_path) {
}
Array result = call("_get_modified_files_data");
for (int i = 0; i < result.size(); i++) {
status_files.push_back(_convert_status_file(result[i]));
}
void EditorVCSInterface::_commit(String p_msg) {
}
Array EditorVCSInterface::_get_file_diff(String p_file_path) {
return Array();
}
bool EditorVCSInterface::_shut_down() {
return false;
}
String EditorVCSInterface::_get_project_name() {
return String();
}
String EditorVCSInterface::_get_vcs_name() {
return "";
}
bool EditorVCSInterface::initialize(String p_project_root_path) {
is_initialized = call("_initialize", p_project_root_path);
return is_initialized;
}
bool EditorVCSInterface::is_vcs_initialized() {
return call("_is_vcs_initialized");
}
Dictionary EditorVCSInterface::get_modified_files_data() {
return call("_get_modified_files_data");
return status_files;
}
void EditorVCSInterface::stage_file(String p_file_path) {
if (is_addon_ready()) {
call("_stage_file", p_file_path);
}
}
void EditorVCSInterface::unstage_file(String p_file_path) {
if (is_addon_ready()) {
call("_unstage_file", p_file_path);
}
}
bool EditorVCSInterface::is_addon_ready() {
return is_initialized;
void EditorVCSInterface::discard_file(String p_file_path) {
call("_discard_file", p_file_path);
}
void EditorVCSInterface::commit(String p_msg) {
if (is_addon_ready()) {
call("_commit", p_msg);
}
}
Array EditorVCSInterface::get_file_diff(String p_file_path) {
if (is_addon_ready()) {
return call("_get_file_diff", p_file_path);
List<EditorVCSInterface::DiffFile> EditorVCSInterface::get_diff(String p_identifier, TreeArea p_area) {
List<DiffFile> diff_files;
Array result = call("_get_diff", p_identifier, p_area);
for (int i = 0; i < result.size(); i++) {
diff_files.push_back(_convert_diff_file(result[i]));
}
return Array();
return diff_files;
}
List<EditorVCSInterface::Commit> EditorVCSInterface::get_previous_commits(int p_max_commits) {
List<EditorVCSInterface::Commit> commits;
Array result = call("_get_previous_commits", p_max_commits);
for (int i = 0; i < result.size(); i++) {
commits.push_back(_convert_commit(result[i]));
}
return commits;
}
List<String> EditorVCSInterface::get_branch_list() {
List<String> branch_list;
Array result = call("_get_branch_list");
for (int i = 0; i < result.size(); i++) {
branch_list.push_back(result[i]);
}
return branch_list;
}
void EditorVCSInterface::create_branch(String p_branch_name) {
call("_create_branch", p_branch_name);
}
void EditorVCSInterface::create_remote(String p_remote_name, String p_remote_url) {
call("_create_remote", p_remote_name, p_remote_url);
}
void EditorVCSInterface::remove_branch(String p_branch_name) {
call("_remove_branch", p_branch_name);
}
void EditorVCSInterface::remove_remote(String p_remote_name) {
call("_remove_remote", p_remote_name);
}
String EditorVCSInterface::get_current_branch_name() {
return call("_get_current_branch_name");
}
bool EditorVCSInterface::checkout_branch(String p_branch_name) {
return call("_checkout_branch", p_branch_name);
}
void EditorVCSInterface::pull(String p_remote) {
call("_pull", p_remote);
}
void EditorVCSInterface::push(String p_remote, bool p_force) {
call("_push", p_remote, p_force);
}
void EditorVCSInterface::fetch(String p_remote) {
call("_fetch", p_remote);
}
List<EditorVCSInterface::DiffHunk> EditorVCSInterface::get_line_diff(String p_file_path, String p_text) {
List<DiffHunk> diff_hunks;
Array result = call("_get_line_diff", p_file_path, p_text);
for (int i = 0; i < result.size(); i++) {
diff_hunks.push_back(_convert_diff_hunk(result[i]));
}
return diff_hunks;
}
bool EditorVCSInterface::shut_down() {
return call("_shut_down");
}
String EditorVCSInterface::get_project_name() {
return call("_get_project_name");
}
String EditorVCSInterface::get_vcs_name() {
return call("_get_vcs_name");
}
EditorVCSInterface::EditorVCSInterface() {
is_initialized = false;
Dictionary EditorVCSInterface::create_diff_line(int p_new_line_no, int p_old_line_no, String p_content, String p_status) {
Dictionary diff_line;
diff_line["new_line_no"] = p_new_line_no;
diff_line["old_line_no"] = p_old_line_no;
diff_line["content"] = p_content;
diff_line["status"] = p_status;
return diff_line;
}
EditorVCSInterface::~EditorVCSInterface() {
Dictionary EditorVCSInterface::create_diff_hunk(int p_old_start, int p_new_start, int p_old_lines, int p_new_lines) {
Dictionary diff_hunk;
diff_hunk["new_lines"] = p_new_lines;
diff_hunk["old_lines"] = p_old_lines;
diff_hunk["new_start"] = p_new_start;
diff_hunk["old_start"] = p_old_start;
diff_hunk["diff_lines"] = Array();
return diff_hunk;
}
Dictionary EditorVCSInterface::add_line_diffs_into_diff_hunk(Dictionary p_diff_hunk, Array p_line_diffs) {
p_diff_hunk["diff_lines"] = p_line_diffs;
return p_diff_hunk;
}
Dictionary EditorVCSInterface::create_diff_file(String p_new_file, String p_old_file) {
Dictionary file_diff;
file_diff["new_file"] = p_new_file;
file_diff["old_file"] = p_old_file;
file_diff["diff_hunks"] = Array();
return file_diff;
}
Dictionary EditorVCSInterface::create_commit(String p_msg, String p_author, String p_id, String p_date) {
Dictionary commit_info;
commit_info["message"] = p_msg;
commit_info["author"] = p_author;
commit_info["date"] = p_date;
commit_info["id"] = p_id;
return commit_info;
}
Dictionary EditorVCSInterface::add_diff_hunks_into_diff_file(Dictionary p_diff_file, Array p_diff_hunks) {
p_diff_file["diff_hunks"] = p_diff_hunks;
return p_diff_file;
}
Dictionary EditorVCSInterface::create_status_file(String p_file_path, ChangeType p_change, TreeArea p_area) {
Dictionary sf;
sf["file_path"] = p_file_path;
sf["change_type"] = p_change;
sf["area"] = p_area;
return sf;
}
EditorVCSInterface::DiffLine EditorVCSInterface::_convert_diff_line(Dictionary p_diff_line) {
DiffLine d;
d.new_line_no = p_diff_line["new_line_no"];
d.old_line_no = p_diff_line["old_line_no"];
d.content = p_diff_line["content"];
d.status = p_diff_line["status"];
return d;
}
EditorVCSInterface::DiffHunk EditorVCSInterface::_convert_diff_hunk(Dictionary p_diff_hunk) {
DiffHunk dh;
dh.new_lines = p_diff_hunk["new_lines"];
dh.old_lines = p_diff_hunk["old_lines"];
dh.new_start = p_diff_hunk["new_start"];
dh.old_start = p_diff_hunk["old_start"];
Array diff_lines = p_diff_hunk["diff_lines"];
for (int i = 0; i < diff_lines.size(); i++) {
DiffLine dl = _convert_diff_line(diff_lines[i]);
dh.diff_lines.push_back(dl);
}
return dh;
}
EditorVCSInterface::DiffFile EditorVCSInterface::_convert_diff_file(Dictionary p_diff_file) {
DiffFile df;
df.new_file = p_diff_file["new_file"];
df.old_file = p_diff_file["old_file"];
Array diff_hunks = p_diff_file["diff_hunks"];
for (int i = 0; i < diff_hunks.size(); i++) {
DiffHunk dh = _convert_diff_hunk(diff_hunks[i]);
df.diff_hunks.push_back(dh);
}
return df;
}
EditorVCSInterface::Commit EditorVCSInterface::_convert_commit(Dictionary p_commit) {
EditorVCSInterface::Commit c;
c.msg = p_commit["message"];
c.author = p_commit["author"];
c.date = p_commit["date"];
c.id = p_commit["id"];
return c;
}
EditorVCSInterface::StatusFile EditorVCSInterface::_convert_status_file(Dictionary p_status_file) {
StatusFile sf;
sf.file_path = p_status_file["file_path"];
sf.change_type = (ChangeType)(int)p_status_file["change_type"];
sf.area = (TreeArea)(int)p_status_file["area"];
return sf;
}
void EditorVCSInterface::_bind_methods() {
// Proxy end points that implement the VCS specific operations that the editor demands.
BIND_VMETHOD(MethodInfo(Variant::BOOL, "_initialize", PropertyInfo(Variant::STRING, "project_path")));
BIND_VMETHOD(MethodInfo("_set_credentials", PropertyInfo(Variant::STRING, "username"), PropertyInfo(Variant::STRING, "password"), PropertyInfo(Variant::STRING, "ssh_public_key_path"), PropertyInfo(Variant::STRING, "ssh_private_key_path"), PropertyInfo(Variant::STRING, "ssh_passphrase")));
BIND_VMETHOD(MethodInfo(Variant::ARRAY, "_get_remotes"));
BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_vcs_name"));
BIND_VMETHOD(MethodInfo(Variant::BOOL, "_shut_down"));
BIND_VMETHOD(MethodInfo(Variant::ARRAY, "_get_modified_files_data"));
BIND_VMETHOD(MethodInfo("_commit", PropertyInfo(Variant::STRING, "msg")));
BIND_VMETHOD(MethodInfo(Variant::ARRAY, "_get_diff", PropertyInfo(Variant::STRING, "identifier"), PropertyInfo(Variant::INT, "area")));
BIND_VMETHOD(MethodInfo("_stage_file", PropertyInfo(Variant::STRING, "file_path")));
BIND_VMETHOD(MethodInfo("_unstage_file", PropertyInfo(Variant::STRING, "file_path")));
BIND_VMETHOD(MethodInfo("_discard_file", PropertyInfo(Variant::STRING, "file_path")));
BIND_VMETHOD(MethodInfo(Variant::ARRAY, "_get_previous_commits", PropertyInfo(Variant::INT, "max_commits")));
BIND_VMETHOD(MethodInfo(Variant::ARRAY, "_get_branch_list"));
BIND_VMETHOD(MethodInfo("_create_branch", PropertyInfo(Variant::STRING, "branch_name")));
BIND_VMETHOD(MethodInfo("_remove_branch", PropertyInfo(Variant::STRING, "branch_name")));
BIND_VMETHOD(MethodInfo("_create_remote", PropertyInfo(Variant::STRING, "remote_name"), PropertyInfo(Variant::STRING, "remote_url")));
BIND_VMETHOD(MethodInfo("_remove_remote", PropertyInfo(Variant::STRING, "remote_name")));
BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_current_branch_name"));
BIND_VMETHOD(MethodInfo(Variant::BOOL, "_checkout_branch", PropertyInfo(Variant::STRING, "branch_name")));
BIND_VMETHOD(MethodInfo("_push", PropertyInfo(Variant::STRING, "remote"), PropertyInfo(Variant::BOOL, "force")));
BIND_VMETHOD(MethodInfo("_pull", PropertyInfo(Variant::STRING, "remote")));
BIND_VMETHOD(MethodInfo("_fetch", PropertyInfo(Variant::STRING, "remote")));
BIND_VMETHOD(MethodInfo(Variant::ARRAY, "_get_line_diff", PropertyInfo(Variant::STRING, "file_path"), PropertyInfo(Variant::STRING, "text")));
ClassDB::bind_method(D_METHOD("create_diff_line", "new_line_no", "old_line_no", "content", "status"), &EditorVCSInterface::create_diff_line);
ClassDB::bind_method(D_METHOD("create_diff_hunk", "old_start", "new_start", "old_lines", "new_lines"), &EditorVCSInterface::create_diff_hunk);
ClassDB::bind_method(D_METHOD("create_diff_file", "new_file", "old_file"), &EditorVCSInterface::create_diff_file);
ClassDB::bind_method(D_METHOD("create_commit", "msg", "author", "id", "date"), &EditorVCSInterface::create_commit);
ClassDB::bind_method(D_METHOD("create_status_file", "file_path", "change_type", "area"), &EditorVCSInterface::create_status_file);
ClassDB::bind_method(D_METHOD("add_diff_hunks_into_diff_file", "diff_file", "diff_hunks"), &EditorVCSInterface::add_diff_hunks_into_diff_file);
ClassDB::bind_method(D_METHOD("add_line_diffs_into_diff_hunk", "diff_hunk", "line_diffs"), &EditorVCSInterface::add_line_diffs_into_diff_hunk);
ClassDB::bind_method(D_METHOD("popup_error", "msg"), &EditorVCSInterface::popup_error);
BIND_ENUM_CONSTANT(CHANGE_TYPE_NEW);
BIND_ENUM_CONSTANT(CHANGE_TYPE_MODIFIED);
BIND_ENUM_CONSTANT(CHANGE_TYPE_RENAMED);
BIND_ENUM_CONSTANT(CHANGE_TYPE_DELETED);
BIND_ENUM_CONSTANT(CHANGE_TYPE_TYPECHANGE);
BIND_ENUM_CONSTANT(CHANGE_TYPE_UNMERGED);
BIND_ENUM_CONSTANT(TREE_AREA_COMMIT);
BIND_ENUM_CONSTANT(TREE_AREA_STAGED);
BIND_ENUM_CONSTANT(TREE_AREA_UNSTAGED);
}
EditorVCSInterface *EditorVCSInterface::get_singleton() {

View file

@ -38,45 +38,112 @@
class EditorVCSInterface : public Object {
GDCLASS(EditorVCSInterface, Object)
bool is_initialized;
public:
enum ChangeType {
CHANGE_TYPE_NEW = 0,
CHANGE_TYPE_MODIFIED = 1,
CHANGE_TYPE_RENAMED = 2,
CHANGE_TYPE_DELETED = 3,
CHANGE_TYPE_TYPECHANGE = 4,
CHANGE_TYPE_UNMERGED = 5
};
enum TreeArea {
TREE_AREA_COMMIT = 0,
TREE_AREA_STAGED = 1,
TREE_AREA_UNSTAGED = 2
};
struct DiffLine {
int new_line_no;
int old_line_no;
String content;
String status;
String old_text;
String new_text;
};
struct DiffHunk {
int new_start;
int old_start;
int new_lines;
int old_lines;
List<DiffLine> diff_lines;
};
struct DiffFile {
String new_file;
String old_file;
List<DiffHunk> diff_hunks;
};
struct Commit {
String author;
String msg;
String id;
String date;
};
struct StatusFile {
TreeArea area;
ChangeType change_type;
String file_path;
};
protected:
static EditorVCSInterface *singleton;
static void _bind_methods();
// Implemented by addons as end points for the proxy functions
virtual bool _initialize(String p_project_root_path);
virtual bool _is_vcs_initialized();
virtual Dictionary _get_modified_files_data();
virtual void _stage_file(String p_file_path);
virtual void _unstage_file(String p_file_path);
virtual void _commit(String p_msg);
virtual Array _get_file_diff(String p_file_path);
virtual bool _shut_down();
virtual String _get_project_name();
virtual String _get_vcs_name();
DiffLine _convert_diff_line(Dictionary p_diff_line);
DiffHunk _convert_diff_hunk(Dictionary p_diff_hunk);
DiffFile _convert_diff_file(Dictionary p_diff_file);
Commit _convert_commit(Dictionary p_commit);
StatusFile _convert_status_file(Dictionary p_status_file);
public:
static EditorVCSInterface *get_singleton();
static void set_singleton(EditorVCSInterface *p_singleton);
bool is_addon_ready();
// Proxy functions to the editor for use
bool initialize(String p_project_root_path);
bool is_vcs_initialized();
Dictionary get_modified_files_data();
bool initialize(String p_project_path);
void set_credentials(String p_username, String p_password, String p_ssh_public_key_path, String p_ssh_private_key_path, String p_ssh_passphrase);
List<StatusFile> get_modified_files_data();
void stage_file(String p_file_path);
void unstage_file(String p_file_path);
void discard_file(String p_file_path);
void commit(String p_msg);
Array get_file_diff(String p_file_path);
List<DiffFile> get_diff(String p_identifier, TreeArea p_area);
bool shut_down();
String get_project_name();
String get_vcs_name();
List<Commit> get_previous_commits(int p_max_commits);
List<String> get_branch_list();
List<String> get_remotes();
void create_branch(String p_branch_name);
void remove_branch(String p_branch_name);
void create_remote(String p_remote_name, String p_remote_url);
void remove_remote(String p_remote_name);
String get_current_branch_name();
bool checkout_branch(String p_branch_name);
void pull(String p_remote);
void push(String p_remote, bool p_force);
void fetch(String p_remote);
List<DiffHunk> get_line_diff(String p_file_path, String p_text);
EditorVCSInterface();
virtual ~EditorVCSInterface();
// Helper functions to create and convert Dictionary into data structures
Dictionary create_diff_line(int p_new_line_no, int p_old_line_no, String p_content, String p_status);
Dictionary create_diff_hunk(int p_old_start, int p_new_start, int p_old_lines, int p_new_lines);
Dictionary create_diff_file(String p_new_file, String p_old_file);
Dictionary create_commit(String p_msg, String p_author, String p_id, String p_date);
Dictionary create_status_file(String p_file_path, ChangeType p_change, TreeArea p_area);
Dictionary add_line_diffs_into_diff_hunk(Dictionary p_diff_hunk, Array p_line_diffs);
Dictionary add_diff_hunks_into_diff_file(Dictionary p_diff_file, Array p_diff_hunks);
void popup_error(String p_msg);
};
VARIANT_ENUM_CAST(EditorVCSInterface::ChangeType);
VARIANT_ENUM_CAST(EditorVCSInterface::TreeArea);
#endif // !EDITOR_VCS_INTERFACE_H

View file

@ -0,0 +1 @@
<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m6.1 1c1.6 0 1.6 2.2-.1 2.2h-1.3l2.5 2.6c1.1 1.1-.3 2.7-1.5 1.5l-2.6-2.6v1.3c.1 1.5-2.1 1.7-2.1.1v-4c0-.7.4-1.1 1-1.1zm5.8 1.2c1.7.1 3 1.4 3.1 3.1v6.6c0 1.9-1.7 3.1-3.3 3.1h-6.3c-2.1 0-3.3-1.5-3.3-3.3v-1.9c0-1.5 2.1-1.5 2.1 0v1.9c0 .6.6 1.2 1.1 1.2h6.4c.6 0 1.1-.5 1.1-1.1v-6.3-.1c0-.6-.5-1-1.1-1l-1.2-.1c-1.9 0-1.9-2.1-.1-2.1z" fill="#e0e0e0"/></svg>

After

Width:  |  Height:  |  Size: 444 B

View file

@ -0,0 +1 @@
<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8.2 1c-.2 0-.3 0-.5 0v2c2.1-.2 4.2 1.1 5 3.1.8 1.9.3 4.3-1.1 5.9l-1.6-1.8.2 4.9h4.4l-1.6-1.9c2.2-2.4 2.7-6.2 1-9-1-1.5-2.5-2.6-4.3-3-.5-.1-1-.2-1.5-.2zm-6.6 0 1.5 1.8c-2.2 2.3-2.8 6.2-1 8.9.9 1.5 2.5 2.6 4.3 3 .6.1 1.4.3 2 .2 0-.6 0-1.3 0-1.9-2.2.2-4.3-1.1-5.1-3.1-.8-1.9-.3-4.3 1.2-5.8l1.6 1.8-.2-4.9z" fill="#e0e0e0"/></svg>

After

Width:  |  Height:  |  Size: 420 B

View file

@ -0,0 +1 @@
<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m3 1.1c-.5 0-1 .4-1 1v5c0 .5.2.9 1 .9h4.9c.6 0 .9-.6.9-1 0-.5-.5-1-1-1h-2.5l2.2-2.2c1.1-1 2.7-.9 3.7.1 1.1 1.1 1.1 2.8 0 3.8l-5.7 5.7c-.4.4-.4 1 0 1.4s1 .4 1.4 0l5.7-5.7c1.8-1.8 1.8-4.8 0-6.6-2.2-1.9-4.5-1.8-6.5 0l-2.2 2.1v-2.7c0-.5-.5-.8-1-.8z" fill="#e0e0e0"/></svg>

After

Width:  |  Height:  |  Size: 361 B

View file

@ -0,0 +1 @@
<svg clip-rule="evenodd" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="1.5" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><g fill="#e0e0e0" fill-rule="nonzero"><path d="m3.755 1.396c-1.599 0-2.914 1.315-2.914 2.913 0 1.599 1.315 2.914 2.914 2.914 1.598 0 2.913-1.315 2.913-2.914 0-1.598-1.315-2.913-2.913-2.913zm0 1.462c.796 0 1.451.655 1.451 1.451 0 .797-.655 1.452-1.451 1.452-.797 0-1.452-.655-1.452-1.452 0-.796.655-1.451 1.452-1.451z"/><path d="m12.073 8.956c-1.599 0-2.914 1.316-2.914 2.914s1.315 2.914 2.914 2.914c1.598 0 2.914-1.316 2.914-2.914s-1.316-2.914-2.914-2.914zm0 1.463c.796 0 1.451.655 1.451 1.451s-.655 1.451-1.451 1.451-1.451-.655-1.451-1.451.655-1.451 1.451-1.451z"/><path d="m12.073 1.396c-1.599 0-2.914 1.315-2.914 2.913 0 1.599 1.315 2.914 2.914 2.914 1.598 0 2.914-1.315 2.914-2.914 0-1.598-1.316-2.913-2.914-2.913zm0 1.462c.796 0 1.451.655 1.451 1.451 0 .797-.655 1.452-1.451 1.452s-1.451-.655-1.451-1.452c0-.796.655-1.451 1.451-1.451z"/></g><path d="m9.159 11.87h-2.491l-2.913-2.914v-1.733" fill="none" stroke="#e0e0e0" stroke-width="1.5"/><path d="m9.159 4.309h-2.491" fill="none" stroke="#e0e0e0" stroke-width="1.5"/></svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -719,7 +719,7 @@ void ScriptEditor::_resave_scripts(const String &p_str) {
disk_changed->hide();
}
void ScriptEditor::_reload_scripts() {
void ScriptEditor::reload_scripts() {
for (int i = 0; i < tab_container->get_child_count(); i++) {
ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i));
if (!se) {
@ -835,7 +835,7 @@ bool ScriptEditor::_test_script_times_on_disk(RES p_for_script) {
if (need_reload) {
if (!need_ask) {
script_editor->_reload_scripts();
script_editor->reload_scripts();
need_reload = false;
} else {
disk_changed->call_deferred("popup_centered_ratio", 0.5);
@ -3072,7 +3072,6 @@ void ScriptEditor::_bind_methods() {
ClassDB::bind_method("_editor_pause", &ScriptEditor::_editor_pause);
ClassDB::bind_method("_editor_stop", &ScriptEditor::_editor_stop);
ClassDB::bind_method("_add_callback", &ScriptEditor::_add_callback);
ClassDB::bind_method("_reload_scripts", &ScriptEditor::_reload_scripts);
ClassDB::bind_method("_resave_scripts", &ScriptEditor::_resave_scripts);
ClassDB::bind_method("_res_saved_callback", &ScriptEditor::_res_saved_callback);
ClassDB::bind_method("_goto_script_line", &ScriptEditor::_goto_script_line);
@ -3125,6 +3124,7 @@ void ScriptEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_current_script"), &ScriptEditor::_get_current_script);
ClassDB::bind_method(D_METHOD("get_open_scripts"), &ScriptEditor::_get_open_scripts);
ClassDB::bind_method(D_METHOD("open_script_create_dialog", "base_name", "base_path"), &ScriptEditor::open_script_create_dialog);
ClassDB::bind_method(D_METHOD("reload_scripts"), &ScriptEditor::reload_scripts);
ADD_SIGNAL(MethodInfo("editor_script_changed", PropertyInfo(Variant::OBJECT, "script", PROPERTY_HINT_RESOURCE_TYPE, "Script")));
ADD_SIGNAL(MethodInfo("script_close", PropertyInfo(Variant::OBJECT, "script", PROPERTY_HINT_RESOURCE_TYPE, "Script")));
@ -3402,7 +3402,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
vbc->add_child(disk_changed_list);
disk_changed_list->set_v_size_flags(SIZE_EXPAND_FILL);
disk_changed->connect("confirmed", this, "_reload_scripts");
disk_changed->connect("confirmed", this, "reload_scripts");
disk_changed->get_ok()->set_text(TTR("Reload"));
disk_changed->add_button(TTR("Resave"), !OS::get_singleton()->get_swap_ok_cancel(), "resave");

View file

@ -278,7 +278,6 @@ class ScriptEditor : public PanelContainer {
String _get_debug_tooltip(const String &p_text, Node *_se);
void _resave_scripts(const String &p_str);
void _reload_scripts();
bool _test_script_times_on_disk(RES p_for_script = Ref<Resource>());
@ -423,6 +422,7 @@ public:
void ensure_focus_current();
void apply_scripts() const;
void open_script_create_dialog(const String &p_base_name, const String &p_base_path);
void reload_scripts();
void ensure_select_current();

File diff suppressed because it is too large Load diff

View file

@ -34,85 +34,158 @@
#include "editor/editor_plugin.h"
#include "editor/editor_vcs_interface.h"
#include "scene/gui/container.h"
#include "scene/gui/file_dialog.h"
#include "scene/gui/menu_button.h"
#include "scene/gui/rich_text_label.h"
#include "scene/gui/tab_container.h"
#include "scene/gui/text_edit.h"
#include "scene/gui/tool_button.h"
#include "scene/gui/tree.h"
class VersionControlEditorPlugin : public EditorPlugin {
GDCLASS(VersionControlEditorPlugin, EditorPlugin)
public:
enum ChangeType {
enum ButtonType {
BUTTON_TYPE_OPEN = 0,
BUTTON_TYPE_DISCARD = 1,
};
CHANGE_TYPE_NEW = 0,
CHANGE_TYPE_MODIFIED = 1,
CHANGE_TYPE_RENAMED = 2,
CHANGE_TYPE_DELETED = 3,
CHANGE_TYPE_TYPECHANGE = 4
enum DiffViewType {
DIFF_VIEW_TYPE_SPLIT = 0,
DIFF_VIEW_TYPE_UNIFIED = 1,
};
enum ExtraOption {
EXTRA_OPTION_FORCE_PUSH,
EXTRA_OPTION_CREATE_BRANCH,
EXTRA_OPTION_CREATE_REMOTE,
};
private:
static VersionControlEditorPlugin *singleton;
int staged_files_count;
List<StringName> available_addons;
List<StringName> available_plugins;
PopupMenu *version_control_actions;
AcceptDialog *set_up_dialog;
VBoxContainer *set_up_vbc;
HBoxContainer *set_up_hbc;
Label *set_up_vcs_label;
OptionButton *set_up_choice;
PanelContainer *set_up_init_settings;
Button *set_up_init_button;
RichTextLabel *set_up_vcs_status;
Button *set_up_ok_button;
VBoxContainer *set_up_vbc;
VBoxContainer *set_up_settings_vbc;
LineEdit *set_up_username;
LineEdit *set_up_password;
LineEdit *set_up_ssh_public_key_path;
LineEdit *set_up_ssh_private_key_path;
LineEdit *set_up_ssh_passphrase;
FileDialog *set_up_ssh_public_key_file_dialog;
FileDialog *set_up_ssh_private_key_file_dialog;
Label *set_up_warning_text;
HashMap<ChangeType, String> change_type_to_strings;
HashMap<ChangeType, Color> change_type_to_color;
OptionButton *commit_list_size_button;
AcceptDialog *branch_create_confirm;
LineEdit *branch_create_name_input;
Button *branch_create_ok;
AcceptDialog *remote_create_confirm;
LineEdit *remote_create_name_input;
LineEdit *remote_create_url_input;
Button *remote_create_ok;
HashMap<EditorVCSInterface::ChangeType, String> change_type_to_strings;
HashMap<EditorVCSInterface::ChangeType, Color> change_type_to_color;
HashMap<EditorVCSInterface::ChangeType, Ref<Texture>> change_type_to_icon;
TabContainer *dock_vbc;
VBoxContainer *version_commit_dock;
VBoxContainer *commit_box_vbc;
HSplitContainer *stage_tools;
Tree *stage_files;
TreeItem *new_files;
TreeItem *modified_files;
TreeItem *renamed_files;
TreeItem *deleted_files;
TreeItem *typechange_files;
Label *staging_area_label;
HSplitContainer *stage_buttons;
Button *stage_all_button;
Button *stage_selected_button;
Button *refresh_button;
Tree *staged_files;
Tree *unstaged_files;
Tree *commit_list;
OptionButton *branch_select;
Button *branch_remove_button;
AcceptDialog *branch_remove_confirm;
ToolButton *fetch_button;
ToolButton *pull_button;
ToolButton *push_button;
OptionButton *remote_select;
Button *remote_remove_button;
AcceptDialog *remote_remove_confirm;
MenuButton *extra_options;
PopupMenu *extra_options_remove_branch_list;
PopupMenu *extra_options_remove_remote_list;
String branch_to_remove;
String remote_to_remove;
ToolButton *stage_all_button;
ToolButton *unstage_all_button;
ToolButton *discard_all_button;
ToolButton *refresh_button;
TextEdit *commit_message;
Button *commit_button;
Label *commit_status;
PanelContainer *version_control_dock;
VBoxContainer *version_control_dock;
ToolButton *version_control_dock_button;
VBoxContainer *diff_vbc;
HBoxContainer *diff_hbc;
Button *diff_refresh_button;
Label *diff_file_name;
Label *diff_heading;
Label *diff_title;
RichTextLabel *diff;
OptionButton *diff_view_type_select;
bool show_commit_diff_header = false;
List<EditorVCSInterface::DiffFile> diff_content;
void _populate_available_vcs_names();
void _selected_a_vcs(int p_id);
void _notification(int p_what);
void _initialize_vcs();
void _send_commit_msg();
void _set_credentials();
void _ssh_public_key_selected(String p_path);
void _ssh_private_key_selected(String p_path);
void _populate_available_vcs_names();
void _update_remotes_list();
void _update_set_up_warning(String p_new_text);
void _update_opened_tabs();
void _update_extra_options();
bool _load_plugin(String p_path);
void _set_up();
void _pull();
void _push();
void _force_push();
void _fetch();
void _commit();
void _discard_all();
void _refresh_stage_area();
void _stage_selected();
void _stage_all();
void _view_file_diff();
void _display_file_diff(String p_file_path);
void _refresh_file_diff();
void _clear_file_diff();
void _update_stage_status();
void _update_commit_status();
void _refresh_branch_list();
void _refresh_commit_list();
void _refresh_remote_list();
void _display_diff(int p_idx);
void _move_all(Object *p_tree);
void _load_diff(Object *p_tree);
void _clear_diff();
int _get_item_count(Tree *p_tree);
void _item_activated(Object *p_tree);
void _create_branch();
void _create_remote();
void _update_branch_create_button(String p_new_text);
void _update_remote_create_button(String p_new_text);
void _branch_item_selected(int p_index);
void _remote_selected(int p_index);
void _remove_branch();
void _remove_remote();
void _popup_branch_remove_confirm(int p_index);
void _popup_remote_remove_confirm(int p_index);
void _move_item(Tree *p_tree, TreeItem *p_itme);
void _display_diff_split_view(List<EditorVCSInterface::DiffLine> &p_diff_content);
void _display_diff_unified_view(List<EditorVCSInterface::DiffLine> &p_diff_content);
void _discard_file(String p_file_path, EditorVCSInterface::ChangeType p_change);
void _cell_button_pressed(Object *p_item, int p_column, int p_id);
void _add_new_item(Tree *p_tree, String p_file_path, EditorVCSInterface::ChangeType p_change);
void _update_commit_button();
void _commit_message_gui_input(const Ref<InputEvent> &p_event);
void _extra_option_selected(int p_index);
bool _is_staging_area_empty();
friend class EditorVCSInterface;
@ -127,21 +200,16 @@ public:
PopupMenu *get_version_control_actions_panel() const { return version_control_actions; }
VBoxContainer *get_version_commit_dock() const { return version_commit_dock; }
PanelContainer *get_version_control_dock() const { return version_control_dock; }
VBoxContainer *get_version_control_dock() const { return version_control_dock; }
List<StringName> get_available_vcs_names() const { return available_addons; }
bool is_vcs_initialized() const;
const String get_vcs_name() const;
List<StringName> get_available_vcs_names() const { return available_plugins; }
void register_editor();
void fetch_available_vcs_addon_names();
void clear_stage_area();
void fetch_available_vcs_plugin_names();
void shut_down();
VersionControlEditorPlugin();
~VersionControlEditorPlugin();
};
VARIANT_ENUM_CAST(VersionControlEditorPlugin::ChangeType);
#endif // !VERSION_CONTROL_EDITOR_PLUGIN_H