diff options
author | Hop311 <Hop3114@gmail.com> | 2023-05-17 20:11:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-17 20:11:57 +0200 |
commit | 6c7a1a7c8f55d92882d9364c0ad36a61a3f5614f (patch) | |
tree | 64dd37032c36da8e48d5d519ac840e11cc64dc58 /game/addons/openvic2-plugin | |
parent | af6a96ed26bca3eaa28c6dca635918061fab7c80 (diff) | |
parent | 578eb8c332810656842f72e0bb94bb0d4dcb9f5e (diff) |
Merge pull request #117 from OpenVicProject/openvic-rename
Changed from OpenVic2 to OpenVic
Diffstat (limited to 'game/addons/openvic2-plugin')
-rw-r--r-- | game/addons/openvic2-plugin/ReleaseExportEditorPlugin.gd | 105 | ||||
-rw-r--r-- | game/addons/openvic2-plugin/openvic2-plugin.gd | 12 | ||||
-rw-r--r-- | game/addons/openvic2-plugin/plugin.cfg | 7 |
3 files changed, 0 insertions, 124 deletions
diff --git a/game/addons/openvic2-plugin/ReleaseExportEditorPlugin.gd b/game/addons/openvic2-plugin/ReleaseExportEditorPlugin.gd deleted file mode 100644 index 4e03788..0000000 --- a/game/addons/openvic2-plugin/ReleaseExportEditorPlugin.gd +++ /dev/null @@ -1,105 +0,0 @@ -extends EditorExportPlugin - -var _repo_hash : StringName = "0000000000000000000000000000000000000000" -var _repo_short_hash : StringName = "0000000" -var _repo_tag : StringName = "<tag missing>" -var _repo_release_name : StringName = "<release name missing>" - -func _get_name(): - return "OpenVic2-ReleaseExportEditorPlugin" - -func _export_file(path: String, type: String, features: PackedStringArray) -> void: - if path != "res://src/Utility/GIT_INFO.gd": return - var GitInfoScript : String = "" - _get_commit_long() - _get_commit_short() - _get_tag() - _get_release_name() - GitInfoScript = "class_name _GIT_INFO_\nextends RefCounted\n\n" - GitInfoScript += "const commit_hash : StringName = &\""+ _repo_hash +"\"\n" - GitInfoScript += "const short_hash : StringName = &\""+ _repo_short_hash +"\"\n" - GitInfoScript += "const tag : StringName = &\""+ _repo_tag +"\"\n" - GitInfoScript += "const release_name : StringName = &\""+ _repo_release_name +"\"\n" - add_file(path, GitInfoScript.to_ascii_buffer(), false) - skip() - -# Based on -# https://github.com/godotengine/godot/blob/6ef2f358c741c993b5cdc9680489e2c4f5da25cc/methods.py#L102-L133 -var _cached_hash : StringName = &"" -func _get_commit_hash() -> StringName: - if not _cached_hash.is_empty(): return _cached_hash - - var git_hash := OS.get_environment("OPENVIC2_COMMIT") - if not git_hash.is_empty(): - _cached_hash = git_hash - return git_hash - - var git_folder := "../.git" - - if FileAccess.file_exists(git_folder): - var module_folder := FileAccess.open(git_folder, FileAccess.READ).get_line().strip_edges() - if module_folder.begins_with("gitdir: "): - git_folder = module_folder.substr(8) - - if FileAccess.file_exists(git_folder.path_join("HEAD")): - var head := FileAccess.open(git_folder.path_join("HEAD"), FileAccess.READ).get_line().strip_edges() - if head.begins_with("ref: "): - var ref := head.substr(5) - var parts := git_folder.split("/") - if len(parts) > 2 and parts[len(parts) - 2] == "worktrees": - git_folder = "/".join(parts.slice(0, len(parts) - 2)) - head = git_folder.path_join(ref) - var packedrefs := git_folder.path_join("packed-refs") - if FileAccess.file_exists(head): - git_hash = FileAccess.open(head, FileAccess.READ).get_line().strip_edges() - elif FileAccess.file_exists(packedrefs): - for line in FileAccess.open(packedrefs, FileAccess.READ).get_as_text().split("\n", false): - if line.begins_with("#"): continue - var line_split := line.split(" ") - var line_hash := line_split[0] - var line_ref = line_split[1] - if ref == line_ref: - git_hash = line_hash - break - else: - git_hash = head - - _cached_hash = git_hash - - return git_hash - -func _try_get_tag() -> StringName: - var result : StringName = OS.get_environment("OPENVIC2_TAG") - if result.is_empty(): - var git_output := [] - if OS.execute("git", ["describe", "--tags", "--abbrev=0"], git_output) == -1: - push_warning("Could not retrieve repository tag.") - return &"" - result = git_output[0].trim_suffix("\n") - return result - -func _get_commit_long(): - var result := _get_commit_hash() - if not result.is_empty(): - _repo_hash = result - print("Hash: " + _repo_hash) - -func _get_commit_short(): - var result := _get_commit_hash().substr(0,7) - if not result.is_empty(): - _repo_short_hash = result - print("Short Hash: " + _repo_short_hash) - -func _get_tag(): - var result := _try_get_tag() - if not result.is_empty(): - _repo_tag = result - print("Tag: " + _repo_tag) - -func _get_release_name(): - var result : StringName = OS.get_environment("OPENVIC2_RELEASE") - if result.is_empty(): - result = _try_get_tag() - if not result.is_empty(): - _repo_release_name = result - print("Release Name: " + _repo_release_name) diff --git a/game/addons/openvic2-plugin/openvic2-plugin.gd b/game/addons/openvic2-plugin/openvic2-plugin.gd deleted file mode 100644 index 8cfa4e8..0000000 --- a/game/addons/openvic2-plugin/openvic2-plugin.gd +++ /dev/null @@ -1,12 +0,0 @@ -@tool -extends EditorPlugin - -const ReleaseExportEditorPlugin := preload("res://addons/openvic2-plugin/ReleaseExportEditorPlugin.gd") -var release_export_editor_plugin := ReleaseExportEditorPlugin.new() - -func _enter_tree() -> void: - add_export_plugin(release_export_editor_plugin) - - -func _exit_tree() -> void: - remove_export_plugin(release_export_editor_plugin) diff --git a/game/addons/openvic2-plugin/plugin.cfg b/game/addons/openvic2-plugin/plugin.cfg deleted file mode 100644 index b3e5611..0000000 --- a/game/addons/openvic2-plugin/plugin.cfg +++ /dev/null @@ -1,7 +0,0 @@ -[plugin] - -name="OpenVic2Plugin" -description="" -author="" -version="" -script="openvic2-plugin.gd" |