mirror of
https://github.com/godotengine/godot-git-plugin.git
synced 2026-01-01 01:48:28 +03:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6002fab42 | ||
|
|
d6582fa939 | ||
|
|
259ae989f4 | ||
|
|
2f160a2b79 | ||
|
|
55b09bf0f7 | ||
|
|
ae2f2d3826 | ||
|
|
3ab28b1d33 | ||
|
|
3fc541feb8 | ||
|
|
04602dc5dc | ||
|
|
bb5da70aa4 | ||
|
|
4cb6ec0edd | ||
|
|
34850841fc | ||
|
|
74342b298e |
41
.github/workflows/build.yml
vendored
41
.github/workflows/build.yml
vendored
@@ -2,18 +2,29 @@ name: C/C++ CI
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
env:
|
||||
# Only used for the cache key. Increment version to force clean build.
|
||||
GODOT_BASE_BRANCH: master
|
||||
SCONS_CACHE: ${{ github.workspace }}/.scons-cache/
|
||||
|
||||
jobs:
|
||||
linux-x64:
|
||||
runs-on: ubuntu-18.04
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Setup Godot build cache
|
||||
uses: ./godot-cpp/.github/actions/godot-cache
|
||||
with:
|
||||
cache-name: linux-x86_64
|
||||
continue-on-error: true
|
||||
- name: build-linux-editor-x64
|
||||
run: |
|
||||
git submodule update --init --recursive
|
||||
pip3 install --user scons
|
||||
scons platform=linux target=editor generate_bindings=yes -j $(nproc)
|
||||
ldd demo/addons/godot-git-plugin/linux/*.so
|
||||
- uses: actions/upload-artifact@v2
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: libgit_plugin.linux.x86_64.editor.so-${{ github.sha }}
|
||||
if-no-files-found: error
|
||||
@@ -23,7 +34,13 @@ jobs:
|
||||
windows-x64:
|
||||
runs-on: windows-2019
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Setup Godot build cache
|
||||
uses: ./godot-cpp/.github/actions/godot-cache
|
||||
with:
|
||||
cache-name: windows-x86_64
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: "3.x"
|
||||
@@ -31,11 +48,10 @@ jobs:
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
- name: build-windows-editor-x64
|
||||
run: |
|
||||
git submodule update --init --recursive
|
||||
pip3 install --user scons
|
||||
scons platform=windows target=editor generate_bindings=yes -j $env:NUMBER_OF_PROCESSORS
|
||||
dumpbin /dependents .\demo\addons\godot-git-plugin\win64\*.dll
|
||||
- uses: actions/upload-artifact@v2
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: libgit_plugin.windows.x86_64.editor.dll-${{ github.sha }}
|
||||
if-no-files-found: error
|
||||
@@ -45,14 +61,19 @@ jobs:
|
||||
macos-universal:
|
||||
runs-on: macos-11
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Setup Godot build cache
|
||||
uses: ./godot-cpp/.github/actions/godot-cache
|
||||
with:
|
||||
cache-name: macos-universal
|
||||
- name: build-macos-editor-universal
|
||||
run: |
|
||||
git submodule update --init --recursive
|
||||
brew install scons
|
||||
scons platform=macos target=editor generate_bindings=yes macos_arch=universal use_llvm=yes macos_deployment_target=10.13 -j $(sysctl -n hw.logicalcpu)
|
||||
otool -L demo/addons/godot-git-plugin/macos/*.dylib
|
||||
- uses: actions/upload-artifact@v2
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: libgit_plugin.macos.universal.editor.dylib-${{ github.sha }}
|
||||
if-no-files-found: error
|
||||
|
||||
1
.gitmodules
vendored
1
.gitmodules
vendored
@@ -5,6 +5,7 @@
|
||||
[submodule "libgit2"]
|
||||
path = thirdparty/git2/libgit2
|
||||
url = https://github.com/libgit2/libgit2
|
||||
ignore = untracked
|
||||
[submodule "thirdparty/ssh2/libssh2"]
|
||||
path = thirdparty/ssh2/libssh2
|
||||
url = https://github.com/libssh2/libssh2
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
[configuration]
|
||||
|
||||
entry_symbol = "git_plugin_init"
|
||||
compatibility_minimum = "4.1.0"
|
||||
|
||||
[libraries]
|
||||
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
name="Godot Git Plugin"
|
||||
description="This plugin lets you interact with Git without leaving the Godot editor. More information can be found at https://github.com/godotengine/godot-git-plugin/wiki"
|
||||
author="twaritwaikar"
|
||||
version="v3.0.0-beta1"
|
||||
version="3.1.1"
|
||||
script="godot-git-plugin.gd"
|
||||
|
||||
@@ -10,7 +10,7 @@ config_version=5
|
||||
|
||||
[application]
|
||||
|
||||
config/features=PackedStringArray("4.0")
|
||||
config/features=PackedStringArray("4.1")
|
||||
|
||||
[editor]
|
||||
|
||||
|
||||
Submodule godot-cpp updated: 9d1c396c54...d627942b64
@@ -19,8 +19,8 @@ void uninitialize_git_plugin_module(godot::ModuleInitializationLevel p_level) {
|
||||
|
||||
extern "C" {
|
||||
|
||||
GDExtensionBool GDE_EXPORT git_plugin_init(const GDExtensionInterface *p_interface, const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) {
|
||||
godot::GDExtensionBinding::InitObject init_obj(p_interface, p_library, r_initialization);
|
||||
GDExtensionBool GDE_EXPORT git_plugin_init(const GDExtensionInterfaceGetProcAddress p_address, const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) {
|
||||
godot::GDExtensionBinding::InitObject init_obj(p_address, p_library, r_initialization);
|
||||
|
||||
init_obj.register_initializer(initialize_git_plugin_module);
|
||||
init_obj.register_terminator(uninitialize_git_plugin_module);
|
||||
|
||||
@@ -13,7 +13,7 @@ extern "C" int progress_cb(const char *str, int len, void *data) {
|
||||
char *progress_str = new char[len + 1];
|
||||
std::memcpy(progress_str, str, len);
|
||||
progress_str[len] = '\0';
|
||||
godot::UtilityFunctions::push_warning("remote: ", CString(godot::String(progress_str).strip_edges()).data);
|
||||
godot::UtilityFunctions::push_warning("remote: ", godot::String::utf8(progress_str).strip_edges());
|
||||
delete[] progress_str;
|
||||
|
||||
return 0;
|
||||
@@ -27,10 +27,10 @@ extern "C" int update_cb(const char *refname, const git_oid *a, const git_oid *b
|
||||
|
||||
git_oid_tostr(b_str, short_commit_length, b);
|
||||
if (git_oid_is_zero(a)) {
|
||||
godot::UtilityFunctions::print("* [new] ", CString(godot::String(b_str)).data, " ", CString(godot::String(refname)).data);
|
||||
godot::UtilityFunctions::print("* [new] ", godot::String::utf8(b_str), " ", godot::String::utf8(refname));
|
||||
} else {
|
||||
git_oid_tostr(a_str, short_commit_length, a);
|
||||
godot::UtilityFunctions::print("[updated] ", CString(godot::String(a_str)).data, "...", CString(godot::String(b_str)).data, " ", CString(godot::String(refname)).data);
|
||||
godot::UtilityFunctions::print("[updated] ", godot::String::utf8(a_str), "...", godot::String::utf8(b_str), " ", godot::String::utf8(refname));
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -68,11 +68,11 @@ extern "C" int push_transfer_progress_cb(unsigned int current, unsigned int tota
|
||||
}
|
||||
|
||||
extern "C" int push_update_reference_cb(const char *refname, const char *status, void *data) {
|
||||
godot::String status_str = status;
|
||||
if (status_str == "") {
|
||||
godot::UtilityFunctions::print("[rejected] ", CString(godot::String(refname)).data, " ", CString(status_str).data);
|
||||
if (status != NULL) {
|
||||
godot::String status_str = godot::String::utf8(status);
|
||||
godot::UtilityFunctions::print("[rejected] ", godot::String::utf8(refname), " ", status_str);
|
||||
} else {
|
||||
godot::UtilityFunctions::print("[updated] ", CString(godot::String(refname)).data);
|
||||
godot::UtilityFunctions::print("[updated] ", godot::String::utf8(refname));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -82,16 +82,18 @@ extern "C" int credentials_cb(git_cred **out, const char *url, const char *usern
|
||||
|
||||
godot::String proper_username = username_from_url ? username_from_url : creds->username;
|
||||
|
||||
if (allowed_types & GIT_CREDENTIAL_USERPASS_PLAINTEXT) {
|
||||
return git_cred_userpass_plaintext_new(out, CString(proper_username).data, CString(creds->password).data);
|
||||
if (!creds->ssh_public_key_path.is_empty()) {
|
||||
if (allowed_types & GIT_CREDENTIAL_SSH_KEY) {
|
||||
return git_credential_ssh_key_new(out,
|
||||
CString(proper_username).data,
|
||||
CString(creds->ssh_public_key_path).data,
|
||||
CString(creds->ssh_private_key_path).data,
|
||||
CString(creds->ssh_passphrase).data);
|
||||
}
|
||||
}
|
||||
|
||||
if (allowed_types & GIT_CREDENTIAL_SSH_KEY) {
|
||||
return git_credential_ssh_key_new(out,
|
||||
CString(proper_username).data,
|
||||
CString(creds->ssh_public_key_path).data,
|
||||
CString(creds->ssh_private_key_path).data,
|
||||
CString(creds->ssh_passphrase).data);
|
||||
if (allowed_types & GIT_CREDENTIAL_USERPASS_PLAINTEXT) {
|
||||
return git_cred_userpass_plaintext_new(out, CString(proper_username).data, CString(creds->password).data);
|
||||
}
|
||||
|
||||
if (allowed_types & GIT_CREDENTIAL_USERNAME) {
|
||||
|
||||
@@ -63,10 +63,10 @@ bool GitPlugin::check_errors(int error, godot::String function, godot::String fi
|
||||
message = message + ".";
|
||||
if ((lg2err = git_error_last()) != nullptr && lg2err->message != nullptr) {
|
||||
message = message + " Error " + godot::String::num_int64(error) + ": ";
|
||||
message = message + godot::String(lg2err->message);
|
||||
message = message + godot::String::utf8(lg2err->message);
|
||||
}
|
||||
|
||||
godot::UtilityFunctions::push_error("GitPlugin: ", CString(message).data, " in ", CString(file).data, ":", CString(function).data, "#L", line);
|
||||
godot::UtilityFunctions::push_error("GitPlugin: ", message, " in ", file, ":", function, "#L", line);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -232,9 +232,9 @@ godot::TypedArray<godot::Dictionary> GitPlugin::_get_modified_files_data() {
|
||||
const git_status_entry *entry = git_status_byindex(statuses.get(), i);
|
||||
godot::String path;
|
||||
if (entry->index_to_workdir) {
|
||||
path = entry->index_to_workdir->new_file.path;
|
||||
path = godot::String::utf8(entry->index_to_workdir->new_file.path);
|
||||
} else {
|
||||
path = entry->head_to_index->new_file.path;
|
||||
path = godot::String::utf8(entry->head_to_index->new_file.path);
|
||||
}
|
||||
|
||||
const static int git_status_wt = GIT_STATUS_WT_NEW | GIT_STATUS_WT_MODIFIED | GIT_STATUS_WT_DELETED | GIT_STATUS_WT_TYPECHANGE | GIT_STATUS_WT_RENAMED | GIT_STATUS_CONFLICTED;
|
||||
@@ -245,8 +245,8 @@ godot::TypedArray<godot::Dictionary> GitPlugin::_get_modified_files_data() {
|
||||
}
|
||||
|
||||
if (entry->status & git_status_index) {
|
||||
if (entry->status == GIT_STATUS_INDEX_RENAMED) {
|
||||
godot::String old_path = entry->head_to_index->old_file.path;
|
||||
if (entry->status & GIT_STATUS_INDEX_RENAMED) {
|
||||
godot::String old_path = godot::String::utf8(entry->head_to_index->old_file.path);
|
||||
stats_files.push_back(create_status_file(old_path, map_changes.at(GIT_STATUS_INDEX_DELETED), TREE_AREA_STAGED));
|
||||
stats_files.push_back(create_status_file(path, map_changes.at(GIT_STATUS_INDEX_NEW), TREE_AREA_STAGED));
|
||||
} else {
|
||||
@@ -273,9 +273,9 @@ godot::TypedArray<godot::String> GitPlugin::_get_branch_list() {
|
||||
|
||||
if (git_branch_is_head(ref.get())) {
|
||||
// Always send the current branch as the first branch in list
|
||||
branch_names.push_front(name);
|
||||
branch_names.push_front(godot::String::utf8(name));
|
||||
} else {
|
||||
branch_names.push_back(godot::String(name));
|
||||
branch_names.push_back(godot::String::utf8(name));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ godot::String GitPlugin::_get_current_branch_name() {
|
||||
const char *name = "";
|
||||
GIT2_CALL_R(git_branch_name(&name, branch.get()), "Could not get branch name from current branch reference", "");
|
||||
|
||||
return name;
|
||||
return godot::String::utf8(name);
|
||||
}
|
||||
|
||||
godot::TypedArray<godot::String> GitPlugin::_get_remotes() {
|
||||
@@ -361,7 +361,7 @@ godot::TypedArray<godot::String> GitPlugin::_get_remotes() {
|
||||
|
||||
godot::TypedArray<godot::String> remotes;
|
||||
for (int i = 0; i < remote_array.count; i++) {
|
||||
remotes.push_back(remote_array.strings[i]);
|
||||
remotes.push_back(godot::String::utf8(remote_array.strings[i]));
|
||||
}
|
||||
|
||||
return remotes;
|
||||
@@ -382,10 +382,10 @@ godot::TypedArray<godot::Dictionary> GitPlugin::_get_previous_commits(int32_t ma
|
||||
GIT2_CALL_R(git_commit_lookup(Capture(commit), repo.get(), &oid), "Failed to lookup the commit", commits);
|
||||
|
||||
git_oid_tostr(commit_id, GIT_OID_HEXSZ + 1, git_commit_id(commit.get()));
|
||||
godot::String msg = git_commit_message(commit.get());
|
||||
godot::String msg = godot::String::utf8(git_commit_message(commit.get()));
|
||||
|
||||
const git_signature *sig = git_commit_author(commit.get());
|
||||
godot::String author = godot::String() + sig->name + " <" + sig->email + ">";
|
||||
godot::String author = godot::String::utf8(sig->name) + " <" + godot::String::utf8(sig->email) + ">";
|
||||
|
||||
commits.push_back(create_commit(msg, author, commit_id, sig->when.time, sig->when.offset));
|
||||
}
|
||||
@@ -394,7 +394,7 @@ godot::TypedArray<godot::Dictionary> GitPlugin::_get_previous_commits(int32_t ma
|
||||
}
|
||||
|
||||
void GitPlugin::_fetch(const godot::String &remote) {
|
||||
godot::UtilityFunctions::print("GitPlugin: Performing fetch from ", CString(remote).data);
|
||||
godot::UtilityFunctions::print("GitPlugin: Performing fetch from ", remote);
|
||||
|
||||
git_remote_ptr remote_object;
|
||||
GIT2_CALL(git_remote_lookup(Capture(remote_object), repo.get(), CString(remote).data), "Could not lookup remote \"" + remote + "\"");
|
||||
@@ -418,7 +418,7 @@ void GitPlugin::_fetch(const godot::String &remote) {
|
||||
}
|
||||
|
||||
void GitPlugin::_pull(const godot::String &remote) {
|
||||
godot::UtilityFunctions::print("GitPlugin: Performing pull from ", CString(remote).data);
|
||||
godot::UtilityFunctions::print("GitPlugin: Performing pull from ", remote);
|
||||
|
||||
git_remote_ptr remote_object;
|
||||
GIT2_CALL(git_remote_lookup(Capture(remote_object), repo.get(), CString(remote).data), "Could not lookup remote \"" + remote + "\"");
|
||||
@@ -515,7 +515,7 @@ void GitPlugin::_pull(const godot::String &remote) {
|
||||
}
|
||||
|
||||
void GitPlugin::_push(const godot::String &remote, bool force) {
|
||||
godot::UtilityFunctions::print("GitPlugin: Performing push to ", CString(remote).data);
|
||||
godot::UtilityFunctions::print("GitPlugin: Performing push to ", remote);
|
||||
|
||||
git_remote_ptr remote_object;
|
||||
GIT2_CALL(git_remote_lookup(Capture(remote_object), repo.get(), CString(remote).data), "Could not lookup remote \"" + remote + "\"");
|
||||
@@ -529,7 +529,8 @@ void GitPlugin::_push(const godot::String &remote, bool force) {
|
||||
remote_cbs.push_transfer_progress = &push_transfer_progress_cb;
|
||||
remote_cbs.push_update_reference = &push_update_reference_cb;
|
||||
|
||||
GIT2_CALL(git_remote_connect(remote_object.get(), GIT_DIRECTION_PUSH, &remote_cbs, nullptr, nullptr), "Could not connect to remote \"" + remote + "\". Are your credentials correct? Try using a PAT token (in case you are using Github) as your password");
|
||||
godot::String msg = "Could not connect to remote \"" + remote + "\". Are your credentials correct? Try using a PAT token (in case you are using Github) as your password";
|
||||
GIT2_CALL(git_remote_connect(remote_object.get(), GIT_DIRECTION_PUSH, &remote_cbs, nullptr, nullptr), msg);
|
||||
|
||||
godot::String branch_name = _get_current_branch_name();
|
||||
|
||||
@@ -629,7 +630,7 @@ godot::TypedArray<godot::Dictionary> GitPlugin::_parse_diff(git_diff *diff) {
|
||||
git_patch_ptr patch;
|
||||
GIT2_CALL_R(git_patch_from_diff(Capture(patch), diff, i), "Could not create patch from diff", godot::TypedArray<godot::Dictionary>());
|
||||
|
||||
godot::Dictionary diff_file = create_diff_file(delta->new_file.path, delta->old_file.path);
|
||||
godot::Dictionary diff_file = create_diff_file(godot::String::utf8(delta->new_file.path), godot::String::utf8(delta->old_file.path));
|
||||
|
||||
godot::TypedArray<godot::Dictionary> diff_hunks;
|
||||
for (int j = 0; j < git_patch_num_hunks(patch.get()); j++) {
|
||||
@@ -650,7 +651,7 @@ godot::TypedArray<godot::Dictionary> GitPlugin::_parse_diff(git_diff *diff) {
|
||||
|
||||
godot::String status = " "; // We reserve 1 null terminated space to fill the + or the - character at git_diff_line->origin
|
||||
status[0] = git_diff_line->origin;
|
||||
diff_lines.push_back(create_diff_line(git_diff_line->new_lineno, git_diff_line->old_lineno, godot::String(content), status));
|
||||
diff_lines.push_back(create_diff_line(git_diff_line->new_lineno, git_diff_line->old_lineno, godot::String::utf8(content), status));
|
||||
|
||||
delete[] content;
|
||||
}
|
||||
@@ -680,9 +681,9 @@ bool GitPlugin::_initialize(const godot::String &project_path) {
|
||||
|
||||
git_buf discovered_repo_path = {};
|
||||
if (git_repository_discover(&discovered_repo_path, CString(project_path).data, 1, nullptr) == 0) {
|
||||
repo_project_path = godot::String(discovered_repo_path.ptr);
|
||||
repo_project_path = godot::String::utf8(discovered_repo_path.ptr);
|
||||
|
||||
godot::UtilityFunctions::print("Found a repository at " + godot::String(discovered_repo_path.ptr) + ".");
|
||||
godot::UtilityFunctions::print("Found a repository at " + repo_project_path + ".");
|
||||
git_buf_dispose(&discovered_repo_path);
|
||||
} else {
|
||||
repo_project_path = project_path;
|
||||
@@ -690,7 +691,7 @@ bool GitPlugin::_initialize(const godot::String &project_path) {
|
||||
godot::UtilityFunctions::push_warning("Could not find any higher level repositories.");
|
||||
}
|
||||
|
||||
godot::UtilityFunctions::print("Selected repository path: " + godot::String(repo_project_path) + ".");
|
||||
godot::UtilityFunctions::print("Selected repository path: " + repo_project_path + ".");
|
||||
GIT2_CALL_R(git_repository_init(Capture(repo), CString(repo_project_path).data, 0), "Could not initialize repository", false);
|
||||
|
||||
git_reference_ptr head;
|
||||
|
||||
Reference in New Issue
Block a user