mirror of
https://github.com/godotengine/godot-git-plugin.git
synced 2026-01-01 01:48:28 +03:00
Compare commits
30 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
09ec512ea7 | ||
|
|
f90cbe3b0a | ||
|
|
24a0a14ef3 | ||
|
|
4f914d15ac | ||
|
|
ea15d7a5f1 | ||
|
|
7aa4d02193 | ||
|
|
957e633c2a | ||
|
|
243b03aa33 | ||
|
|
a480cf4b16 | ||
|
|
e9f0844485 | ||
|
|
094424ce50 | ||
|
|
d598850795 | ||
|
|
68e48e47c9 | ||
|
|
9ed3b5128d | ||
|
|
abe4799600 | ||
|
|
82ba804255 | ||
|
|
58a5f956c0 | ||
|
|
707937da12 | ||
|
|
95e7b29088 | ||
|
|
2d2bbb0704 | ||
|
|
4f1604d4f1 | ||
|
|
34bdbcdc50 | ||
|
|
d6f3bdbab6 | ||
|
|
57cd5cc068 | ||
|
|
0c6017066f | ||
|
|
0afdf18596 | ||
|
|
a41e4040d0 | ||
|
|
6ec481671b | ||
|
|
9da28eed5a | ||
|
|
24931cf07a |
110
.github/workflows/build.yml
vendored
Normal file
110
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
name: C/C++ CI
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
ubuntu-debug:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: build-ubuntu-debug
|
||||
run: |
|
||||
pip3 install --user scons
|
||||
. ./build_libs.sh Debug
|
||||
scons platform=x11 target=debug
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: godot-git-plugin-ubuntu-debug-${{ github.sha }}
|
||||
if-no-files-found: error
|
||||
path: |
|
||||
demo/
|
||||
|
||||
ubuntu-release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: build-ubuntu-release
|
||||
run: |
|
||||
pip3 install --user scons
|
||||
. ./build_libs.sh Release
|
||||
scons platform=x11 target=release
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: godot-git-plugin-ubuntu-release-${{ github.sha }}
|
||||
if-no-files-found: error
|
||||
path: |
|
||||
demo/
|
||||
|
||||
windows-debug:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: "3.x"
|
||||
architecture: "x64"
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
- name: build-windows-debug
|
||||
run: |
|
||||
pip3 install --user scons
|
||||
./build_libs.bat Debug
|
||||
scons platform=windows target=debug
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: godot-git-plugin-windows-debug-${{ github.sha }}
|
||||
if-no-files-found: error
|
||||
path: |
|
||||
demo/
|
||||
|
||||
windows-release:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: "3.x"
|
||||
architecture: "x64"
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
- name: build-windows-release
|
||||
run: |
|
||||
pip3 install --user scons
|
||||
./build_libs.bat Release
|
||||
scons platform=windows target=release
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: godot-git-plugin-windows-release-${{ github.sha }}
|
||||
if-no-files-found: error
|
||||
path: |
|
||||
demo/
|
||||
|
||||
macos-debug:
|
||||
runs-on: macos-11
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: build-macos-debug
|
||||
run: |
|
||||
brew install scons
|
||||
. ./build_libs_mac.sh Debug
|
||||
scons platform=osx target=debug use_llvm=yes
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: godot-git-plugin-macos-debug-${{ github.sha }}
|
||||
if-no-files-found: error
|
||||
path: |
|
||||
demo/
|
||||
|
||||
macos-release:
|
||||
runs-on: macos-11
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: build-macos-release
|
||||
run: |
|
||||
brew install scons
|
||||
. ./build_libs_mac.sh Release
|
||||
scons platform=osx target=release use_llvm=yes
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: godot-git-plugin-macos-release-${{ github.sha }}
|
||||
if-no-files-found: error
|
||||
path: |
|
||||
demo/
|
||||
15
.github/workflows/clang-format.yml
vendored
Normal file
15
.github/workflows/clang-format.yml
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
name: clang-format
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: DoozyX/clang-format-lint-action@v0.11
|
||||
with:
|
||||
source: "godot-git-plugin/src"
|
||||
extensions: "h,cpp"
|
||||
clangFormatVersion: 11
|
||||
12
.gitignore
vendored
12
.gitignore
vendored
@@ -14,17 +14,5 @@ api.json
|
||||
.DS_Store
|
||||
|
||||
# Binaries
|
||||
bin/
|
||||
intermediate/
|
||||
build/
|
||||
*.dll
|
||||
*.obj
|
||||
*.so
|
||||
*.dylib
|
||||
*.pdb
|
||||
*.ilk
|
||||
*.exe
|
||||
*.os
|
||||
*.out
|
||||
.import/
|
||||
|
||||
|
||||
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,3 +1,4 @@
|
||||
[submodule "godot-cpp"]
|
||||
path = godot-cpp
|
||||
url = https://github.com/GodotNativeTools/godot-cpp
|
||||
url = https://github.com/godotengine/godot-cpp
|
||||
branch = 3.x
|
||||
|
||||
57
.travis.yml
57
.travis.yml
@@ -1,57 +0,0 @@
|
||||
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;
|
||||
@@ -1,8 +1,10 @@
|
||||
[](https://github.com/godotengine/godot-git-plugin/actions/workflows/build.yml)
|
||||
|
||||
# GDNative Based Git Plugin for Godot Version Control Editor Plugin
|
||||
|
||||
Git implementation of the Godot Engine VCS interface in Godot. We use [libgit2](https://libgit2.org) as our backend to simulate Git in code.
|
||||
|
||||
> Planned for Godot 4.0 since Godot 3.2+. Look for other branches for support in other Godot releases.
|
||||
> Planned for the upcoming version of Godot. Look for other branches for support in other Godot releases.
|
||||
|
||||
## Installation Instructions
|
||||
|
||||
|
||||
21
SConstruct
21
SConstruct
@@ -11,14 +11,14 @@ opts.Add(EnumVariable('target', "Compilation target", 'debug', ['d', 'debug', 'r
|
||||
opts.Add(EnumVariable('platform', "Compilation platform", '', ['', 'windows', 'x11', 'linux', 'osx']))
|
||||
opts.Add(EnumVariable('p', "Compilation target, alias for 'platform'", '', ['', 'windows', 'x11', 'linux', 'osx']))
|
||||
opts.Add(BoolVariable('use_llvm', "Use the LLVM / Clang compiler", 'no'))
|
||||
opts.Add(PathVariable('target_path', 'The path where the lib is installed.', 'demo/bin/'))
|
||||
opts.Add(PathVariable('target_path', 'The path where the lib is installed.', 'demo/addons/godot-git-plugin/'))
|
||||
opts.Add(PathVariable('target_name', 'The library name.', 'libgitapi', PathVariable.PathAccept))
|
||||
|
||||
# Local dependency paths, adapt them to your setup
|
||||
godot_headers_path = "godot-cpp/godot_headers/"
|
||||
godot_headers_path = "godot-cpp/godot-headers/"
|
||||
cpp_bindings_path = "godot-cpp/"
|
||||
cpp_library = "libgodot-cpp"
|
||||
libgit2_lib_path = "demo/bin/"
|
||||
libgit2_lib_path = "demo/addons/godot-git-plugin/"
|
||||
libgit2_include_path = "godot-git-plugin/thirdparty/libgit2/include/"
|
||||
|
||||
# only support 64 at this time..
|
||||
@@ -45,11 +45,11 @@ if env['platform'] == "osx":
|
||||
cpp_library += '.osx'
|
||||
libgit2_lib_path += 'osx/'
|
||||
if env['target'] in ('debug', 'd'):
|
||||
env.Append(CCFLAGS = ['-g','-O2', '-arch', 'x86_64'])
|
||||
env.Append(LINKFLAGS = ['-arch', 'x86_64'])
|
||||
env.Append(CCFLAGS = ['-g','-O2', '-arch', 'x86_64', '-arch', 'arm64', '-std=c++17'])
|
||||
env.Append(LINKFLAGS = ['-arch', 'x86_64', '-arch', 'arm64'])
|
||||
else:
|
||||
env.Append(CCFLAGS = ['-g','-O3', '-arch', 'x86_64', '-std=c++17'])
|
||||
env.Append(LINKFLAGS = ['-arch', 'x86_64'])
|
||||
env.Append(CCFLAGS = ['-g','-O3', '-arch', 'x86_64', '-arch', 'arm64', '-std=c++17'])
|
||||
env.Append(LINKFLAGS = ['-arch', 'x86_64', '-arch', 'arm64'])
|
||||
|
||||
elif env['platform'] in ('x11', 'linux'):
|
||||
env['target_path'] += 'x11/'
|
||||
@@ -68,7 +68,7 @@ elif env['platform'] == "windows":
|
||||
# that way you can run scons in a vs 2017 prompt and it will find all the required tools
|
||||
env.Append(ENV = os.environ)
|
||||
|
||||
env.Append(CCFLAGS = ['-DWIN32', '-D_WIN32', '-D_WINDOWS', '-W3', '-GR', '-D_CRT_SECURE_NO_WARNINGS'])
|
||||
env.Append(CCFLAGS = ['-DWIN32', '-D_WIN32', '-D_WINDOWS', '-W3', '-GR', '-D_CRT_SECURE_NO_WARNINGS', '/std:c++17'])
|
||||
env.Append(LIBS=['Advapi32'])
|
||||
if env['target'] in ('debug', 'd'):
|
||||
env.Append(CCFLAGS = ['-EHsc', '-D_DEBUG', '-MDd'])
|
||||
@@ -82,7 +82,10 @@ else:
|
||||
cpp_library += '.release'
|
||||
env['target_path'] += 'release/'
|
||||
|
||||
cpp_library += '.' + str(bits)
|
||||
if env['platform'] == 'osx':
|
||||
cpp_library += '.universal'
|
||||
else:
|
||||
cpp_library += '.' + str(bits)
|
||||
|
||||
# make sure our binding library properly includes
|
||||
env.Append(CPPPATH=['.', godot_headers_path, cpp_bindings_path + 'include/', cpp_bindings_path + 'include/core/', cpp_bindings_path + 'include/gen/'])
|
||||
|
||||
22
appveyor.yml
22
appveyor.yml
@@ -1,22 +0,0 @@
|
||||
environment:
|
||||
matrix:
|
||||
- vs_version: 16
|
||||
|
||||
os: Visual Studio 2019
|
||||
|
||||
build: off
|
||||
|
||||
configuration:
|
||||
- release
|
||||
- debug
|
||||
|
||||
platform:
|
||||
- x64
|
||||
|
||||
install:
|
||||
- call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
|
||||
- curl -LO https://downloads.sourceforge.net/project/scons/scons-local/3.1.2/scons-local-3.1.2.zip
|
||||
- unzip scons-local-3.1.2.zip
|
||||
- .\build_libs.bat %configuration%
|
||||
- cd ..
|
||||
- .\scons.bat platform=windows target=%configuration% -j2
|
||||
@@ -8,17 +8,15 @@ del /F CMakeCache.txt
|
||||
cmake .. -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_CLAR=OFF -DBUILD_EXAMPLES=OFF -DUSE_SSH=OFF -DUSE_HTTPS=OFF -DUSE_BUNDLED_ZLIB=ON -DWINHTTP=OFF
|
||||
cmake --build . --config %1
|
||||
cd ../../../../
|
||||
mkdir "demo/bin/win64/"
|
||||
copy godot-git-plugin\thirdparty\libgit2\build\%1\git2.lib demo\bin\win64\
|
||||
mkdir "demo/addons/godot-git-plugin/win64/"
|
||||
copy godot-git-plugin\thirdparty\libgit2\build\%1\git2.lib demo\addons\godot-git-plugin\win64\git2.lib
|
||||
|
||||
if "%CI%"=="" (
|
||||
echo Non-CI build detected
|
||||
set SCONS=scons
|
||||
) else (
|
||||
echo CI build detected
|
||||
set SCONS=..\scons.bat
|
||||
)
|
||||
|
||||
cd godot-cpp\
|
||||
%SCONS% platform=windows target=%1 generate_bindings=yes bits=64
|
||||
scons platform=windows target=%1 generate_bindings=yes bits=64 -j%NUMBER_OF_PROCESSORS%
|
||||
cd ..
|
||||
|
||||
@@ -4,20 +4,21 @@ git submodule update --init --recursive;
|
||||
cd godot-git-plugin/thirdparty/libgit2/
|
||||
mkdir build
|
||||
cd build/
|
||||
rm CMakeCache.txt
|
||||
rm -f CMakeCache.txt
|
||||
cmake .. -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_CLAR=OFF -DBUILD_EXAMPLES=OFF -DUSE_SSH=OFF -DUSE_HTTPS=OFF -DUSE_BUNDLED_ZLIB=ON
|
||||
cmake --build . --config $1
|
||||
cd ../../../../
|
||||
mkdir -p "demo/bin/x11/"
|
||||
cp "godot-git-plugin/thirdparty/libgit2/build/libgit2.a" "demo/bin/x11/libgit2.a"
|
||||
mkdir -p "demo/addons/godot-git-plugin/x11/"
|
||||
cp "godot-git-plugin/thirdparty/libgit2/build/libgit2.a" "demo/addons/godot-git-plugin/x11/libgit2.a"
|
||||
|
||||
if [ -z "$CI" ]
|
||||
then
|
||||
echo "Non-CI run was detected"
|
||||
echo "Non-CI run was detected"
|
||||
else
|
||||
echo "CI run was detected"
|
||||
fi
|
||||
|
||||
cd godot-cpp/;
|
||||
scons platform=linux target=$1 generate_bindings=yes bits=64;
|
||||
CORES=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || sysctl -n hw.ncpu)
|
||||
scons platform=linux target=$1 generate_bindings=yes bits=64 -j$CORES;
|
||||
cd ..
|
||||
|
||||
@@ -1,23 +1,31 @@
|
||||
#!/bin/sh
|
||||
git submodule init;
|
||||
git submodule update --init --recursive;
|
||||
|
||||
cd godot-git-plugin/thirdparty/libgit2/
|
||||
mkdir build
|
||||
cd build/
|
||||
rm CMakeCache.txt
|
||||
cmake .. -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_CLAR=OFF -DBUILD_EXAMPLES=OFF -DUSE_SSH=OFF -DUSE_HTTPS=OFF -DUSE_BUNDLED_ZLIB=ON -DUSE_ICONV=OFF
|
||||
rm -f CMakeCache.txt
|
||||
cmake .. -DCMAKE_C_FLAGS="-arch arm64 -arch x86_64" -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_CLAR=OFF -DBUILD_EXAMPLES=OFF -DUSE_SSH=OFF -DUSE_HTTPS=OFF -DUSE_BUNDLED_ZLIB=ON -DUSE_ICONV=OFF
|
||||
cmake --build . --config $1
|
||||
cd ../../../../
|
||||
mkdir -p "demo/bin/osx/"
|
||||
cp "godot-git-plugin/thirdparty/libgit2/build/libgit2.a" "demo/bin/osx/libgit2.a"
|
||||
mkdir -p "demo/addons/godot-git-plugin/osx/"
|
||||
cp "godot-git-plugin/thirdparty/libgit2/build/libgit2.a" "demo/addons/godot-git-plugin/osx/libgit2.a"
|
||||
|
||||
if [ -z "$CI" ]
|
||||
then
|
||||
echo "Non-CI run was detected"
|
||||
echo "Non-CI run was detected"
|
||||
else
|
||||
echo "CI run was detected"
|
||||
fi
|
||||
|
||||
cd godot-cpp/;
|
||||
scons platform=osx target=$1 generate_bindings=yes bits=64;
|
||||
CORES=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || sysctl -n hw.ncpu)
|
||||
scons platform=osx target=$1 generate_bindings=yes macos_arch=x86_64 -j$CORES;
|
||||
scons platform=osx target=$1 generate_bindings=yes macos_arch=arm64 -j$CORES;
|
||||
shopt -s nocasematch; if [[ "release" =~ "$1" ]]; then
|
||||
lipo -create ./bin/libgodot-cpp.osx.release.64.a ./bin/libgodot-cpp.osx.release.arm64.a -output ./bin/libgodot-cpp.osx.release.universal.a
|
||||
else
|
||||
lipo -create ./bin/libgodot-cpp.osx.debug.64.a ./bin/libgodot-cpp.osx.debug.arm64.a -output ./bin/libgodot-cpp.osx.debug.universal.a
|
||||
fi
|
||||
cd ..
|
||||
|
||||
18
demo/addons/godot-git-plugin/git_api.gdnlib
Normal file
18
demo/addons/godot-git-plugin/git_api.gdnlib
Normal file
@@ -0,0 +1,18 @@
|
||||
[general]
|
||||
|
||||
singleton=true
|
||||
load_once=true
|
||||
symbol_prefix="godot_"
|
||||
reloadable=false
|
||||
|
||||
[entry]
|
||||
|
||||
OSX.64="res://addons/godot-git-plugin/osx/release/libgitapi.dylib"
|
||||
Windows.64="res://addons/godot-git-plugin/win64/release/libgitapi.dll"
|
||||
X11.64="res://addons/godot-git-plugin/x11/release/libgitapi.so"
|
||||
|
||||
[dependencies]
|
||||
|
||||
OSX.64=[ ]
|
||||
Windows.64=[ ]
|
||||
X11.64=[ ]
|
||||
@@ -1,6 +1,6 @@
|
||||
[gd_resource type="NativeScript" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://git_api.gdnlib" type="GDNativeLibrary" id=1]
|
||||
[ext_resource path="res://addons/godot-git-plugin/git_api.gdnlib" type="GDNativeLibrary" id=1]
|
||||
|
||||
[resource]
|
||||
resource_name = "GitAPI"
|
||||
BIN
demo/addons/godot-git-plugin/osx/release/libgitapi.dylib
Normal file
BIN
demo/addons/godot-git-plugin/osx/release/libgitapi.dylib
Normal file
Binary file not shown.
7
demo/addons/godot-git-plugin/plugin.cfg
Normal file
7
demo/addons/godot-git-plugin/plugin.cfg
Normal file
@@ -0,0 +1,7 @@
|
||||
[plugin]
|
||||
|
||||
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="ChronicallySerious"
|
||||
version="v1.2.2"
|
||||
script="git_api.gdns"
|
||||
BIN
demo/addons/godot-git-plugin/win64/release/libgitapi.dll
Normal file
BIN
demo/addons/godot-git-plugin/win64/release/libgitapi.dll
Normal file
Binary file not shown.
BIN
demo/addons/godot-git-plugin/x11/release/libgitapi.so
Normal file
BIN
demo/addons/godot-git-plugin/x11/release/libgitapi.so
Normal file
Binary file not shown.
@@ -1,18 +0,0 @@
|
||||
[general]
|
||||
|
||||
singleton=true
|
||||
load_once=true
|
||||
symbol_prefix="godot_"
|
||||
reloadable=false
|
||||
|
||||
[entry]
|
||||
|
||||
OSX.64="res://bin/osx/release/libgitapi.dylib"
|
||||
Windows.64="res://bin/win64/release/libgitapi.dll"
|
||||
X11.64="res://bin/x11/release/libgitapi.so"
|
||||
|
||||
[dependencies]
|
||||
|
||||
OSX.64=[ ]
|
||||
Windows.64=[ ]
|
||||
X11.64=[ ]
|
||||
@@ -12,7 +12,7 @@ _global_script_classes=[ {
|
||||
"base": "",
|
||||
"class": "GitAPI",
|
||||
"language": "NativeScript",
|
||||
"path": "res://git_api.gdns"
|
||||
"path": "res://addons/godot-git-plugin/git_api.gdns"
|
||||
} ]
|
||||
_global_script_class_icons={
|
||||
"GitAPI": ""
|
||||
@@ -26,7 +26,7 @@ config/icon="res://icon.png"
|
||||
|
||||
[gdnative]
|
||||
|
||||
singletons=[ "res://git_api.gdnlib" ]
|
||||
singletons=[ "res://addons/godot-git-plugin/git_api.gdnlib" ]
|
||||
|
||||
[rendering]
|
||||
|
||||
|
||||
Submodule godot-cpp updated: c2f765e49c...99e9dd1d93
@@ -3,7 +3,7 @@
|
||||
# chosen value in case the base style changes (last sync: Clang 6.0.1).
|
||||
---
|
||||
### General config, applies to all languages ###
|
||||
BasedOnStyle: LLVM
|
||||
BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: DontAlign
|
||||
# AlignConsecutiveAssignments: false
|
||||
@@ -13,9 +13,9 @@ AlignAfterOpenBracket: DontAlign
|
||||
AlignTrailingComments: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
# AllowShortBlocksOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: true
|
||||
# AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: Inline
|
||||
AllowShortIfStatementsOnASingleLine: true
|
||||
# AllowShortIfStatementsOnASingleLine: false
|
||||
# AllowShortLoopsOnASingleLine: false
|
||||
# AlwaysBreakAfterDefinitionReturnType: None
|
||||
# AlwaysBreakAfterReturnType: None
|
||||
@@ -46,7 +46,7 @@ BreakBeforeTernaryOperators: false
|
||||
# BreakConstructorInitializersBeforeComma: false
|
||||
BreakConstructorInitializers: AfterColon
|
||||
# BreakStringLiterals: true
|
||||
ColumnLimit: 0
|
||||
ColumnLimit: 0
|
||||
# CommentPragmas: '^ IWYU pragma:'
|
||||
# CompactNamespaces: false
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
@@ -63,20 +63,20 @@ Cpp11BracedListStyle: false
|
||||
# - BOOST_FOREACH
|
||||
# IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '".*"'
|
||||
Priority: 1
|
||||
- Regex: '^<.*\.h>'
|
||||
Priority: 2
|
||||
- Regex: '^<.*'
|
||||
Priority: 3
|
||||
- Regex: '".*"'
|
||||
Priority: 1
|
||||
- Regex: '^<.*\.h>'
|
||||
Priority: 2
|
||||
- Regex: "^<.*"
|
||||
Priority: 3
|
||||
# IncludeIsMainRegex: '(Test)?$'
|
||||
IndentCaseLabels: true
|
||||
# IndentPPDirectives: None
|
||||
IndentWidth: 4
|
||||
IndentWidth: 4
|
||||
# IndentWrappedFunctionNames: false
|
||||
# JavaScriptQuotes: Leave
|
||||
# JavaScriptWrapImports: true
|
||||
# KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
# MacroBlockBegin: ''
|
||||
# MacroBlockEnd: ''
|
||||
# MaxEmptyLinesToKeep: 1
|
||||
@@ -107,21 +107,30 @@ IndentWidth: 4
|
||||
# SpacesInCStyleCastParentheses: false
|
||||
# SpacesInParentheses: false
|
||||
# SpacesInSquareBrackets: false
|
||||
TabWidth: 4
|
||||
UseTab: Always
|
||||
TabWidth: 4
|
||||
UseTab: Always
|
||||
---
|
||||
### C++ specific config ###
|
||||
Language: Cpp
|
||||
Standard: Cpp03
|
||||
Language: Cpp
|
||||
Standard: Cpp11
|
||||
---
|
||||
### ObjC specific config ###
|
||||
Language: ObjC
|
||||
Standard: Cpp03
|
||||
Language: ObjC
|
||||
Standard: Cpp11
|
||||
ObjCBlockIndentWidth: 4
|
||||
# ObjCSpaceAfterProperty: false
|
||||
# ObjCSpaceBeforeProtocolList: true
|
||||
---
|
||||
### Java specific config ###
|
||||
Language: Java
|
||||
Language: Java
|
||||
# BreakAfterJavaFieldAnnotations: false
|
||||
...
|
||||
JavaImportGroups:
|
||||
[
|
||||
"org.godotengine",
|
||||
"android",
|
||||
"androidx",
|
||||
"com.android",
|
||||
"com.google",
|
||||
"java",
|
||||
"javax",
|
||||
]
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <Godot.hpp>
|
||||
|
||||
extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) {
|
||||
|
||||
godot::Godot::gdnative_init(o);
|
||||
}
|
||||
|
||||
@@ -11,12 +10,10 @@ extern "C" void GDN_EXPORT godot_gdnative_singleton(godot_gdnative_init_options
|
||||
}
|
||||
|
||||
extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *o) {
|
||||
|
||||
godot::Godot::gdnative_terminate(o);
|
||||
}
|
||||
|
||||
extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) {
|
||||
|
||||
godot::Godot::nativescript_init(handle);
|
||||
|
||||
godot::register_tool_class<godot::GitAPI>();
|
||||
|
||||
@@ -5,7 +5,6 @@ namespace godot {
|
||||
GitAPI *GitAPI::singleton = NULL;
|
||||
|
||||
void GitAPI::_register_methods() {
|
||||
|
||||
register_method("_process", &GitAPI::_process);
|
||||
|
||||
register_method("_commit", &GitAPI::_commit);
|
||||
@@ -21,9 +20,7 @@ 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;
|
||||
}
|
||||
@@ -36,14 +33,11 @@ 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 = staged_files[i];
|
||||
File *file = File::_new();
|
||||
if (file->file_exists(file_path)) {
|
||||
|
||||
GIT2_CALL(git_index_add_bypath(repo_index, file_path.alloc_c_string()), "Could not add file by path", NULL);
|
||||
} else {
|
||||
|
||||
GIT2_CALL(git_index_remove_bypath(repo_index, file_path.alloc_c_string()), "Could not add file by path", NULL);
|
||||
}
|
||||
}
|
||||
@@ -79,27 +73,21 @@ void GitAPI::_commit(const String p_msg) {
|
||||
}
|
||||
|
||||
void GitAPI::_stage_file(const String p_file_path) {
|
||||
|
||||
if (staged_files.find(p_file_path) == -1) {
|
||||
|
||||
staged_files.push_back(p_file_path);
|
||||
}
|
||||
}
|
||||
|
||||
void GitAPI::_unstage_file(const String p_file_path) {
|
||||
|
||||
if (staged_files.find(p_file_path) != -1) {
|
||||
|
||||
staged_files.erase(p_file_path);
|
||||
}
|
||||
}
|
||||
|
||||
void GitAPI::create_gitignore_and_gitattributes() {
|
||||
|
||||
File *file = File::_new();
|
||||
|
||||
if (!file->file_exists("res://.gitignore")) {
|
||||
|
||||
file->open("res://.gitignore", File::ModeFlags::WRITE);
|
||||
file->store_string(
|
||||
"# Import cache\n"
|
||||
@@ -113,7 +101,6 @@ void GitAPI::create_gitignore_and_gitattributes() {
|
||||
}
|
||||
|
||||
if (!file->file_exists("res://.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"
|
||||
@@ -138,14 +125,12 @@ void GitAPI::create_gitignore_and_gitattributes() {
|
||||
}
|
||||
|
||||
bool GitAPI::create_initial_commit() {
|
||||
|
||||
git_signature *sig;
|
||||
git_oid tree_id, commit_id;
|
||||
git_index *repo_index;
|
||||
git_tree *tree;
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -176,12 +161,10 @@ bool GitAPI::create_initial_commit() {
|
||||
}
|
||||
|
||||
bool GitAPI::_is_vcs_initialized() {
|
||||
|
||||
return is_initialized;
|
||||
}
|
||||
|
||||
Dictionary GitAPI::_get_modified_files_data() {
|
||||
|
||||
git_status_options opts = GIT_STATUS_OPTIONS_INIT;
|
||||
opts.show = GIT_STATUS_SHOW_INDEX_AND_WORKDIR;
|
||||
opts.flags = GIT_STATUS_OPT_EXCLUDE_SUBMODULES;
|
||||
@@ -193,41 +176,32 @@ Dictionary GitAPI::_get_modified_files_data() {
|
||||
Dictionary diff; // Schema is <file_path, status>
|
||||
size_t count = git_status_list_entrycount(statuses);
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
|
||||
const git_status_entry *entry = git_status_byindex(statuses, i);
|
||||
String path;
|
||||
if (entry->index_to_workdir) {
|
||||
|
||||
path = entry->index_to_workdir->new_file.path;
|
||||
} else {
|
||||
|
||||
path = entry->head_to_index->new_file.path;
|
||||
}
|
||||
switch (entry->status) {
|
||||
|
||||
case GIT_STATUS_INDEX_NEW:
|
||||
case GIT_STATUS_WT_NEW: {
|
||||
|
||||
diff[path] = 0;
|
||||
} break;
|
||||
case GIT_STATUS_INDEX_MODIFIED:
|
||||
case GIT_STATUS_WT_MODIFIED: {
|
||||
|
||||
diff[path] = 1;
|
||||
} break;
|
||||
case GIT_STATUS_INDEX_RENAMED:
|
||||
case GIT_STATUS_WT_RENAMED: {
|
||||
|
||||
diff[path] = 2;
|
||||
} break;
|
||||
case GIT_STATUS_INDEX_DELETED:
|
||||
case GIT_STATUS_WT_DELETED: {
|
||||
|
||||
diff[path] = 3;
|
||||
} break;
|
||||
case GIT_STATUS_INDEX_TYPECHANGE:
|
||||
case GIT_STATUS_WT_TYPECHANGE: {
|
||||
|
||||
diff[path] = 4;
|
||||
} break;
|
||||
}
|
||||
@@ -239,7 +213,6 @@ Dictionary GitAPI::_get_modified_files_data() {
|
||||
}
|
||||
|
||||
Array GitAPI::_get_file_diff(const String file_path) {
|
||||
|
||||
git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
|
||||
git_diff *diff;
|
||||
char *pathspec = file_path.alloc_c_string();
|
||||
@@ -261,39 +234,32 @@ Array GitAPI::_get_file_diff(const String file_path) {
|
||||
}
|
||||
|
||||
String GitAPI::_get_project_name() {
|
||||
|
||||
return String("project");
|
||||
}
|
||||
|
||||
String GitAPI::_get_vcs_name() {
|
||||
|
||||
return "Git";
|
||||
}
|
||||
|
||||
bool GitAPI::_initialize(const String p_project_root_path) {
|
||||
|
||||
ERR_FAIL_COND_V(p_project_root_path == "", false);
|
||||
|
||||
singleton = this;
|
||||
|
||||
int init = git_libgit2_init();
|
||||
if (init > 1) {
|
||||
|
||||
WARN_PRINT("Multiple libgit2 instances are running");
|
||||
}
|
||||
|
||||
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();
|
||||
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;
|
||||
}
|
||||
@@ -306,7 +272,6 @@ bool GitAPI::_initialize(const String p_project_root_path) {
|
||||
}
|
||||
|
||||
bool GitAPI::_shut_down() {
|
||||
|
||||
git_repository_free(repo);
|
||||
|
||||
GIT2_CALL(git_libgit2_shutdown(), "Could not shutdown Git Addon", NULL);
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
#ifndef GIT_API_H
|
||||
#define GIT_API_H
|
||||
|
||||
#include <Godot.hpp>
|
||||
#include <Button.hpp>
|
||||
#include <Control.hpp>
|
||||
#include <EditorVCSInterface.hpp>
|
||||
#include <PanelContainer.hpp>
|
||||
#include <Directory.hpp>
|
||||
#include <EditorVCSInterface.hpp>
|
||||
#include <File.hpp>
|
||||
#include <Godot.hpp>
|
||||
#include <PanelContainer.hpp>
|
||||
|
||||
#include <git_common.h>
|
||||
#include <allocation_defs.h>
|
||||
#include <git_common.h>
|
||||
|
||||
#include <git2.h>
|
||||
|
||||
namespace godot {
|
||||
|
||||
class GitAPI : public EditorVCSInterface {
|
||||
|
||||
GODOT_CLASS(GitAPI, EditorVCSInterface)
|
||||
|
||||
static GitAPI *singleton;
|
||||
|
||||
@@ -1,33 +1,27 @@
|
||||
#include <git_common.h>
|
||||
#include <git_api.h>
|
||||
#include <git_common.h>
|
||||
|
||||
void check_git2_errors(int error, const char *message, const char *extra) {
|
||||
|
||||
const git_error *lg2err;
|
||||
const char *lg2msg = "", *lg2spacer = "";
|
||||
|
||||
if (!error) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ((lg2err = git_error_last()) != NULL && lg2err->message != NULL) {
|
||||
|
||||
lg2msg = lg2err->message;
|
||||
lg2spacer = " - ";
|
||||
}
|
||||
|
||||
if (extra) {
|
||||
|
||||
printf("Git API: %s '%s' [%d]%s%s\n", message, extra, error, lg2spacer, lg2msg);
|
||||
} else {
|
||||
|
||||
printf("Git API: %s [%d]%s%s\n", message, error, lg2spacer, lg2msg);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" int diff_line_callback_function(const git_diff_delta *delta, const git_diff_hunk *hunk, const git_diff_line *line, void *payload) {
|
||||
|
||||
// First we NULL terminate the line text incoming
|
||||
char *content = new char[line->content_len + 1];
|
||||
memcpy(content, line->content, line->content_len);
|
||||
@@ -36,14 +30,15 @@ extern "C" int diff_line_callback_function(const git_diff_delta *delta, const gi
|
||||
|
||||
godot::String prefix = "";
|
||||
switch (line->origin) {
|
||||
|
||||
case GIT_DIFF_LINE_DEL_EOFNL:
|
||||
case GIT_DIFF_LINE_DELETION:
|
||||
prefix = "-"; break;
|
||||
prefix = "-";
|
||||
break;
|
||||
|
||||
case GIT_DIFF_LINE_ADD_EOFNL:
|
||||
case GIT_DIFF_LINE_ADDITION:
|
||||
prefix = "+"; break;
|
||||
prefix = "+";
|
||||
break;
|
||||
}
|
||||
|
||||
godot::String content_str = content;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef GIT_COMMON_H
|
||||
#define GIT_COMMON_H
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include <Godot.hpp>
|
||||
|
||||
#include <git2.h>
|
||||
|
||||
Reference in New Issue
Block a user