mirror of
https://github.com/godotengine/godot-git-plugin.git
synced 2026-01-01 01:48:28 +03:00
Compare commits
50 Commits
v1.0-alpha
...
v1.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13c8905f72 | ||
|
|
04cab3e227 | ||
|
|
62247870dc | ||
|
|
b1ac091571 | ||
|
|
aa3d85d970 | ||
|
|
b484d1eb3b | ||
|
|
923818997d | ||
|
|
933fb7b7d0 | ||
|
|
cdbcbf8710 | ||
|
|
da42fb3896 | ||
|
|
d915d53e31 | ||
|
|
0388ca39d5 | ||
|
|
db05e54d00 | ||
|
|
07876bff06 | ||
|
|
827dabced8 | ||
|
|
7bdda124aa | ||
|
|
5ddb2d44e5 | ||
|
|
7e57104764 | ||
|
|
b44a9c29a9 | ||
|
|
17dc47e151 | ||
|
|
19627c4063 | ||
|
|
f1feb86c42 | ||
|
|
271fc3e996 | ||
|
|
20e1148d39 | ||
|
|
80fa3f185f | ||
|
|
3fc9aa263c | ||
|
|
6ab8845dd2 | ||
|
|
3364a0ef16 | ||
|
|
cc512c0a17 | ||
|
|
f0a5bf16d9 | ||
|
|
02d3df348f | ||
|
|
4908788e24 | ||
|
|
6dbac88d8f | ||
|
|
bed4e799d6 | ||
|
|
ba4a907f89 | ||
|
|
f1e8e0ac1d | ||
|
|
990ccfd0bc | ||
|
|
7dec368991 | ||
|
|
23af5c9f50 | ||
|
|
c71c5c15be | ||
|
|
c2485c1346 | ||
|
|
c72509109b | ||
|
|
ee3c9c9746 | ||
|
|
0bf806c508 | ||
|
|
5b2d8d48c3 | ||
|
|
a1d32d04bb | ||
|
|
066e951e2f | ||
|
|
b20bde7d3e | ||
|
|
0e4f8acd3d | ||
|
|
531495001e |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -27,9 +27,5 @@ build/
|
||||
|
||||
# Binaries for distribution
|
||||
!/demo/bin/
|
||||
!libgitapi.dll
|
||||
!libgitapi.so
|
||||
!libgitapi.dylib
|
||||
!git2.lib
|
||||
!libgit.a
|
||||
|
||||
|
||||
2
.gitmodules
vendored
2
.gitmodules
vendored
@@ -1,3 +1,3 @@
|
||||
[submodule "godot-cpp"]
|
||||
path = godot-cpp
|
||||
url = https://github.com/IronicallySerious/godot-cpp
|
||||
url = https://github.com/GodotNativeTools/godot-cpp
|
||||
|
||||
57
.travis.yml
Normal file
57
.travis.yml
Normal file
@@ -0,0 +1,57 @@
|
||||
language: cpp
|
||||
dist: xenial
|
||||
osx_image: xcode10.1
|
||||
|
||||
env:
|
||||
global:
|
||||
- SCONS_CACHE="$HOME/.scons_cache"
|
||||
- SCONS_CACHE_LIMIT=1024
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $SCONS_CACHE
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- name: Linux Debug
|
||||
os: linux
|
||||
compiler: gcc
|
||||
env: TARGET=debug PLATFORM=x11
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- llvm-toolchain-xenial-6.0
|
||||
packages:
|
||||
[scons, pkg-config, build-essential, p7zip-full]
|
||||
|
||||
- name: Linux Release
|
||||
os: linux
|
||||
compiler: gcc
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
[scons, pkg-config, build-essential, p7zip-full]
|
||||
env: TARGET=release PLATFORM=x11
|
||||
|
||||
install:
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
|
||||
brew update;
|
||||
brew install scons p7zip;
|
||||
fi
|
||||
|
||||
- if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
|
||||
curl -LO https://downloads.sourceforge.net/project/scons/scons-local/3.0.5/scons-local-3.0.5.zip;
|
||||
unzip scons-local-3.0.5.zip;
|
||||
fi
|
||||
|
||||
script:
|
||||
- if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
|
||||
export SCONS="./scons.bat";
|
||||
/c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio/2017/BuildTools/Common7/Tools/VsDevCmd.bat;
|
||||
./build_libs.bat $TARGET;
|
||||
else
|
||||
export SCONS="scons";
|
||||
./build_libs.sh $TARGET;
|
||||
fi
|
||||
|
||||
- $SCONS platform=$PLATFORM target=$TARGET $SCONS_FLAGS;
|
||||
21
LICENSE
Normal file
21
LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2016-2019 The Godot Engine community
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
25
README.md
25
README.md
@@ -1,20 +1,21 @@
|
||||
# GDNative Based Git Plugin for Godot Version Control Editor Plugin
|
||||
Implements the proxy end-points for the `EditorVCSInterface` API in the Godot Engine Editor. Uses [libgit2](https://libgit2.org) at its backend to simulate Git in code.
|
||||
|
||||
## Installation Instructions
|
||||
|
||||
1. Plugin binary releases for Linux & Windows are here: <https://github.com/godotengine/godot-git-plugin/releases>
|
||||
2. Installation instructions are here: https://github.com/godotengine/godot-git-plugin/wiki
|
||||
|
||||
## Build Instructions
|
||||
|
||||
> Replace `Release` with `Debug` for a debug build.
|
||||
|
||||
### Windows
|
||||
1. Open `build.bat` as text.
|
||||
2. Edit the relative paths to the Godot binary and from the Godot binary directory to this repository's directory in line 1 and line 2.
|
||||
3. Run `build.bat`.
|
||||
4. Run `cd ..` because the build file leaves you one level deeper in the repository.
|
||||
5. Load the x64 command prompt: `x64 Native Tools Command Prompt for VS 2017`.
|
||||
6. Run `scons platform=windows`
|
||||
1. Load the x64 command prompt: `x64 Native Tools Command Prompt for VS 20XX`.
|
||||
2. Run `build_libs.bat Release`.
|
||||
3. Run `scons platform=windows target=release`
|
||||
|
||||
### Linux
|
||||
1. Open `build.sh` as text.
|
||||
2. Edit the relative paths to the Godot binary and from the Godot binary directory to this repository's directory in line 1 and line 2.
|
||||
3. Prepare script for execution: `chmod 755 build.sh`
|
||||
4. Run ```. ./build.sh```.
|
||||
5. Run `cd ..` because the build file leaves you one level deeper in the repository.
|
||||
6. Run `scons platform=x11`.
|
||||
1. Prepare script for execution: `chmod 755 build_libs.sh`
|
||||
2. Run ```. ./build_libs.sh Release```.
|
||||
3. Run `scons platform=x11 target=release`.
|
||||
|
||||
@@ -48,7 +48,7 @@ if env['platform'] == "osx":
|
||||
env.Append(CCFLAGS = ['-g','-O2', '-arch', 'x86_64'])
|
||||
env.Append(LINKFLAGS = ['-arch', 'x86_64'])
|
||||
else:
|
||||
env.Append(CCFLAGS = ['-g','-O3', '-arch', 'x86_64'])
|
||||
env.Append(CCFLAGS = ['-g','-O3', '-arch', 'x86_64', '-std=c++17'])
|
||||
env.Append(LINKFLAGS = ['-arch', 'x86_64'])
|
||||
|
||||
elif env['platform'] in ('x11', 'linux'):
|
||||
@@ -69,6 +69,7 @@ elif env['platform'] == "windows":
|
||||
env.Append(ENV = os.environ)
|
||||
|
||||
env.Append(CCFLAGS = ['-DWIN32', '-D_WIN32', '-D_WINDOWS', '-W3', '-GR', '-D_CRT_SECURE_NO_WARNINGS'])
|
||||
env.Append(LIBS=['Advapi32'])
|
||||
if env['target'] in ('debug', 'd'):
|
||||
env.Append(CCFLAGS = ['-EHsc', '-D_DEBUG', '-MDd'])
|
||||
else:
|
||||
@@ -76,8 +77,10 @@ elif env['platform'] == "windows":
|
||||
|
||||
if env['target'] in ('debug', 'd'):
|
||||
cpp_library += '.debug'
|
||||
env['target_path'] += 'debug/'
|
||||
else:
|
||||
cpp_library += '.release'
|
||||
env['target_path'] += 'release/'
|
||||
|
||||
cpp_library += '.' + str(bits)
|
||||
|
||||
|
||||
20
appveyor.yml
Normal file
20
appveyor.yml
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- vs_version: 15
|
||||
|
||||
os: Visual Studio 2017
|
||||
|
||||
configuration:
|
||||
- Release
|
||||
- Debug
|
||||
|
||||
platform:
|
||||
- x64
|
||||
|
||||
install:
|
||||
- call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
|
||||
- curl -LO https://downloads.sourceforge.net/project/scons/scons-local/3.0.5/scons-local-3.0.5.zip
|
||||
- unzip scons-local-3.0.5.zip
|
||||
- ./build_libs.bat %configuration%
|
||||
- scons platform=windows target=%configuration%
|
||||
@@ -1,9 +0,0 @@
|
||||
set GODOT_PATH_RELATIVE_TO_PLUGIN="..\godot\bin"
|
||||
set GIT_PLUGIN_RELATIVE_TO_GODOT="..\..\godot-git-plugin\"
|
||||
git submodule init
|
||||
git submodule update --init --recursive
|
||||
cd %GODOT_PATH_RELATIVE_TO_PLUGIN%
|
||||
godot.windows.tools.64.exe --gdnative-generate-json-api api.json
|
||||
copy api.json %GIT_PLUGIN_RELATIVE_TO_GODOT%\api.json /Y
|
||||
cd %GIT_PLUGIN_RELATIVE_TO_GODOT%\godot-cpp\
|
||||
scons platform=windows generate_bindings=yes use_custom_api_file=yes custom_api_file=../api.json bits=64
|
||||
10
build.sh
10
build.sh
@@ -1,10 +0,0 @@
|
||||
GODOT_PATH_RELATIVE_TO_PLUGIN="../godot/bin";
|
||||
GIT_PLUGIN_RELATIVE_TO_GODOT="../../godot-git-plugin/";
|
||||
git submodule init;
|
||||
git submodule update --init --recursive;
|
||||
cd $GODOT_PATH_RELATIVE_TO_PLUGIN;
|
||||
./godot.x11.tools.64 --gdnative-generate-json-api api.json;
|
||||
cp api.json $GIT_PLUGIN_RELATIVE_TO_GODOT/api.json;
|
||||
cd $GIT_PLUGIN_RELATIVE_TO_GODOT;
|
||||
cd godot-cpp/;
|
||||
scons platform=linux generate_bindings=yes use_custom_api_file=yes custom_api_file=../api.json bits=64;
|
||||
15
build_libs.bat
Normal file
15
build_libs.bat
Normal file
@@ -0,0 +1,15 @@
|
||||
git submodule init
|
||||
git submodule update --init --recursive
|
||||
|
||||
cd godot-git-plugin\thirdparty\libgit2\
|
||||
mkdir build
|
||||
cd build\
|
||||
del /F CMakeCache.txt
|
||||
cmake ..
|
||||
cmake --build .
|
||||
cd ../../../../
|
||||
copy godot-git-plugin\thirdparty\libgit2\build\%1\git2.lib demo\bin\win64\
|
||||
|
||||
cd godot-cpp\
|
||||
scons platform=windows target=%1 generate_bindings=yes bits=64
|
||||
cd ..
|
||||
16
build_libs.sh
Executable file
16
build_libs.sh
Executable file
@@ -0,0 +1,16 @@
|
||||
git submodule init;
|
||||
git submodule update --init --recursive;
|
||||
|
||||
cd godot-git-plugin/thirdparty/libgit2/
|
||||
mkdir build
|
||||
cd build/
|
||||
rm CMakeCache.txt
|
||||
cmake ..
|
||||
cmake --build .
|
||||
cd ../../../../
|
||||
mv godot-git-plugin/thirdparty/libgit2/build/libgit2.a demo/bin/x11/libgit2.a
|
||||
|
||||
cd godot-cpp/;
|
||||
apt-get install scons
|
||||
scons platform=linux target=$1 generate_bindings=yes bits=64;
|
||||
cd ..
|
||||
8
demo/.gitattributes
vendored
8
demo/.gitattributes
vendored
@@ -1,17 +1,17 @@
|
||||
# Set the default behavior, in case people don't have core.autocrlf set.
|
||||
* text=auto
|
||||
|
||||
#Explicitly declare text files you want to always be normalized and converted
|
||||
#to native line endings on checkout.
|
||||
# Explicitly declare text files you want to always be normalized and converted
|
||||
# to native line endings on checkout.
|
||||
*.cpp text
|
||||
*.c text
|
||||
*.h text
|
||||
*.gd text
|
||||
*.cs text
|
||||
|
||||
#Declare files that will always have CRLF line endings on checkout.
|
||||
# Declare files that will always have CRLF line endings on checkout.
|
||||
*.sln text eol=crlf
|
||||
|
||||
#Denote all files that are truly binary and should not be modified.
|
||||
# Denote all files that are truly binary and should not be modified.
|
||||
*.png binary
|
||||
*.jpg binary
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -7,8 +7,8 @@ reloadable=false
|
||||
|
||||
[entry]
|
||||
|
||||
Windows.64="res://bin/win64/libgitapi.dll"
|
||||
X11.64="res://bin/x11/libgitapi.so"
|
||||
Windows.64="res://bin/win64/release/libgitapi.dll"
|
||||
X11.64="res://bin/x11/release/libgitapi.so"
|
||||
|
||||
[dependencies]
|
||||
|
||||
|
||||
Submodule godot-cpp updated: cdd50260d0...c2f765e49c
@@ -22,32 +22,32 @@
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{574C5E6A-EDEC-41A6-BDF7-4106698F80B0}</ProjectGuid>
|
||||
<RootNamespace>godotgitplugin</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
@@ -73,10 +73,18 @@
|
||||
<IncludePath>D:\CPP Projects\godot-git-plugin\godot-git-plugin\thirdparty\libgit2\include;.\src\;..\godot-cpp\godot_headers\;..\godot-cpp\include\gen;..\godot-cpp\include\core\;..\godot-cpp\include\;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>D:\CPP Projects\godot-git-plugin\demo\bin\win64;..\godot-cpp\bin;$(LibraryPath)</LibraryPath>
|
||||
<SourcePath>.\src\;$(VC_SourcePath);</SourcePath>
|
||||
<OutDir>$(SolutionDir)..\demo\bin\win64\</OutDir>
|
||||
<OutDir>$(SolutionDir)..\demo\bin\win64\debug\</OutDir>
|
||||
<IntDir>$(SolutionDir)..\demo\bin\win64\intermediate\</IntDir>
|
||||
<TargetName>libgitapi</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<IncludePath>D:\CPP Projects\godot-git-plugin\godot-git-plugin\thirdparty\libgit2\include;.\src\;..\godot-cpp\godot_headers\;..\godot-cpp\include\gen;..\godot-cpp\include\core\;..\godot-cpp\include\;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>D:\CPP Projects\godot-git-plugin\demo\bin\win64;..\godot-cpp\bin;$(LibraryPath)</LibraryPath>
|
||||
<SourcePath>.\src\;$(VC_SourcePath);</SourcePath>
|
||||
<TargetName>libgitapi</TargetName>
|
||||
<IntDir>$(SolutionDir)..\demo\bin\win64\intermediate\</IntDir>
|
||||
<OutDir>$(SolutionDir)..\demo\bin\win64\release\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
@@ -95,7 +103,7 @@
|
||||
<Link>
|
||||
<AdditionalDependencies>libgodot-cpp.windows.debug.64.lib;git2.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<OutputFile>$(SolutionDir)..\demo\bin\win64\libgitapi.dll</OutputFile>
|
||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
@@ -124,6 +132,7 @@
|
||||
<Link>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>libgodot-cpp.windows.release.64.lib;git2.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -9,7 +9,7 @@ void GitAPI::_register_methods() {
|
||||
register_method("_process", &GitAPI::_process);
|
||||
|
||||
register_method("_commit", &GitAPI::_commit);
|
||||
register_method("_get_is_vcs_intialized", &GitAPI::_get_is_vcs_intialized);
|
||||
register_method("_is_vcs_initialized", &GitAPI::_is_vcs_initialized);
|
||||
register_method("_get_modified_files_data", &GitAPI::_get_modified_files_data);
|
||||
register_method("_get_file_diff", &GitAPI::_get_file_diff);
|
||||
register_method("_get_project_name", &GitAPI::_get_project_name);
|
||||
@@ -22,6 +22,12 @@ void GitAPI::_register_methods() {
|
||||
|
||||
void GitAPI::_commit(const String p_msg) {
|
||||
|
||||
if (!can_commit) {
|
||||
|
||||
godot::Godot::print("Git API cannot commit. Check previous errors.");
|
||||
return;
|
||||
}
|
||||
|
||||
git_signature *default_sign;
|
||||
git_oid tree_id, parent_commit_id, new_commit_id;
|
||||
git_tree *tree;
|
||||
@@ -31,7 +37,7 @@ void GitAPI::_commit(const String p_msg) {
|
||||
GIT2_CALL(git_repository_index(&repo_index, repo), "Could not get repository index", NULL);
|
||||
for (int i = 0; i < staged_files.size(); i++) {
|
||||
|
||||
String file_path = ((String)staged_files[i]);
|
||||
String file_path = staged_files[i];
|
||||
File *file = File::_new();
|
||||
if (file->file_exists(file_path)) {
|
||||
|
||||
@@ -50,19 +56,19 @@ void GitAPI::_commit(const String p_msg) {
|
||||
GIT2_CALL(git_commit_lookup(&parent_commit, repo, &parent_commit_id), "Could not lookup parent commit data", NULL);
|
||||
|
||||
GIT2_CALL(
|
||||
git_commit_create_v(
|
||||
&new_commit_id,
|
||||
repo,
|
||||
"HEAD",
|
||||
default_sign,
|
||||
default_sign,
|
||||
"UTF-8",
|
||||
p_msg.alloc_c_string(),
|
||||
tree,
|
||||
1,
|
||||
parent_commit),
|
||||
"Could not create commit",
|
||||
NULL);
|
||||
git_commit_create_v(
|
||||
&new_commit_id,
|
||||
repo,
|
||||
"HEAD",
|
||||
default_sign,
|
||||
default_sign,
|
||||
"UTF-8",
|
||||
p_msg.alloc_c_string(),
|
||||
tree,
|
||||
1,
|
||||
parent_commit),
|
||||
"Could not create commit",
|
||||
NULL);
|
||||
|
||||
staged_files.clear();
|
||||
|
||||
@@ -96,14 +102,13 @@ void GitAPI::create_gitignore_and_gitattributes() {
|
||||
|
||||
file->open("res://.gitignore", File::ModeFlags::WRITE);
|
||||
file->store_string(
|
||||
"# Import cache\n"
|
||||
".import/\n\n"
|
||||
"# Import cache\n"
|
||||
".import/\n\n"
|
||||
|
||||
"# Binaries\n"
|
||||
"bin/\n"
|
||||
"build/\n"
|
||||
"lib/\n"
|
||||
);
|
||||
"# Binaries\n"
|
||||
"bin/\n"
|
||||
"build/\n"
|
||||
"lib/\n");
|
||||
file->close();
|
||||
}
|
||||
|
||||
@@ -111,61 +116,66 @@ void GitAPI::create_gitignore_and_gitattributes() {
|
||||
|
||||
file->open("res://.gitattributes", File::ModeFlags::WRITE);
|
||||
file->store_string(
|
||||
"# Set the default behavior, in case people don't have core.autocrlf set.\n"
|
||||
"* text=auto\n\n"
|
||||
"# Set the default behavior, in case people don't have core.autocrlf set.\n"
|
||||
"* text=auto\n\n"
|
||||
|
||||
"# Explicitly declare text files you want to always be normalized and converted\n"
|
||||
"# to native line endings on checkout.\n"
|
||||
"*.cpp text\n"
|
||||
"*.c text\n"
|
||||
"*.h text\n"
|
||||
"*.gd text\n"
|
||||
"*.cs text\n\n"
|
||||
"# Explicitly declare text files you want to always be normalized and converted\n"
|
||||
"# to native line endings on checkout.\n"
|
||||
"*.cpp text\n"
|
||||
"*.c text\n"
|
||||
"*.h text\n"
|
||||
"*.gd text\n"
|
||||
"*.cs text\n\n"
|
||||
|
||||
"# Declare files that will always have CRLF line endings on checkout.\n"
|
||||
"*.sln text eol=crlf\n\n"
|
||||
"# Declare files that will always have CRLF line endings on checkout.\n"
|
||||
"*.sln text eol=crlf\n\n"
|
||||
|
||||
"# Denote all files that are truly binary and should not be modified.\n"
|
||||
"*.png binary\n"
|
||||
"*.jpg binary\n");
|
||||
"# Denote all files that are truly binary and should not be modified.\n"
|
||||
"*.png binary\n"
|
||||
"*.jpg binary\n");
|
||||
file->close();
|
||||
}
|
||||
}
|
||||
|
||||
void GitAPI::create_initial_commit() {
|
||||
bool GitAPI::create_initial_commit() {
|
||||
|
||||
git_signature *sig;
|
||||
git_oid tree_id, commit_id;
|
||||
git_index *repo_index;
|
||||
git_tree *tree;
|
||||
|
||||
GIT2_CALL(git_signature_default(&sig, repo), "Unable to create a commit signature. Perhaps 'user.name' and 'user.email' are not set", NULL);
|
||||
if (git_signature_default(&sig, repo) != 0) {
|
||||
|
||||
godot::Godot::print_error("Unable to create a commit signature. Perhaps 'user.name' and 'user.email' are not set. Set default user name and user email by `git config` and initialize again", __func__, __FILE__, __LINE__);
|
||||
return false;
|
||||
}
|
||||
GIT2_CALL(git_repository_index(&repo_index, repo), "Could not get repository index", NULL);
|
||||
GIT2_CALL(git_index_write_tree(&tree_id, repo_index), "Could not create intial commit", NULL);
|
||||
|
||||
GIT2_CALL(git_tree_lookup(&tree, repo, &tree_id), "Could not create intial commit", NULL);
|
||||
GIT2_CALL(
|
||||
git_commit_create_v(
|
||||
&commit_id,
|
||||
repo,
|
||||
"HEAD",
|
||||
sig,
|
||||
sig,
|
||||
NULL,
|
||||
"Initial commit",
|
||||
tree,
|
||||
0
|
||||
),
|
||||
"Could not create the initial commit",
|
||||
NULL);
|
||||
git_commit_create_v(
|
||||
&commit_id,
|
||||
repo,
|
||||
"HEAD",
|
||||
sig,
|
||||
sig,
|
||||
NULL,
|
||||
"Initial commit",
|
||||
tree,
|
||||
0),
|
||||
"Could not create the initial commit",
|
||||
NULL);
|
||||
|
||||
GIT2_CALL(git_index_write(repo_index), "Could not write index to disk", NULL);
|
||||
git_index_free(repo_index);
|
||||
git_tree_free(tree);
|
||||
git_signature_free(sig);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GitAPI::_get_is_vcs_intialized() {
|
||||
bool GitAPI::_is_vcs_initialized() {
|
||||
|
||||
return is_initialized;
|
||||
}
|
||||
@@ -272,16 +282,21 @@ bool GitAPI::_initialize(const String p_project_root_path) {
|
||||
WARN_PRINT("Multiple libgit2 instances are running");
|
||||
}
|
||||
|
||||
if (is_initialized) {
|
||||
if (repo) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
can_commit = true;
|
||||
GIT2_CALL(git_repository_init(&repo, p_project_root_path.alloc_c_string(), 0), "Could not initialize repository", NULL);
|
||||
if (git_repository_head_unborn(repo) == 1) {
|
||||
|
||||
create_gitignore_and_gitattributes();
|
||||
create_initial_commit();
|
||||
if (!create_initial_commit()) {
|
||||
|
||||
godot::Godot::print_error("Initial commit could not be created. Commit functionality will not work.", __func__, __FILE__, __LINE__);
|
||||
can_commit = false;
|
||||
}
|
||||
}
|
||||
|
||||
GIT2_CALL(git_repository_open(&repo, p_project_root_path.alloc_c_string()), "Could not open repository", NULL);
|
||||
|
||||
@@ -22,6 +22,9 @@ class GitAPI : public EditorVCSInterface {
|
||||
|
||||
static GitAPI *singleton;
|
||||
|
||||
bool is_initialized;
|
||||
bool can_commit;
|
||||
|
||||
Array staged_files;
|
||||
|
||||
PanelContainer *init_settings_panel_container;
|
||||
@@ -30,7 +33,7 @@ class GitAPI : public EditorVCSInterface {
|
||||
git_repository *repo;
|
||||
|
||||
void _commit(const String p_msg);
|
||||
bool _get_is_vcs_intialized();
|
||||
bool _is_vcs_initialized();
|
||||
Dictionary _get_modified_files_data();
|
||||
Array _get_file_diff(const String file_path);
|
||||
String _get_project_name();
|
||||
@@ -45,11 +48,10 @@ public:
|
||||
|
||||
static GitAPI *get_singleton() { return singleton; }
|
||||
|
||||
bool is_initialized;
|
||||
Array diff_contents;
|
||||
|
||||
void create_gitignore_and_gitattributes();
|
||||
void create_initial_commit();
|
||||
bool create_initial_commit();
|
||||
|
||||
void _init();
|
||||
void _process();
|
||||
|
||||
@@ -55,8 +55,8 @@ extern "C" int diff_line_callback_function(const git_diff_delta *delta, const gi
|
||||
result["line_count"] = line->num_lines;
|
||||
result["old_line_number"] = line->old_lineno;
|
||||
result["offset"] = line->content_offset;
|
||||
|
||||
|
||||
godot::GitAPI::get_singleton()->diff_contents.push_back(result);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -42,8 +42,9 @@ INCLUDE(EnableWarnings)
|
||||
|
||||
# Build options
|
||||
#
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
OPTION(SONAME "Set the (SO)VERSION of the target" ON)
|
||||
OPTION(BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON)
|
||||
OPTION(BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" OFF)
|
||||
OPTION(THREADSAFE "Build libgit2 as threadsafe" ON)
|
||||
OPTION(BUILD_CLAR "Build Tests using the Clar suite" ON)
|
||||
OPTION(BUILD_EXAMPLES "Build library usage example apps" OFF)
|
||||
@@ -61,7 +62,7 @@ OPTION(USE_LEAK_CHECKER "Run tests with leak checker" OFF)
|
||||
OPTION(VALGRIND "Configure build for valgrind" OFF)
|
||||
OPTION(DEBUG_POOL "Enable debug pool allocator" OFF)
|
||||
OPTION(ENABLE_WERROR "Enable compilation with -Werror" OFF)
|
||||
OPTION(USE_BUNDLED_ZLIB "Use the bundled version of zlib" OFF)
|
||||
OPTION(USE_BUNDLED_ZLIB "Use the bundled version of zlib" ON)
|
||||
SET(USE_HTTP_PARSER "" CACHE STRING "Specifies the HTTP Parser implementation; either system or builtin.")
|
||||
OPTION(DEPRECATE_HARD "Do not include deprecated functions in the library" OFF)
|
||||
SET(REGEX_BACKEND "" CACHE STRING "Regular expression implementation. One of regcomp_l, pcre2, pcre, regcomp, or builtin.")
|
||||
|
||||
Reference in New Issue
Block a user