Class EditorVCSInterface
Version Control System (VCS) interface, which reads and writes to the local VCS in use.
- Inheritance
-
EditorVCSInterface
Remarks
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 GDExtension plugins 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 each of these virtual functions.
See Also
Methods
_checkout_branch(String)
Qualifiers: virtual
Checks out a branch_name
in the VCS.
bool _checkout_branch(String branch_name)
Parameters
branch_name
String
_commit(String)
Qualifiers: virtual
Commits the currently staged changes and applies the commit msg
to the resulting commit.
void _commit(String msg)
Parameters
msg
String
_create_branch(String)
Qualifiers: virtual
Creates a new branch named branch_name
in the VCS.
void _create_branch(String branch_name)
Parameters
branch_name
String
_create_remote(String, String)
Qualifiers: virtual
Creates a new remote destination with name remote_name
and points it to remote_url
. This can be an HTTPS remote or an SSH remote.
void _create_remote(String remote_name, String remote_url)
Parameters
_discard_file(String)
Qualifiers: virtual
Discards the changes made in a file present at file_path
.
void _discard_file(String file_path)
Parameters
file_path
String
_fetch(String)
Qualifiers: virtual
Fetches new changes from the remote
, but doesn't write changes to the current working directory. Equivalent to git fetch
.
void _fetch(String remote)
Parameters
remote
String
_get_branch_list
Qualifiers: virtual
Gets an instance of an Array of Strings containing available branch names in the VCS.
String[] _get_branch_list
_get_current_branch_name
Qualifiers: virtual
Gets the current branch name defined in the VCS.
String _get_current_branch_name
_get_diff(String, int)
Qualifiers: virtual
Returns an array of Dictionary items (see EditorVCSInterface.create_diff_file, EditorVCSInterface.create_diff_hunk, EditorVCSInterface.create_diff_line, EditorVCSInterface.add_line_diffs_into_diff_hunk and EditorVCSInterface.add_diff_hunks_into_diff_file), each containing information about a diff. If identifier
is a file path, returns a file diff, and if it is a commit identifier, then returns a commit diff.
Dictionary[] _get_diff(String identifier, int area)
Parameters
_get_line_diff(String, String)
Qualifiers: virtual
Returns an Array of Dictionary items (see EditorVCSInterface.create_diff_hunk), each containing a line diff between a file at file_path
and the text
which is passed in.
Dictionary[] _get_line_diff(String file_path, String text)
Parameters
_get_modified_files_data
Qualifiers: virtual
Returns an Array of Dictionary items (see EditorVCSInterface.create_status_file), each containing the status data of every modified file in the project folder.
Dictionary[] _get_modified_files_data
_get_previous_commits(int)
Qualifiers: virtual
Returns an Array of Dictionary items (see EditorVCSInterface.create_commit), each containing the data for a past commit.
Dictionary[] _get_previous_commits(int max_commits)
Parameters
max_commits
int
_get_remotes
Qualifiers: virtual
Returns an Array of Strings, each containing the name of a remote configured in the VCS.
String[] _get_remotes
_get_vcs_name
Qualifiers: virtual
Returns the name of the underlying VCS provider.
String _get_vcs_name
_initialize(String)
Qualifiers: virtual
Initializes the VCS plugin when called from the editor. Returns whether or not the plugin was successfully initialized. A VCS project is initialized at project_path
.
bool _initialize(String project_path)
Parameters
project_path
String
_pull(String)
Qualifiers: virtual
Pulls changes from the remote. This can give rise to merge conflicts.
void _pull(String remote)
Parameters
remote
String
_push(String, bool)
Qualifiers: virtual
Pushes changes to the remote
. If force
is true
, a force push will override the change history already present on the remote.
void _push(String remote, bool force)
Parameters
_remove_branch(String)
Qualifiers: virtual
Remove a branch from the local VCS.
void _remove_branch(String branch_name)
Parameters
branch_name
String
_remove_remote(String)
Qualifiers: virtual
Remove a remote from the local VCS.
void _remove_remote(String remote_name)
Parameters
remote_name
String
_set_credentials(String, String, String, String, String)
Qualifiers: virtual
Set user credentials in the underlying VCS. username
and password
are used only during HTTPS authentication unless not already mentioned in the remote URL. ssh_public_key_path
, ssh_private_key_path
, and ssh_passphrase
are only used during SSH authentication.
void _set_credentials(String username, String password, String ssh_public_key_path, String ssh_private_key_path, String ssh_passphrase)
Parameters
username
Stringpassword
Stringssh_public_key_path
Stringssh_private_key_path
Stringssh_passphrase
String
_shut_down
Qualifiers: virtual
Shuts down VCS plugin instance. Called when the user either closes the editor or shuts down the VCS plugin through the editor UI.
bool _shut_down
_stage_file(String)
Qualifiers: virtual
Stages the file present at file_path
to the staged area.
void _stage_file(String file_path)
Parameters
file_path
String
_unstage_file(String)
Qualifiers: virtual
Unstages the file present at file_path
from the staged area to the unstaged area.
void _unstage_file(String file_path)
Parameters
file_path
String
add_diff_hunks_into_diff_file(Dictionary, Dictionary[])
Helper function to add an array of diff_hunks
into a diff_file
.
Dictionary add_diff_hunks_into_diff_file(Dictionary diff_file, Dictionary[] diff_hunks)
Parameters
diff_file
Dictionarydiff_hunks
Dictionary[]
add_line_diffs_into_diff_hunk(Dictionary, Dictionary[])
Helper function to add an array of line_diffs
into a diff_hunk
.
Dictionary add_line_diffs_into_diff_hunk(Dictionary diff_hunk, Dictionary[] line_diffs)
Parameters
diff_hunk
Dictionaryline_diffs
Dictionary[]
create_commit(String, String, String, int, int)
Helper function to create a commit Dictionary item. msg
is the commit message of the commit. author
is a single human-readable string containing all the author's details, e.g. the email and name configured in the VCS. id
is the identifier of the commit, in whichever format your VCS may provide an identifier to commits. unix_timestamp
is the UTC Unix timestamp of when the commit was created. offset_minutes
is the timezone offset in minutes, recorded from the system timezone where the commit was created.
Dictionary create_commit(String msg, String author, String id, int unix_timestamp, int offset_minutes)
Parameters
create_diff_file(String, String)
Helper function to create a Dictionary for storing old and new diff file paths.
Dictionary create_diff_file(String new_file, String old_file)
Parameters
create_diff_hunk(int, int, int, int)
Helper function to create a Dictionary for storing diff hunk data. old_start
is the starting line number in old file. new_start
is the starting line number in new file. old_lines
is the number of lines in the old file. new_lines
is the number of lines in the new file.
Dictionary create_diff_hunk(int old_start, int new_start, int old_lines, int new_lines)
Parameters
create_diff_line(int, int, String, String)
Helper function to create a Dictionary for storing a line diff. new_line_no
is the line number in the new file (can be -1
if the line is deleted). old_line_no
is the line number in the old file (can be -1
if the line is added). content
is the diff text. status
is a single character string which stores the line origin.
Dictionary create_diff_line(int new_line_no, int old_line_no, String content, String status)
Parameters
create_status_file(String, int, int)
Helper function to create a Dictionary used by editor to read the status of a file.
Dictionary create_status_file(String file_path, int change_type, int area)
Parameters
popup_error(String)
Pops up an error message in the editor which is shown as coming from the underlying VCS. Use this to show VCS specific error messages.
void popup_error(String msg)
Parameters
msg
String