You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-17 14:11:06 +00:00
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:
committed by
ChronicallySerious
parent
fddbbf445b
commit
0b327eb46e
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user