EditorVCSInterface.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="EditorVCSInterface" inherits="Object" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
  3. <brief_description>
  4. Version Control System (VCS) interface, which reads and writes to the local VCS in use.
  5. </brief_description>
  6. <description>
  7. 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.
  8. </description>
  9. <tutorials>
  10. </tutorials>
  11. <methods>
  12. <method name="_checkout_branch" qualifiers="virtual">
  13. <return type="bool" />
  14. <argument index="0" name="branch_name" type="String" />
  15. <description>
  16. Checks out a [code]branch_name[/code] in the VCS.
  17. </description>
  18. </method>
  19. <method name="_commit" qualifiers="virtual">
  20. <return type="void" />
  21. <argument index="0" name="msg" type="String" />
  22. <description>
  23. Commits the currently staged changes and applies the commit [code]msg[/code] to the resulting commit.
  24. </description>
  25. </method>
  26. <method name="_create_branch" qualifiers="virtual">
  27. <return type="void" />
  28. <argument index="0" name="branch_name" type="String" />
  29. <description>
  30. Creates a new branch named [code]branch_name[/code] in the VCS.
  31. </description>
  32. </method>
  33. <method name="_create_remote" qualifiers="virtual">
  34. <return type="void" />
  35. <argument index="0" name="remote_name" type="String" />
  36. <argument index="1" name="remote_url" type="String" />
  37. <description>
  38. 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.
  39. </description>
  40. </method>
  41. <method name="_discard_file" qualifiers="virtual">
  42. <return type="void" />
  43. <argument index="0" name="file_path" type="String" />
  44. <description>
  45. Discards the changes made in file present at [code]file_path[/code].
  46. </description>
  47. </method>
  48. <method name="_fetch" qualifiers="virtual">
  49. <return type="void" />
  50. <argument index="0" name="remote" type="String" />
  51. <description>
  52. Fetches new changes from the remote, but doesn't write changes to the current working directory. Equivalent to [code]git fetch[/code].
  53. </description>
  54. </method>
  55. <method name="_get_branch_list" qualifiers="virtual">
  56. <return type="Array" />
  57. <description>
  58. Gets an instance of an [Array] of [String]s containing available branch names in the VCS.
  59. </description>
  60. </method>
  61. <method name="_get_current_branch_name" qualifiers="virtual">
  62. <return type="String" />
  63. <description>
  64. Gets the current branch name defined in the VCS.
  65. </description>
  66. </method>
  67. <method name="_get_diff" qualifiers="virtual">
  68. <return type="Array" />
  69. <argument index="0" name="identifier" type="String" />
  70. <argument index="1" name="area" type="int" />
  71. <description>
  72. 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.
  73. </description>
  74. </method>
  75. <method name="_get_line_diff" qualifiers="virtual">
  76. <return type="Array" />
  77. <argument index="0" name="file_path" type="String" />
  78. <argument index="1" name="text" type="String" />
  79. <description>
  80. 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.
  81. </description>
  82. </method>
  83. <method name="_get_modified_files_data" qualifiers="virtual">
  84. <return type="Array" />
  85. <description>
  86. Returns an [Array] of [Dictionary] items (see [method create_status_file]), each containing the status data of every modified file in the project folder.
  87. </description>
  88. </method>
  89. <method name="_get_previous_commits" qualifiers="virtual">
  90. <return type="Array" />
  91. <argument index="0" name="max_commits" type="int" />
  92. <description>
  93. Returns an [Array] of [Dictionary] items (see [method create_commit]), each containing the data for a past commit.
  94. </description>
  95. </method>
  96. <method name="_get_remotes" qualifiers="virtual">
  97. <return type="Array" />
  98. <description>
  99. Returns an [Array] of [String]s, each containing the name of a remote configured in the VCS.
  100. </description>
  101. </method>
  102. <method name="_get_vcs_name" qualifiers="virtual">
  103. <return type="String" />
  104. <description>
  105. Returns the name of the underlying VCS provider.
  106. </description>
  107. </method>
  108. <method name="_initialize" qualifiers="virtual">
  109. <return type="bool" />
  110. <argument index="0" name="project_path" type="String" />
  111. <description>
  112. 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].
  113. </description>
  114. </method>
  115. <method name="_pull" qualifiers="virtual">
  116. <return type="void" />
  117. <argument index="0" name="remote" type="String" />
  118. <description>
  119. Pulls changes from the remote. This can give rise to merge conflicts.
  120. </description>
  121. </method>
  122. <method name="_push" qualifiers="virtual">
  123. <return type="void" />
  124. <argument index="0" name="remote" type="String" />
  125. <argument index="1" name="force" type="bool" />
  126. <description>
  127. 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.
  128. </description>
  129. </method>
  130. <method name="_remove_branch" qualifiers="virtual">
  131. <return type="void" />
  132. <argument index="0" name="branch_name" type="String" />
  133. <description>
  134. Remove a branch from the local VCS.
  135. </description>
  136. </method>
  137. <method name="_remove_remote" qualifiers="virtual">
  138. <return type="void" />
  139. <argument index="0" name="remote_name" type="String" />
  140. <description>
  141. Remove a remote from the local VCS.
  142. </description>
  143. </method>
  144. <method name="_set_credentials" qualifiers="virtual">
  145. <return type="void" />
  146. <argument index="0" name="username" type="String" />
  147. <argument index="1" name="password" type="String" />
  148. <argument index="2" name="ssh_public_key_path" type="String" />
  149. <argument index="3" name="ssh_private_key_path" type="String" />
  150. <argument index="4" name="ssh_passphrase" type="String" />
  151. <description>
  152. 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.
  153. </description>
  154. </method>
  155. <method name="_shut_down" qualifiers="virtual">
  156. <return type="bool" />
  157. <description>
  158. Shuts down VCS plugin instance. Called when the user either closes the editor or shuts down the VCS plugin through the editor UI.
  159. </description>
  160. </method>
  161. <method name="_stage_file" qualifiers="virtual">
  162. <return type="void" />
  163. <argument index="0" name="file_path" type="String" />
  164. <description>
  165. Stages the file present at [code]file_path[/code] to the staged area.
  166. </description>
  167. </method>
  168. <method name="_unstage_file" qualifiers="virtual">
  169. <return type="void" />
  170. <argument index="0" name="file_path" type="String" />
  171. <description>
  172. Unstages the file present at [code]file_path[/code] from the staged area to the unstaged area.
  173. </description>
  174. </method>
  175. <method name="add_diff_hunks_into_diff_file">
  176. <return type="Dictionary" />
  177. <argument index="0" name="diff_file" type="Dictionary" />
  178. <argument index="1" name="diff_hunks" type="Array" />
  179. <description>
  180. Helper function to add an array of [code]diff_hunks[/code] into a [code]diff_file[/code].
  181. </description>
  182. </method>
  183. <method name="add_line_diffs_into_diff_hunk">
  184. <return type="Dictionary" />
  185. <argument index="0" name="diff_hunk" type="Dictionary" />
  186. <argument index="1" name="line_diffs" type="Array" />
  187. <description>
  188. Helper function to add an array of [code]line_diffs[/code] into a [code]diff_hunk[/code].
  189. </description>
  190. </method>
  191. <method name="create_commit">
  192. <return type="Dictionary" />
  193. <argument index="0" name="msg" type="String" />
  194. <argument index="1" name="author" type="String" />
  195. <argument index="2" name="id" type="String" />
  196. <argument index="3" name="unix_timestamp" type="int" />
  197. <argument index="4" name="offset_minutes" type="int" />
  198. <description>
  199. Helper function to create a commit [Dictionary] item. [code]msg[/code] is the commit message of the commit. [code]author[/code] is a single human-readable string containing all 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]unix_timestamp[/code] is the UTC Unix timestamp of when the commit was created. [code]offset_minutes[/code] is the timezone offset in minutes, recorded from the system timezone where the commit was created.
  200. </description>
  201. </method>
  202. <method name="create_diff_file">
  203. <return type="Dictionary" />
  204. <argument index="0" name="new_file" type="String" />
  205. <argument index="1" name="old_file" type="String" />
  206. <description>
  207. Helper function to create a [code]Dictionary[/code] for storing old and new diff file paths.
  208. </description>
  209. </method>
  210. <method name="create_diff_hunk">
  211. <return type="Dictionary" />
  212. <argument index="0" name="old_start" type="int" />
  213. <argument index="1" name="new_start" type="int" />
  214. <argument index="2" name="old_lines" type="int" />
  215. <argument index="3" name="new_lines" type="int" />
  216. <description>
  217. 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.
  218. </description>
  219. </method>
  220. <method name="create_diff_line">
  221. <return type="Dictionary" />
  222. <argument index="0" name="new_line_no" type="int" />
  223. <argument index="1" name="old_line_no" type="int" />
  224. <argument index="2" name="content" type="String" />
  225. <argument index="3" name="status" type="String" />
  226. <description>
  227. 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]status[/code] is a single character string which stores the line origin.
  228. </description>
  229. </method>
  230. <method name="create_status_file">
  231. <return type="Dictionary" />
  232. <argument index="0" name="file_path" type="String" />
  233. <argument index="1" name="change_type" type="int" enum="EditorVCSInterface.ChangeType" />
  234. <argument index="2" name="area" type="int" enum="EditorVCSInterface.TreeArea" />
  235. <description>
  236. Helper function to create a [code]Dictionary[/code] used by editor to read the status of a file.
  237. </description>
  238. </method>
  239. <method name="popup_error">
  240. <return type="void" />
  241. <argument index="0" name="msg" type="String" />
  242. <description>
  243. Pops up an error message in the edior.
  244. </description>
  245. </method>
  246. </methods>
  247. <constants>
  248. <constant name="CHANGE_TYPE_NEW" value="0" enum="ChangeType">
  249. A new file has been added.
  250. </constant>
  251. <constant name="CHANGE_TYPE_MODIFIED" value="1" enum="ChangeType">
  252. An earlier added file has been modified.
  253. </constant>
  254. <constant name="CHANGE_TYPE_RENAMED" value="2" enum="ChangeType">
  255. An earlier added file has been renamed.
  256. </constant>
  257. <constant name="CHANGE_TYPE_DELETED" value="3" enum="ChangeType">
  258. An earlier added file has been deleted.
  259. </constant>
  260. <constant name="CHANGE_TYPE_TYPECHANGE" value="4" enum="ChangeType">
  261. An earlier added file has been typechanged.
  262. </constant>
  263. <constant name="CHANGE_TYPE_UNMERGED" value="5" enum="ChangeType">
  264. A file is left unmerged.
  265. </constant>
  266. <constant name="TREE_AREA_COMMIT" value="0" enum="TreeArea">
  267. A commit is encountered from the commit area.
  268. </constant>
  269. <constant name="TREE_AREA_STAGED" value="1" enum="TreeArea">
  270. A file is encountered from the staged area.
  271. </constant>
  272. <constant name="TREE_AREA_UNSTAGED" value="2" enum="TreeArea">
  273. A file is encountered from the unstaged area.
  274. </constant>
  275. </constants>
  276. </class>