gdharness 1.0.11 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,6 +13,8 @@ const Read = preload("reading.gd")
13
13
  const DEFAULT_URL: String = "ws://127.0.0.1:6505/godot"
14
14
  ## Written beside the addon by the install, so it names the version this copy came from.
15
15
  const VERSION_MARKER: String = "res://addons/gdharness_editor/.gdharness-version"
16
+ ## Written beside it, kept in step with `DIGEST_MARKER` in src/setup.ts.
17
+ const DIGEST_MARKER: String = "res://addons/gdharness_editor/.gdharness-digest"
16
18
  ## Written by the server that serves this project, saying where its bridge actually is. Kept in
17
19
  ## step with `announcementPath` in src/bridge-announce.ts.
18
20
  const ANNOUNCEMENT: String = "res://.godot/gdharness-bridge.json"
@@ -70,6 +72,8 @@ var server_url: String = DEFAULT_URL
70
72
  ## What this copy was when it loaded, which is what the editor is running until it is restarted.
71
73
  ## See [method _loaded_version] for why it is held rather than read when it is wanted.
72
74
  var version_at_load: String = ""
75
+ ## The digest of the editor addon code this copy loaded, held for the same reason.
76
+ var digest_at_load: String = ""
73
77
 
74
78
  var _is_connected: bool = false
75
79
  var _reconnect_timer: Timer
@@ -98,6 +102,7 @@ var _connecting_for: float = 0.0
98
102
  func _ready() -> void:
99
103
  _project_path = ProjectSettings.globalize_path("res://")
100
104
  version_at_load = _loaded_version()
105
+ digest_at_load = _loaded_digest()
101
106
  _keep_breakpoints_through_sessions()
102
107
  OS.set_environment(EDITOR_PID_VARIABLE, str(OS.get_process_id()))
103
108
 
@@ -290,6 +295,7 @@ func _handle_connect() -> void:
290
295
  "type": "godot_ready",
291
296
  "project_path": _project_path,
292
297
  "addon_version": version_at_load,
298
+ "addon_digest": digest_at_load,
293
299
  "editor_pid": OS.get_process_id(),
294
300
  "lsp_port": _serves(LSP_ASKED, LSP_SETTING),
295
301
  "dap_port": _serves(DAP_ASKED, DAP_SETTING),
@@ -408,9 +414,19 @@ func _serving(setting: String) -> int:
408
414
  ## and `addonIsStale` reporting false over an editor still running the old code, which is exactly
409
415
  ## what it exists to catch.
410
416
  func _loaded_version() -> String:
411
- if not FileAccess.file_exists(VERSION_MARKER):
417
+ return _read_marker(VERSION_MARKER)
418
+
419
+
420
+ ## The same for the digest of the editor addon code, which an upgrade that leaves the code alone
421
+ ## rewrites unchanged, so the server can tell an editor that needs a restart from one that does not.
422
+ func _loaded_digest() -> String:
423
+ return _read_marker(DIGEST_MARKER)
424
+
425
+
426
+ func _read_marker(path: String) -> String:
427
+ if not FileAccess.file_exists(path):
412
428
  return ""
413
- var file: FileAccess = FileAccess.open(VERSION_MARKER, FileAccess.READ)
429
+ var file: FileAccess = FileAccess.open(path, FileAccess.READ)
414
430
  if file == null:
415
431
  return ""
416
432
  var text: String = file.get_as_text().strip_edges()