diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3e50ecfa..6012ea1d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,7 +5,7 @@ on: [push, pull_request] env: # Only used for the cache key. Increment version to force clean build. GODOT_BASE_BRANCH: master - SCONSFLAGS: target=editor build_profile=build_profile.json api_version=4.3 + SCONSFLAGS: target=editor build_profile=build_profile.json api_version=4.7 SCONS_CACHE: ${{ github.workspace }}/.scons-cache/ jobs: diff --git a/godot-cpp b/godot-cpp index 58d1de72..5ffd70e3 160000 --- a/godot-cpp +++ b/godot-cpp @@ -1 +1 @@ -Subproject commit 58d1de720b8ffe9f8ffcdfe3a85148582cfd2e74 +Subproject commit 5ffd70e34d0ab87009a9f0ffa3361bc8f4b09731 diff --git a/godot-git-plugin/src/git_plugin.cpp b/godot-git-plugin/src/git_plugin.cpp index b4a34ce8..352e662d 100644 --- a/godot-git-plugin/src/git_plugin.cpp +++ b/godot-git-plugin/src/git_plugin.cpp @@ -91,7 +91,7 @@ void GitPlugin::_discard_file(const godot::String &file_path) { GIT2_CALL(git_checkout_index(repo.get(), nullptr, &opts), "Could not checkout index"); } -void GitPlugin::_commit(const godot::String &msg) { +void GitPlugin::_commit(const godot::String &msg, bool amend) { git_index_ptr repo_index; GIT2_CALL(git_repository_index(Capture(repo_index), repo.get()), "Could not get repository index"); @@ -115,19 +115,33 @@ void GitPlugin::_commit(const godot::String &msg) { git_oid new_commit_id; if (!has_merge) { - GIT2_CALL( - git_commit_create_v( - &new_commit_id, - repo.get(), - "HEAD", - default_sign.get(), - default_sign.get(), - "UTF-8", - CString(msg).data, - tree.get(), - parent_commit.get() ? 1 : 0, - parent_commit.get()), - "Could not create commit"); + if (amend) { + GIT2_CALL( + git_commit_amend( + &new_commit_id, + parent_commit.get(), + "HEAD", + default_sign.get(), + default_sign.get(), + "UTF-8", + CString(msg).data, + tree.get()), + "Could not create amend commit"); + } else { + GIT2_CALL( + git_commit_create_v( + &new_commit_id, + repo.get(), + "HEAD", + default_sign.get(), + default_sign.get(), + "UTF-8", + CString(msg).data, + tree.get(), + parent_commit.get() ? 1 : 0, + parent_commit.get()), + "Could not create commit"); + } } else { git_commit_ptr fetchhead_commit; GIT2_CALL(git_commit_lookup(Capture(fetchhead_commit), repo.get(), &pull_merge_oid), "Could not lookup commit pointed to by HEAD"); @@ -151,6 +165,10 @@ void GitPlugin::_commit(const godot::String &msg) { } } +bool GitPlugin::_allow_amends() { + return true; +} + void GitPlugin::_stage_file(const godot::String &file_path) { CString c_path(file_path); char *paths[] = { c_path.data }; diff --git a/godot-git-plugin/src/git_plugin.h b/godot-git-plugin/src/git_plugin.h index 1ec17dac..cb5e982c 100644 --- a/godot-git-plugin/src/git_plugin.h +++ b/godot-git-plugin/src/git_plugin.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "git_callbacks.h" #include "git_wrappers.h" @@ -41,7 +42,8 @@ class GitPlugin : public godot::EditorVCSInterface { void _stage_file(const godot::String &file_path) override; void _unstage_file(const godot::String &file_path) override; void _discard_file(const godot::String &file_path) override; - void _commit(const godot::String &msg) override; + void _commit(const godot::String &msg, bool amend) override; + bool _allow_amends() override; godot::TypedArray _get_diff(const godot::String &identifier, int32_t area) override; bool _shut_down() override; godot::String _get_vcs_name() override;