Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
EditorVCSInterface
繼承: Object
版本控制系統(VCS)介面,用於讀取和寫入正在使用的本地 VCS。
說明
定義編輯器使用的 API,負責從底層 VCS 提取資訊。該 API 的實作包含在 VCS 外掛程式中,這些外掛程式是繼承 EditorVCSInterface 並被附加(按需)到 EditorVCSInterface 的單例實例的 GDExtension 外掛程式。以下列出的所有虛函式都不會親自執行操作,而是會去呼叫 VCS 外掛程式中內部覆蓋的函式,以提供隨插即用的體驗。自訂 VCS 外掛程式應當繼承 EditorVCSInterface 並覆蓋這些虛函式。
教學
方法
_allow_amends() virtual |
|
_checkout_branch(branch_name: String) virtual required |
|
void |
|
void |
_create_branch(branch_name: String) virtual required |
void |
_create_remote(remote_name: String, remote_url: String) virtual required |
void |
_discard_file(file_path: String) virtual required |
void |
|
_get_branch_list() virtual required |
|
_get_current_branch_name() virtual required |
|
_get_line_diff(file_path: String, text: String) virtual required |
|
_get_modified_files_data() virtual required |
|
_get_previous_commits(max_commits: int) virtual required |
|
_get_remotes() virtual required |
|
_get_vcs_name() virtual required |
|
_initialize(project_path: String) virtual required |
|
void |
|
void |
|
void |
_remove_branch(branch_name: String) virtual required |
void |
_remove_remote(remote_name: String) virtual required |
void |
_set_credentials(username: String, password: String, ssh_public_key_path: String, ssh_private_key_path: String, ssh_passphrase: String) virtual required |
_shut_down() virtual required |
|
void |
_stage_file(file_path: String) virtual required |
void |
_unstage_file(file_path: String) virtual required |
add_diff_hunks_into_diff_file(diff_file: Dictionary, diff_hunks: Array[Dictionary]) |
|
add_line_diffs_into_diff_hunk(diff_hunk: Dictionary, line_diffs: Array[Dictionary]) |
|
create_commit(msg: String, author: String, id: String, unix_timestamp: int, offset_minutes: int) |
|
create_diff_file(new_file: String, old_file: String) |
|
create_diff_hunk(old_start: int, new_start: int, old_lines: int, new_lines: int) |
|
create_diff_line(new_line_no: int, old_line_no: int, content: String, status: String) |
|
create_status_file(file_path: String, change_type: ChangeType, area: TreeArea) |
|
void |
popup_error(msg: String) |
列舉
enum ChangeType: 🔗
ChangeType CHANGE_TYPE_NEW = 0
新增了新檔案。
ChangeType CHANGE_TYPE_MODIFIED = 1
先前新增的檔已被修改。
ChangeType CHANGE_TYPE_RENAMED = 2
先前新增的檔已被重命名。
ChangeType CHANGE_TYPE_DELETED = 3
先前新增的檔已被刪除。
ChangeType CHANGE_TYPE_TYPECHANGE = 4
先前新增的檔案已更改型別。
ChangeType CHANGE_TYPE_UNMERGED = 5
檔未合併。
enum TreeArea: 🔗
TreeArea TREE_AREA_COMMIT = 0
在提交區域遇到了提交。
TreeArea TREE_AREA_STAGED = 1
在暫存區域遇到了檔。
TreeArea TREE_AREA_UNSTAGED = 2
在未暫存區域遇到了檔。
方法說明
bool _allow_amends() virtual 🔗
Returns whether or not the plugin allows commit amends.
bool _checkout_branch(branch_name: String) virtual required 🔗
檢出 VCS 中的 branch_name 分支。
void _commit(msg: String, amend: bool) virtual 🔗
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.
void _create_branch(branch_name: String) virtual required 🔗
在 VCS 中新建名為 branch_name 的分支。
void _create_remote(remote_name: String, remote_url: String) virtual required 🔗
建立一個名為 remote_name 的新遠端倉庫目標,並將其指向 remote_url。這既可以是 HTTPS 遠端倉庫,也可以是 SSH 遠端倉庫。
void _discard_file(file_path: String) virtual required 🔗
丟棄對位於 file_path 的檔進行的修改。
void _fetch(remote: String) virtual required 🔗
從遠程倉庫 remote 中抓取新修改,但不將修改寫入目前工作目錄。相當於 git fetch。
Array[String] _get_branch_list() virtual required 🔗
獲取 String 字串的 Array 陣列實例,包含在 VCS 中可用的分支名稱。
String _get_current_branch_name() virtual required 🔗
獲取 VCS 中定義的目前分支名稱。
Array[Dictionary] _get_diff(identifier: String, area: int) virtual required 🔗
返回 Dictionary 項的陣列(參見 create_diff_file()、create_diff_hunk()、create_diff_line()、add_line_diffs_into_diff_hunk()、和 add_diff_hunks_into_diff_file()),每項都包含一個差異的資訊。如果 identifier 是檔路徑,則返回呼函式差異;如果它是提交識別字,則返回提交差異。
Array[Dictionary] _get_line_diff(file_path: String, text: String) virtual required 🔗
返回 Dictionary 字典項的 Array 陣列(見 create_diff_hunk()),每一項都包含位於 file_path 的檔與傳入的 text 之間的單行差異。
Array[Dictionary] _get_modified_files_data() virtual required 🔗
返回 Dictionary 字典項的 Array 陣列(見 create_status_file()),每一項都包含專案檔案夾中每個已修改的檔的狀態資料。
Array[Dictionary] _get_previous_commits(max_commits: int) virtual required 🔗
返回 Dictionary 字典項的 Array 陣列(見 create_commit()),每一項都包含一個過去提交的資料。
Array[String] _get_remotes() virtual required 🔗
返回 String 字串的 Array 陣列,每一個都包含 VCS 中配置的一個遠端倉庫的名稱。
String _get_vcs_name() virtual required 🔗
返回底層 VCS 提供方的名稱。
bool _initialize(project_path: String) virtual required 🔗
從編輯器中呼叫時初始化該 VCS 外掛程式。返回該外掛程式是否成功初始化。會在 project_path 初始化 VCS 專案。
void _pull(remote: String) virtual required 🔗
從遠程倉庫拉取修改。這可能會導致合併衝突。
void _push(remote: String, force: bool) virtual required 🔗
將修改推送至遠程倉庫 remote。如果 force 為 true,則會進行強制推送,覆蓋遠端倉庫中現有的修改歷史。
void _remove_branch(branch_name: String) virtual required 🔗
從本地 VCS 中移除一個分支。
void _remove_remote(remote_name: String) virtual required 🔗
從本地 VCS 中移除一個遠端倉庫。
void _set_credentials(username: String, password: String, ssh_public_key_path: String, ssh_private_key_path: String, ssh_passphrase: String) virtual required 🔗
在底層 VCS 中設定使用者認證資訊。使用者名 username 和密碼 password 只會在進行 HTTPS 認證且沒有在遠端倉庫 URL 中給出時使用。SSH 公開金鑰路徑 ssh_public_key_path、SSH 私密金鑰路徑 ssh_private_key_path、SSH 密碼 ssh_passphrase 只會在進行 SSH 認證時使用。
bool _shut_down() virtual required 🔗
關閉 VCS 外掛程式實例。會在使用者關閉編輯器或通過編輯器 UI 關閉該 VCS 外掛程式時呼叫。
void _stage_file(file_path: String) virtual required 🔗
將位於 file_path 的檔案暫存到暫存區。
void _unstage_file(file_path: String) virtual required 🔗
將位於 file_path 的檔從暫存區撤銷到未暫存區。
Dictionary add_diff_hunks_into_diff_file(diff_file: Dictionary, diff_hunks: Array[Dictionary]) 🔗
輔助函式,用於將一組 diff_hunks 新增到 diff_file。
Dictionary add_line_diffs_into_diff_hunk(diff_hunk: Dictionary, line_diffs: Array[Dictionary]) 🔗
輔助函式,用於將一組 line_diffs 新增到 diff_hunk 中。
Dictionary create_commit(msg: String, author: String, id: String, unix_timestamp: int, offset_minutes: int) 🔗
輔助函式, 用於建立一個提交 Dictionary 項。msg 是該提交的提交消息。author 是單個人類可讀的字串,包含所有作者的詳細資訊,例如 VCS 中配置的電子郵件和名稱。無論 VCS 可能以哪種格式為提交提供識別字,id 是該提交的識別字。unix_timestamp 是該提交被建立時的 UTC Unix 時間戳記。offset_minutes 是該提交建立時目前系統時區的偏移量,單位為分鐘。
Dictionary create_diff_file(new_file: String, old_file: String) 🔗
輔助函式,用於建立用來保存新舊檔路徑差異的 Dictionary。
Dictionary create_diff_hunk(old_start: int, new_start: int, old_lines: int, new_lines: int) 🔗
輔助函式,用於建立用於保存差異塊資料的 Dictionary。old_start 是舊文件中的起始行號。new_start 是新檔案中的起始行號。old_lines 是舊檔案中的行數。new_lines 是新檔案中的行數。
Dictionary create_diff_line(new_line_no: int, old_line_no: int, content: String, status: String) 🔗
輔助函式,建立用於保存行差異的 Dictionary。new_line_no 是新檔案中的行號(該行被刪除時可為 -1)。old_line_no 是舊檔案中的行號(該行為新增時可為 -1)。content 為差異文字。status 為保存該行原點的單字元字串。
Dictionary create_status_file(file_path: String, change_type: ChangeType, area: TreeArea) 🔗
輔助函式,用於建立被編輯器用來讀取檔狀態的 Dictionary。
void popup_error(msg: String) 🔗
在編輯器中彈出一條錯誤消息,顯示為來自底層 VCS。使用它來顯示 VCS 特定的錯誤消息。