Index · Object → EditorVCSInterface

EditorVCSInterface

Version Control System (VCS) interface, which reads and writes to the local VCS in use.

Class Description

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.

Methods

func _allow_amends() -> bool

Returns whether or not the plugin allows commit amends.

func _checkout_branch(branch_name: String) -> bool

Checks out a branch_name in the VCS.

func _commit(msg: String, amend: bool) -> void

Commits the currently staged changes and applies the commit msg to the resulting commit. If amend is true the commit will modify the most recent commit instead.

func _create_branch(branch_name: String) -> void

Creates a new branch named branch_name in the VCS.

func _create_remote(remote_name: String, remote_url: String) -> void

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.

func _discard_file(file_path: String) -> void

Discards the changes made in a file present at file_path.

func _fetch(remote: String) -> void

Fetches new changes from the remote, but doesn't write changes to the current working directory. Equivalent to git fetch.

func _get_branch_list() -> String[]

Gets an instance of an Array of Strings containing available branch names in the VCS.

func _get_current_branch_name() -> String

Gets the current branch name defined in the VCS.

func _get_diff(identifier: String, area: int) -> Dictionary[]

Returns an array of Dictionary items (see create_diff_file(), create_diff_hunk(), create_diff_line(), add_line_diffs_into_diff_hunk() and 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.

func _get_line_diff(file_path: String, text: String) -> Dictionary[]

Returns an Array of Dictionary items (see create_diff_hunk()), each containing a line diff between a file at file_path and the text which is passed in.

func _get_modified_files_data() -> Dictionary[]

Returns an Array of Dictionary items (see create_status_file()), each containing the status data of every modified file in the project folder.

func _get_previous_commits(max_commits: int) -> Dictionary[]

Returns an Array of Dictionary items (see create_commit()), each containing the data for a past commit.

func _get_remotes() -> String[]

Returns an Array of Strings, each containing the name of a remote configured in the VCS.

func _get_vcs_name() -> String

Returns the name of the underlying VCS provider.

func _initialize(project_path: String) -> bool

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.

func _pull(remote: String) -> void

Pulls changes from the remote. This can give rise to merge conflicts.

func _push(remote: String, force: bool) -> void

Pushes changes to the remote. If force is true, a force push will override the change history already present on the remote.

func _remove_branch(branch_name: String) -> void

Remove a branch from the local VCS.

func _remove_remote(remote_name: String) -> void

Remove a remote from the local VCS.

func _set_credentials(username: String, password: String, ssh_public_key_path: String, ssh_private_key_path: String, ssh_passphrase: String) -> void

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.

func _shut_down() -> bool

Shuts down VCS plugin instance. Called when the user either closes the editor or shuts down the VCS plugin through the editor UI.

func _stage_file(file_path: String) -> void

Stages the file present at file_path to the staged area.

func _unstage_file(file_path: String) -> void

Unstages the file present at file_path from the staged area to the unstaged area.

func add_diff_hunks_into_diff_file(diff_file: Dictionary, diff_hunks: Dictionary[]) -> Dictionary

Helper function to add an array of diff_hunks into a diff_file.

func add_line_diffs_into_diff_hunk(diff_hunk: Dictionary, line_diffs: Dictionary[]) -> Dictionary

Helper function to add an array of line_diffs into a diff_hunk.

func create_commit(msg: String, author: String, id: String, unix_timestamp: int, offset_minutes: int) -> Dictionary

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.

func create_diff_file(new_file: String, old_file: String) -> Dictionary

Helper function to create a Dictionary for storing old and new diff file paths.

func create_diff_hunk(old_start: int, new_start: int, old_lines: int, new_lines: int) -> Dictionary

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.

func create_diff_line(new_line_no: int, old_line_no: int, content: String, status: String) -> Dictionary

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.

func create_status_file(file_path: String, change_type: EditorVCSInterface.ChangeType, area: EditorVCSInterface.TreeArea) -> Dictionary

Helper function to create a Dictionary used by editor to read the status of a file.

func popup_error(msg: String) -> void

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.

Inherited from Object (62)
func _get(property: StringName) -> Variant
func _get_property_list() -> Dictionary[]
func _init() -> void
func _iter_get(iter: Variant) -> Variant
func _iter_init(iter: Array) -> bool
func _iter_next(iter: Array) -> bool
func _notification(what: int) -> void
func _set(property: StringName, value: Variant) -> bool
func _to_string() -> String
func _validate_property(property: Dictionary) -> void
func add_user_signal(signal: String, arguments: Array = []) -> void
func call(method: StringName) -> Variant
func callv(method: StringName, arg_array: Array) -> Variant
func cancel_free() -> void
func connect(signal: StringName, callable: Callable, flags: int = 0) -> Error
func disconnect(signal: StringName, callable: Callable) -> void
func emit_signal(signal: StringName) -> Error
func free() -> void
func get(property: StringName) -> Variant
func get_class() -> String
func get_incoming_connections() -> Dictionary[]
func get_indexed(property_path: NodePath) -> Variant
func get_meta(name: StringName, default: Variant = null) -> Variant
func get_meta_list() -> StringName[]
func get_method_list() -> Dictionary[]
func get_property_list() -> Dictionary[]
func get_signal_connection_list(signal: StringName) -> Dictionary[]
func get_signal_list() -> Dictionary[]
func has_meta(name: StringName) -> bool
func has_method(method: StringName) -> bool
func has_signal(signal: StringName) -> bool
func is_class(class: StringName) -> bool
func is_connected(signal: StringName, callable: Callable) -> bool
func notification(what: int, reversed: bool = false) -> void
func remove_meta(name: StringName) -> void
func remove_user_signal(signal: StringName) -> void
func set(property: StringName, value: Variant) -> void
func set_block_signals(enable: bool) -> void
func set_deferred(property: StringName, value: Variant) -> void
func set_indexed(property_path: NodePath, value: Variant) -> void
func set_message_translation(enable: bool) -> void
func set_meta(name: StringName, value: Variant) -> void
func set_script(script: Variant) -> void
func set_translation_domain(domain: StringName) -> void
func to_string() -> String
func tr(message: StringName, context: StringName = &"") -> String
func tr_n(message: StringName, plural_message: StringName, n: int, context: StringName = &"") -> String

Signals

Inherited from Object (2)

Enums & Constants

enum ChangeType
CHANGE_TYPE_NEW = 0

A new file has been added.

CHANGE_TYPE_MODIFIED = 1

An earlier added file has been modified.

CHANGE_TYPE_RENAMED = 2

An earlier added file has been renamed.

CHANGE_TYPE_DELETED = 3

An earlier added file has been deleted.

CHANGE_TYPE_TYPECHANGE = 4

An earlier added file has been typechanged.

CHANGE_TYPE_UNMERGED = 5

A file is left unmerged.

enum TreeArea
TREE_AREA_COMMIT = 0

A commit is encountered from the commit area.

TREE_AREA_STAGED = 1

A file is encountered from the staged area.

TREE_AREA_UNSTAGED = 2

A file is encountered from the unstaged area.