├── .gitignore
├── .idea
├── libraries
│ ├── Dart_SDK.xml
│ └── Flutter_for_Android.xml
├── modules.xml
├── runConfigurations
│ └── example_lib_main_dart.xml
└── workspace.xml
├── .metadata
├── CHANGELOG.md
├── LICENSE
├── README.md
├── android
├── .gitignore
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ └── gradle-wrapper.properties
├── settings.gradle
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── cpp
│ ├── CMakeLists.txt
│ └── git.c
│ └── java
│ └── io
│ └── gitjournal
│ └── git_bindings
│ ├── AnyThreadResult.java
│ ├── GenerateSSHKeysTask.java
│ ├── Git.java
│ ├── GitAddTask.java
│ ├── GitBindingsPlugin.java
│ ├── GitCloneTask.java
│ ├── GitCommitTask.java
│ ├── GitDefaultBranchTask.java
│ ├── GitFetchTask.java
│ ├── GitMergeTask.java
│ ├── GitPushTask.java
│ ├── GitResetLastTask.java
│ └── GitRmTask.java
├── example
├── .gitignore
├── .metadata
├── README.md
├── android
│ ├── .gitignore
│ ├── app
│ │ ├── build.gradle
│ │ └── src
│ │ │ ├── debug
│ │ │ └── AndroidManifest.xml
│ │ │ ├── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── git_bindings_example
│ │ │ │ │ └── MainActivity.java
│ │ │ └── res
│ │ │ │ ├── drawable
│ │ │ │ └── launch_background.xml
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ └── values
│ │ │ │ └── styles.xml
│ │ │ └── profile
│ │ │ └── AndroidManifest.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ └── gradle-wrapper.properties
│ └── settings.gradle
├── ios
│ ├── .gitignore
│ ├── Flutter
│ │ ├── AppFrameworkInfo.plist
│ │ ├── Debug.xcconfig
│ │ └── Release.xcconfig
│ ├── Podfile
│ ├── Runner.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ └── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ └── Runner.xcscheme
│ ├── Runner.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── Runner
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ ├── Contents.json
│ │ │ ├── Icon-App-1024x1024@1x.png
│ │ │ ├── Icon-App-20x20@1x.png
│ │ │ ├── Icon-App-20x20@2x.png
│ │ │ ├── Icon-App-20x20@3x.png
│ │ │ ├── Icon-App-29x29@1x.png
│ │ │ ├── Icon-App-29x29@2x.png
│ │ │ ├── Icon-App-29x29@3x.png
│ │ │ ├── Icon-App-40x40@1x.png
│ │ │ ├── Icon-App-40x40@2x.png
│ │ │ ├── Icon-App-40x40@3x.png
│ │ │ ├── Icon-App-60x60@2x.png
│ │ │ ├── Icon-App-60x60@3x.png
│ │ │ ├── Icon-App-76x76@1x.png
│ │ │ ├── Icon-App-76x76@2x.png
│ │ │ └── Icon-App-83.5x83.5@2x.png
│ │ └── LaunchImage.imageset
│ │ │ ├── Contents.json
│ │ │ ├── LaunchImage.png
│ │ │ ├── LaunchImage@2x.png
│ │ │ ├── LaunchImage@3x.png
│ │ │ └── README.md
│ │ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ │ ├── Info.plist
│ │ └── main.m
├── lib
│ └── main.dart
├── pubspec.lock
└── pubspec.yaml
├── git_bindings.iml
├── gj_common
├── .dockerignore
├── .gitignore
├── Dockerfile
├── Makefile
├── build-libgit2.sh
├── common.c
├── gitjournal.c
├── gitjournal.h
├── keygen.c
└── test.c
├── ios
├── .gitignore
├── Assets
│ └── .gitkeep
├── Classes
│ ├── GitBindingsPlugin.h
│ └── GitBindingsPlugin.m
└── git_bindings.podspec
├── lib
└── git_bindings.dart
├── pubspec.lock
└── pubspec.yaml
/.gitignore:
--------------------------------------------------------------------------------
1 | .vscode
2 | .classpath
3 | .project
4 | .settings/
5 |
6 | .DS_Store
7 | .dart_tool/
8 |
9 | .packages
10 | .pub/
11 |
12 | build/
13 | android/libs.tar.gz
14 |
--------------------------------------------------------------------------------
/.idea/libraries/Dart_SDK.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/libraries/Flutter_for_Android.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/runConfigurations/example_lib_main_dart.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: 27321ebbad34b0a3fafe99fac037102196d655ff
8 | channel: stable
9 |
10 | project_type: plugin
11 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## 0.0.1
2 |
3 | * TODO: Describe initial release.
4 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright 2018-2019 Vishesh Handa
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
203 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Flutter Git Bindings
2 |
3 | Flutter bindings for the libgit2 project.
4 |
--------------------------------------------------------------------------------
/android/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | libs
10 | .idea
11 | .externalNativeBuild
12 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | google()
4 | jcenter()
5 | }
6 |
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:3.2.1'
9 | }
10 | }
11 |
12 | plugins {
13 | id "de.undercouch.download" version "4.0.4"
14 | }
15 |
16 | group 'io.gitjournal.git_bindings'
17 | version '1.0'
18 |
19 | rootProject.allprojects {
20 | repositories {
21 | google()
22 | jcenter()
23 | }
24 | }
25 |
26 | apply plugin: 'com.android.library'
27 |
28 | android {
29 | compileSdkVersion 28
30 |
31 | defaultConfig {
32 | minSdkVersion 21
33 | targetSdkVersion 28
34 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
35 |
36 | externalNativeBuild {
37 | cmake {
38 | cppFlags ""
39 | }
40 | }
41 | sourceSets {
42 | main {
43 | jniLibs.srcDirs = ['libs']
44 | java.srcDirs = ['src']
45 | }
46 | }
47 | }
48 |
49 | lintOptions {
50 | disable 'InvalidPackage'
51 | }
52 |
53 | externalNativeBuild {
54 | cmake {
55 | path "src/main/cpp/CMakeLists.txt"
56 | }
57 | }
58 | }
59 |
60 | dependencies {
61 | implementation 'androidx.annotation:annotation:1.1.0'
62 | // For reading a file to string
63 | implementation 'commons-io:commons-io:2.5'
64 | }
65 |
66 | task extractLibGit2 {
67 | doLast {
68 | download {
69 | src 'https://github.com/GitJournal/ndk-libraries/releases/download/v0.2/libs.tar'
70 | dest 'libs.tar.gz'
71 | overwrite false
72 | }
73 | copy {
74 | from tarTree(resources.gzip("libs.tar.gz"))
75 | into 'libs'
76 | }
77 | copy {
78 | from 'libs/libs/openssl-lib/'
79 | into 'libs/'
80 | }
81 | copy {
82 | from 'libs/libs/libssh2/'
83 | into 'libs/'
84 | }
85 | copy {
86 | from 'libs/libs/libgit2/'
87 | into 'libs/'
88 | }
89 | }
90 | }
91 |
92 | preBuild.dependsOn extractLibGit2
93 |
--------------------------------------------------------------------------------
/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | android.enableR8=true
3 | android.useAndroidX=true
4 | android.enableJetifier=true
5 |
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | zipStoreBase=GRADLE_USER_HOME
4 | zipStorePath=wrapper/dists
5 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
6 |
--------------------------------------------------------------------------------
/android/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'git_bindings'
2 |
--------------------------------------------------------------------------------
/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/android/src/main/cpp/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.4.1)
2 |
3 | set(lib_src_DIR ${CMAKE_SOURCE_DIR}/../../../libs/${ANDROID_ABI})
4 | include_directories(
5 | ${lib_src_DIR}/include
6 | ${CMAKE_SOURCE_DIR}/../../../../gj_common/
7 | )
8 |
9 | add_library(openssl-lib
10 | STATIC
11 | IMPORTED)
12 |
13 | set_target_properties(openssl-lib
14 | PROPERTIES IMPORTED_LOCATION
15 | ${lib_src_DIR}/lib/libssl.a)
16 |
17 | add_library(crypto-lib
18 | STATIC
19 | IMPORTED)
20 |
21 | set_target_properties(crypto-lib
22 | PROPERTIES IMPORTED_LOCATION
23 | ${lib_src_DIR}/lib/libcrypto.a)
24 |
25 | add_library(ssh2-lib
26 | STATIC
27 | IMPORTED)
28 |
29 | set_target_properties(ssh2-lib
30 | PROPERTIES IMPORTED_LOCATION
31 | ${lib_src_DIR}/lib/libssh2.a)
32 |
33 | add_library(git2-lib
34 | STATIC
35 | IMPORTED)
36 |
37 | set_target_properties(git2-lib
38 | PROPERTIES IMPORTED_LOCATION
39 | ${lib_src_DIR}/lib/libgit2.a)
40 |
41 | add_library(native-lib
42 | SHARED
43 | ${CMAKE_SOURCE_DIR}/../../../../gj_common/gitjournal.c
44 | ${CMAKE_SOURCE_DIR}/../../../../gj_common/keygen.c
45 | ${CMAKE_SOURCE_DIR}/../../../../gj_common/common.c
46 | git.c
47 | )
48 |
49 | target_compile_options(native-lib PRIVATE -Werror -Wall -Wextra -Wno-missing-field-initializers)
50 |
51 | # The order of these libraries is super dooper important
52 | # Otherwise you'll get linker errors
53 | target_link_libraries(native-lib crypto-lib git2-lib ssh2-lib openssl-lib crypto-lib android log)
54 |
--------------------------------------------------------------------------------
/android/src/main/cpp/git.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 |
6 | #include
7 | #include
8 |
9 | #include "gitjournal.h"
10 |
11 | #define UNUSED(x) (void)(x)
12 |
13 | void gj_log(const char *message)
14 | {
15 | __android_log_print(ANDROID_LOG_ERROR, "GitJournalLib", "%s", message);
16 | }
17 |
18 | jstring handle_error(JNIEnv *env, int err)
19 | {
20 | if (err != 0)
21 | {
22 | const gj_error *e = gj_error_info(err);
23 | if (e)
24 | {
25 | __android_log_print(ANDROID_LOG_ERROR, "GitJournalLib", "Error %d/%d: %s\n", err,
26 | e->code, e->message);
27 |
28 | jstring error = (*env)->NewStringUTF(env, e->message);
29 | gj_error_free(e);
30 | return error;
31 | }
32 | return (*env)->NewStringUTF(env, "Error");
33 | }
34 |
35 | return (*env)->NewStringUTF(env, "");
36 | }
37 |
38 | JNIEXPORT void JNICALL
39 | Java_io_gitjournal_git_1bindings_Git_setupLib(
40 | JNIEnv *env,
41 | jobject this_obj)
42 | {
43 |
44 | UNUSED(env);
45 | UNUSED(this_obj);
46 |
47 | gj_init();
48 | }
49 |
50 | JNIEXPORT jstring JNICALL
51 | Java_io_gitjournal_git_1bindings_Git_fetch(
52 | JNIEnv *env,
53 | jobject this_obj,
54 | jstring jni_git_base_path,
55 | jstring jni_remote_name,
56 | jstring jni_public_key,
57 | jstring jni_private_key,
58 | jstring jni_passphrase,
59 | jstring jni_status_file)
60 | {
61 | UNUSED(this_obj);
62 | const char *git_base_path = (*env)->GetStringUTFChars(env, jni_git_base_path, 0);
63 | const char *remote_name = (*env)->GetStringUTFChars(env, jni_remote_name, 0);
64 |
65 | const char *public_key = (*env)->GetStringUTFChars(env, jni_public_key, 0);
66 | const char *private_key = (*env)->GetStringUTFChars(env, jni_private_key, 0);
67 | const char *passphrase = (*env)->GetStringUTFChars(env, jni_passphrase, 0);
68 |
69 | const char *status_file = (*env)->GetStringUTFChars(env, jni_status_file, 0);
70 |
71 | int err = gj_git_fetch(git_base_path, remote_name, (char *)public_key, (char *)private_key, (char *)passphrase, false, (char *)status_file);
72 | return handle_error(env, err);
73 | }
74 |
75 | JNIEXPORT jstring JNICALL
76 | Java_io_gitjournal_git_1bindings_Git_merge(
77 | JNIEnv *env,
78 | jobject this_obj,
79 | jstring jni_git_base_path,
80 | jstring jni_git_branch_name,
81 | jstring jni_author_name,
82 | jstring jni_author_email)
83 | {
84 | UNUSED(this_obj);
85 | const char *git_base_path = (*env)->GetStringUTFChars(env, jni_git_base_path, 0);
86 | const char *git_branch_name = (*env)->GetStringUTFChars(env, jni_git_branch_name, 0);
87 | const char *author_name = (*env)->GetStringUTFChars(env, jni_author_name, 0);
88 | const char *author_email = (*env)->GetStringUTFChars(env, jni_author_email, 0);
89 |
90 | int err = gj_git_merge(git_base_path, git_branch_name, author_name, author_email);
91 | return handle_error(env, err);
92 | }
93 |
94 | JNIEXPORT jstring JNICALL
95 | Java_io_gitjournal_git_1bindings_Git_push(
96 | JNIEnv *env,
97 | jobject this_obj,
98 | jstring jni_git_base_path,
99 | jstring jni_remote_name,
100 | jstring jni_public_key,
101 | jstring jni_private_key,
102 | jstring jni_passphrase,
103 | jstring jni_status_file)
104 | {
105 | UNUSED(this_obj);
106 | const char *git_base_path = (*env)->GetStringUTFChars(env, jni_git_base_path, 0);
107 | const char *remote_name = (*env)->GetStringUTFChars(env, jni_remote_name, 0);
108 |
109 | const char *public_key = (*env)->GetStringUTFChars(env, jni_public_key, 0);
110 | const char *private_key = (*env)->GetStringUTFChars(env, jni_private_key, 0);
111 | const char *passphrase = (*env)->GetStringUTFChars(env, jni_passphrase, 0);
112 |
113 | const char *status_file = (*env)->GetStringUTFChars(env, jni_status_file, 0);
114 |
115 | int err = gj_git_push(git_base_path, remote_name, (char *)public_key, (char *)private_key, (char *)passphrase, false, (char *)status_file);
116 | return handle_error(env, err);
117 | }
118 |
119 | JNIEXPORT jstring JNICALL
120 | Java_io_gitjournal_git_1bindings_Git_defaultBranch(
121 | JNIEnv *env,
122 | jobject this_obj,
123 | jstring jni_git_base_path,
124 | jstring jni_remote_name,
125 | jstring jni_public_key,
126 | jstring jni_private_key,
127 | jstring jni_passphrase)
128 | {
129 | UNUSED(this_obj);
130 | const char *git_base_path = (*env)->GetStringUTFChars(env, jni_git_base_path, 0);
131 | const char *remote_name = (*env)->GetStringUTFChars(env, jni_remote_name, 0);
132 |
133 | const char *public_key = (*env)->GetStringUTFChars(env, jni_public_key, 0);
134 | const char *private_key = (*env)->GetStringUTFChars(env, jni_private_key, 0);
135 | const char *passphrase = (*env)->GetStringUTFChars(env, jni_passphrase, 0);
136 |
137 | char branch_name[1024];
138 | memset(branch_name, 0, 1024);
139 | int err = gj_git_default_branch(git_base_path, remote_name, (char *)public_key, (char *)private_key, (char *)passphrase, false, (char *)branch_name);
140 | if (err == 0)
141 | {
142 | char return_val[1024 + 3];
143 | memset(return_val, 0, 1024 + 3);
144 |
145 | strcat(return_val, "gj:");
146 | strcat(return_val, branch_name);
147 | return (*env)->NewStringUTF(env, return_val);
148 | }
149 |
150 | return handle_error(env, err);
151 | }
152 |
153 | JNIEXPORT jstring JNICALL
154 | Java_io_gitjournal_git_1bindings_Git_clone(
155 | JNIEnv *env,
156 | jobject this_obj,
157 | jstring jni_clone_url,
158 | jstring jni_git_base_path,
159 | jstring jni_public_key,
160 | jstring jni_private_key,
161 | jstring jni_passphrase,
162 | jstring jni_status_file)
163 | {
164 | UNUSED(this_obj);
165 | const char *clone_url = (*env)->GetStringUTFChars(env, jni_clone_url, 0);
166 | const char *git_base_path = (*env)->GetStringUTFChars(env, jni_git_base_path, 0);
167 | const char *status_file = (*env)->GetStringUTFChars(env, jni_status_file, 0);
168 |
169 | const char *public_key = (*env)->GetStringUTFChars(env, jni_public_key, 0);
170 | const char *private_key = (*env)->GetStringUTFChars(env, jni_private_key, 0);
171 | const char *passphrase = (*env)->GetStringUTFChars(env, jni_passphrase, 0);
172 |
173 | int err = gj_git_clone(clone_url, git_base_path, (char *)public_key, (char *)private_key, (char *)passphrase, false, (char *)status_file);
174 | return handle_error(env, err);
175 | }
176 |
177 | JNIEXPORT jstring JNICALL
178 | Java_io_gitjournal_git_1bindings_Git_commit(
179 | JNIEnv *env,
180 | jobject this_obj,
181 | jstring jni_git_base_path,
182 | jstring jni_author_name,
183 | jstring jni_author_email,
184 | jstring jni_message)
185 | {
186 | UNUSED(this_obj);
187 | const char *git_base_path = (*env)->GetStringUTFChars(env, jni_git_base_path, 0);
188 | const char *author_name = (*env)->GetStringUTFChars(env, jni_author_name, 0);
189 | const char *author_email = (*env)->GetStringUTFChars(env, jni_author_email, 0);
190 | const char *message = (*env)->GetStringUTFChars(env, jni_message, 0);
191 |
192 | int err = gj_git_commit(git_base_path, author_name, author_email, message, 0, 0);
193 | return handle_error(env, err);
194 | }
195 |
196 | JNIEXPORT jstring JNICALL
197 | Java_io_gitjournal_git_1bindings_Git_resetHard(
198 | JNIEnv *env,
199 | jobject this_obj,
200 | jstring jni_git_base_path,
201 | jstring jni_ref)
202 | {
203 | UNUSED(this_obj);
204 | const char *git_base_path = (*env)->GetStringUTFChars(env, jni_git_base_path, 0);
205 | const char *ref = (*env)->GetStringUTFChars(env, jni_ref, 0);
206 |
207 | int err = gj_git_reset_hard(git_base_path, ref);
208 | return handle_error(env, err);
209 | }
210 |
211 | JNIEXPORT jstring JNICALL
212 | Java_io_gitjournal_git_1bindings_Git_add(
213 | JNIEnv *env,
214 | jobject this_obj,
215 | jstring jni_git_base_path,
216 | jstring jni_add_pattern)
217 | {
218 | UNUSED(this_obj);
219 |
220 | const char *git_base_path = (*env)->GetStringUTFChars(env, jni_git_base_path, 0);
221 | const char *add_pattern = (*env)->GetStringUTFChars(env, jni_add_pattern, 0);
222 |
223 | int err = gj_git_add(git_base_path, add_pattern);
224 | return handle_error(env, err);
225 | }
226 |
227 | JNIEXPORT jstring JNICALL
228 | Java_io_gitjournal_git_1bindings_Git_rm(
229 | JNIEnv *env,
230 | jobject this_obj,
231 | jstring jni_git_base_path,
232 | jstring jni_pattern)
233 | {
234 | UNUSED(this_obj);
235 |
236 | const char *git_base_path = (*env)->GetStringUTFChars(env, jni_git_base_path, 0);
237 | const char *pattern = (*env)->GetStringUTFChars(env, jni_pattern, 0);
238 |
239 | int err = gj_git_rm(git_base_path, pattern);
240 | return handle_error(env, err);
241 | }
242 |
243 | JNIEXPORT jstring JNICALL
244 | Java_io_gitjournal_git_1bindings_Git_generateKeys(
245 | JNIEnv *env,
246 | jobject this_obj,
247 | jstring jni_private_key_path,
248 | jstring jni_public_key_path,
249 | jstring jni_comment)
250 | {
251 | UNUSED(this_obj);
252 |
253 | const char *private_key_path = (*env)->GetStringUTFChars(env, jni_private_key_path, 0);
254 | const char *public_key_path = (*env)->GetStringUTFChars(env, jni_public_key_path, 0);
255 | const char *comment = (*env)->GetStringUTFChars(env, jni_comment, 0);
256 |
257 | int err = gj_generate_ssh_keys(private_key_path, public_key_path, comment);
258 | return handle_error(env, err);
259 | }
260 |
--------------------------------------------------------------------------------
/android/src/main/java/io/gitjournal/git_bindings/AnyThreadResult.java:
--------------------------------------------------------------------------------
1 | package io.gitjournal.git_bindings;
2 |
3 | import android.os.Handler;
4 | import android.os.Looper;
5 |
6 | import androidx.annotation.Nullable;
7 |
8 | import io.flutter.plugin.common.MethodChannel;
9 | import io.flutter.plugin.common.MethodChannel.Result;
10 |
11 | public class AnyThreadResult implements MethodChannel.Result {
12 | private Result result;
13 |
14 | AnyThreadResult(Result r) {
15 | result = r;
16 | }
17 |
18 | public void success(final @Nullable Object var1) {
19 | new Handler(Looper.getMainLooper()).post(new Runnable() {
20 | @Override
21 | public void run() {
22 | result.success(var1);
23 | }
24 | });
25 | }
26 |
27 | public void error(final String var1, @Nullable final String var2, @Nullable final Object var3) {
28 | new Handler(Looper.getMainLooper()).post(new Runnable() {
29 | @Override
30 | public void run() {
31 | result.error(var1, var2, var3);
32 | }
33 | });
34 | }
35 |
36 | public void notImplemented() {
37 | new Handler(Looper.getMainLooper()).post(new Runnable() {
38 | @Override
39 | public void run() {
40 | result.notImplemented();
41 | }
42 | });
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/android/src/main/java/io/gitjournal/git_bindings/GenerateSSHKeysTask.java:
--------------------------------------------------------------------------------
1 | package io.gitjournal.git_bindings;
2 |
3 | import android.os.AsyncTask;
4 | import android.util.Log;
5 |
6 | import org.apache.commons.io.FileUtils;
7 |
8 | import java.io.File;
9 | import java.io.IOException;
10 | import java.nio.charset.Charset;
11 |
12 | public class GenerateSSHKeysTask extends AsyncTask {
13 | private final static String TAG = "GenerateSSHKeys";
14 | private AnyThreadResult result;
15 |
16 | public GenerateSSHKeysTask(AnyThreadResult _result) {
17 | result = _result;
18 | }
19 |
20 | protected Void doInBackground(String... params) {
21 | String publicKeyPath = params[0];
22 | String privateKeyPath = params[1];
23 | String comment = params[2];
24 |
25 | File privateKeyFile = new File(privateKeyPath);
26 | if (privateKeyFile.exists()) {
27 | Log.d(TAG, "Private key already exists. Overwriting");
28 | }
29 |
30 | Git git = new Git();
31 | String errorStr = git.generateKeys(privateKeyPath, publicKeyPath, comment);
32 | if (!errorStr.isEmpty()) {
33 | result.error("FAILED", errorStr, null);
34 | return null;
35 | }
36 |
37 | result.success(null);
38 | return null;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/android/src/main/java/io/gitjournal/git_bindings/Git.java:
--------------------------------------------------------------------------------
1 | package io.gitjournal.git_bindings;
2 |
3 | public class Git {
4 | static {
5 | // FIXME: Change the name of the library
6 | System.loadLibrary("native-lib");
7 | }
8 |
9 | // This needs to be called once!
10 | public native void setupLib();
11 |
12 | public native String generateKeys(String privateKeyPath, String publicKeyPath, String comment);
13 |
14 | public native String merge(String basePath, String branch, String authorName, String authorEmail);
15 | public native String fetch(String basePath, String remote, String publicKey, String privateKey, String password, String statusFile);
16 | public native String push(String basePath, String remote, String publicKey, String privateKey, String password, String statusFile);
17 | public native String defaultBranch(String basePath, String remote, String publicKey, String privateKey, String password);
18 | public native String clone(String cloneUrl, String basePath, String publicKey, String privateKey, String password, String statusFile);
19 |
20 | public native String commit(String basePath, String authorName, String authorEmail, String message);
21 | public native String resetHard(String basePath, String ref);
22 | public native String add(String basePath, String pattern);
23 | public native String rm(String basePath, String pattern);
24 | }
25 |
--------------------------------------------------------------------------------
/android/src/main/java/io/gitjournal/git_bindings/GitAddTask.java:
--------------------------------------------------------------------------------
1 | package io.gitjournal.git_bindings;
2 |
3 | import android.os.AsyncTask;
4 | import android.util.Log;
5 |
6 | public class GitAddTask extends AsyncTask {
7 | private final static String TAG = "GitAdd";
8 | private AnyThreadResult result;
9 |
10 | public GitAddTask(AnyThreadResult _result) {
11 | result = _result;
12 | }
13 |
14 | protected Void doInBackground(String... params) {
15 | final String cloneDirPath = params[0];
16 | final String filePattern = params[1];
17 |
18 | Git git = new Git();
19 | String errorStr = git.add(cloneDirPath, filePattern);
20 | if (!errorStr.isEmpty()) {
21 | result.error("FAILED", errorStr, null);
22 | return null;
23 | }
24 |
25 | result.success(null);
26 | return null;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/android/src/main/java/io/gitjournal/git_bindings/GitBindingsPlugin.java:
--------------------------------------------------------------------------------
1 | package io.gitjournal.git_bindings;
2 |
3 | import android.util.Log;
4 | import android.content.Context;
5 |
6 | import androidx.annotation.NonNull;
7 |
8 | import java.io.File;
9 | import java.io.IOException;
10 | import java.nio.charset.Charset;
11 | import java.util.Map;
12 |
13 | import org.apache.commons.io.FileUtils;
14 |
15 | import io.flutter.embedding.engine.plugins.FlutterPlugin;
16 | import io.flutter.plugin.common.MethodCall;
17 | import io.flutter.plugin.common.MethodChannel;
18 | import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
19 | import io.flutter.plugin.common.MethodChannel.Result;
20 | import io.flutter.plugin.common.PluginRegistry.Registrar;
21 |
22 | import io.flutter.util.PathUtils;
23 |
24 | /**
25 | * GitBindingsPlugin
26 | */
27 | public class GitBindingsPlugin implements FlutterPlugin, MethodCallHandler {
28 | private static final String CHANNEL_NAME = "io.gitjournal.git_bindings";
29 | static MethodChannel channel;
30 |
31 | private Context context;
32 |
33 | @Override
34 | public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) {
35 | channel = new MethodChannel(flutterPluginBinding.getFlutterEngine().getDartExecutor(), CHANNEL_NAME);
36 | context = flutterPluginBinding.getApplicationContext();
37 | channel.setMethodCallHandler(this);
38 |
39 | Git g = new Git();
40 | g.setupLib();
41 | }
42 |
43 | public static void registerWith(Registrar registrar) {
44 | GitBindingsPlugin instance = new GitBindingsPlugin();
45 | instance.channel = new MethodChannel(registrar.messenger(), CHANNEL_NAME);
46 | instance.context = registrar.context();
47 | instance.channel.setMethodCallHandler(instance);
48 |
49 | Git g = new Git();
50 | g.setupLib();
51 | }
52 |
53 | @Override
54 | public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
55 | final String filesDir = PathUtils.getFilesDir(context);
56 |
57 | Log.i("GitJournalAndroid", "Called method " + call.method);
58 | if (call.arguments instanceof Map) {
59 | Map map = (Map) call.arguments;
60 | for (Map.Entry entry : map.entrySet()) {
61 | Object val = entry.getValue();
62 | String objVal = "";
63 | if (val != null) {
64 | objVal = val.toString();
65 | }
66 |
67 | String key = entry.getKey();
68 | if (key.equals("publicKey") || key.equals("privateKey") || key.equals("password")) {
69 | objVal = "";
70 | }
71 | Log.i("GitJournalAndroid", ". " + key + ": " + objVal);
72 | }
73 | }
74 |
75 | if (call.method.equals("gitMerge")) {
76 | String folderPath = call.argument("folderPath");
77 | String branch = call.argument("branch");
78 | String authorName = call.argument("authorName");
79 | String authorEmail = call.argument("authorEmail");
80 |
81 | if (folderPath == null || folderPath.isEmpty()) {
82 | result.error("Invalid Parameters", "folderPath Invalid", null);
83 | return;
84 | }
85 | if (branch == null || branch.isEmpty()) {
86 | result.error("Invalid Parameters", "branch Invalid", null);
87 | return;
88 | }
89 | if (authorName == null || authorName.isEmpty()) {
90 | result.error("Invalid Parameters", "authorName Invalid", null);
91 | return;
92 | }
93 | if (authorEmail == null || authorEmail.isEmpty()) {
94 | result.error("Invalid Parameters", "authorEmail Invalid", null);
95 | return;
96 | }
97 |
98 | AnyThreadResult anyResult = new AnyThreadResult(result);
99 | new GitMergeTask(anyResult).execute(folderPath, branch, authorName, authorEmail);
100 | return;
101 | } else if (call.method.equals("gitClone")) {
102 | String folderPath = call.argument("folderPath");
103 | String cloneUrl = call.argument("cloneUrl");
104 | String privateKey = call.argument("privateKey");
105 | String publicKey = call.argument("publicKey");
106 | String password = call.argument("password");
107 | String statusFile = call.argument("statusFile");
108 |
109 | if (privateKey == null || privateKey.isEmpty()) {
110 | result.error("Invalid Parameters", "privateKey Invalid", null);
111 | return;
112 | }
113 |
114 | if (publicKey == null || publicKey.isEmpty()) {
115 | result.error("Invalid Parameters", "publicKey Invalid", null);
116 | return;
117 | }
118 |
119 | if (password == null) {
120 | result.error("Invalid Parameters", "password Invalid", null);
121 | return;
122 | }
123 |
124 | if (folderPath == null || folderPath.isEmpty()) {
125 | result.error("Invalid Parameters", "folderPath Invalid", null);
126 | return;
127 | }
128 | if (cloneUrl == null || cloneUrl.isEmpty()) {
129 | result.error("Invalid Parameters", "cloneUrl Invalid", null);
130 | return;
131 | }
132 | if (statusFile == null) {
133 | result.error("Invalid Parameters", "statusFile Invalid", null);
134 | return;
135 | }
136 |
137 | AnyThreadResult anyResult = new AnyThreadResult(result);
138 | new GitCloneTask(anyResult).execute(cloneUrl, folderPath, publicKey, privateKey, password, statusFile);
139 | return;
140 | } else if (call.method.equals("gitFetch")) {
141 | String folderPath = call.argument("folderPath");
142 | String remote = call.argument("remote");
143 | String privateKey = call.argument("privateKey");
144 | String publicKey = call.argument("publicKey");
145 | String password = call.argument("password");
146 | String statusFile = call.argument("statusFile");
147 |
148 | if (privateKey == null || privateKey.isEmpty()) {
149 | result.error("Invalid Parameters", "privateKey Invalid", null);
150 | return;
151 | }
152 |
153 | if (publicKey == null || publicKey.isEmpty()) {
154 | result.error("Invalid Parameters", "publicKey Invalid", null);
155 | return;
156 | }
157 |
158 | if (password == null) {
159 | result.error("Invalid Parameters", "password Invalid", null);
160 | return;
161 | }
162 |
163 | if (folderPath == null || folderPath.isEmpty()) {
164 | result.error("Invalid Parameters", "folderPath Invalid", null);
165 | return;
166 | }
167 | if (remote == null || remote.isEmpty()) {
168 | result.error("Invalid Parameters", "remote Invalid", null);
169 | return;
170 | }
171 | if (statusFile == null) {
172 | result.error("Invalid Parameters", "statusFile Invalid", null);
173 | return;
174 | }
175 |
176 | AnyThreadResult anyResult = new AnyThreadResult(result);
177 | new GitFetchTask(anyResult).execute(folderPath, publicKey, privateKey, password, remote, statusFile);
178 | return;
179 | } else if (call.method.equals("gitPush")) {
180 | String folderPath = call.argument("folderPath");
181 | String remote = call.argument("remote");
182 | String privateKey = call.argument("privateKey");
183 | String publicKey = call.argument("publicKey");
184 | String password = call.argument("password");
185 | String statusFile = call.argument("statusFile");
186 |
187 | if (privateKey == null || privateKey.isEmpty()) {
188 | result.error("Invalid Parameters", "privateKey Invalid", null);
189 | return;
190 | }
191 |
192 | if (publicKey == null || publicKey.isEmpty()) {
193 | result.error("Invalid Parameters", "publicKey Invalid", null);
194 | return;
195 | }
196 |
197 | if (password == null) {
198 | result.error("Invalid Parameters", "password Invalid", null);
199 | return;
200 | }
201 |
202 | if (folderPath == null || folderPath.isEmpty()) {
203 | result.error("Invalid Parameters", "folderPath Invalid", null);
204 | return;
205 | }
206 | if (remote == null || remote.isEmpty()) {
207 | result.error("Invalid Parameters", "remote Invalid", null);
208 | return;
209 | }
210 | if (statusFile == null) {
211 | result.error("Invalid Parameters", "statusFile Invalid", null);
212 | return;
213 | }
214 |
215 | AnyThreadResult anyResult = new AnyThreadResult(result);
216 | new GitPushTask(anyResult).execute(folderPath, publicKey, privateKey, password, remote, statusFile);
217 | return;
218 | } else if (call.method.equals("gitDefaultBranch")) {
219 | String folderPath = call.argument("folderPath");
220 | String remote = call.argument("remote");
221 | String privateKey = call.argument("privateKey");
222 | String publicKey = call.argument("publicKey");
223 | String password = call.argument("password");
224 |
225 | if (privateKey == null || privateKey.isEmpty()) {
226 | result.error("Invalid Parameters", "privateKey Invalid", null);
227 | return;
228 | }
229 |
230 | if (publicKey == null || publicKey.isEmpty()) {
231 | result.error("Invalid Parameters", "publicKey Invalid", null);
232 | return;
233 | }
234 |
235 | if (password == null) {
236 | result.error("Invalid Parameters", "password Invalid", null);
237 | return;
238 | }
239 |
240 | if (folderPath == null || folderPath.isEmpty()) {
241 | result.error("Invalid Parameters", "folderPath Invalid", null);
242 | return;
243 | }
244 | if (remote == null || remote.isEmpty()) {
245 | result.error("Invalid Parameters", "remote Invalid", null);
246 | return;
247 | }
248 |
249 | AnyThreadResult anyResult = new AnyThreadResult(result);
250 | new GitDefaultBranchTask(anyResult).execute(folderPath, publicKey, privateKey, password, remote);
251 | return;
252 | } else if (call.method.equals("gitAdd")) {
253 | String folderPath = call.argument("folderPath");
254 | String filePattern = call.argument("filePattern");
255 |
256 | if (folderPath == null || folderPath.isEmpty()) {
257 | result.error("Invalid Parameters", "folderPath Invalid", null);
258 | return;
259 | }
260 | if (filePattern == null || filePattern.isEmpty()) {
261 | result.error("Invalid Parameters", "filePattern Invalid", null);
262 | return;
263 | }
264 |
265 | AnyThreadResult anyResult = new AnyThreadResult(result);
266 | new GitAddTask(anyResult).execute(folderPath, filePattern);
267 | return;
268 | } else if (call.method.equals("gitRm")) {
269 | String folderPath = call.argument("folderPath");
270 | String filePattern = call.argument("filePattern");
271 |
272 | if (folderPath == null || folderPath.isEmpty()) {
273 | result.error("Invalid Parameters", "folderPath Invalid", null);
274 | return;
275 | }
276 | if (filePattern == null || filePattern.isEmpty()) {
277 | result.error("Invalid Parameters", "filePattern Invalid", null);
278 | return;
279 | }
280 |
281 | AnyThreadResult anyResult = new AnyThreadResult(result);
282 | new GitRmTask(anyResult).execute(folderPath, filePattern);
283 | return;
284 | } else if (call.method.equals("gitCommit")) {
285 | String folderPath = call.argument("folderPath");
286 | String authorName = call.argument("authorName");
287 | String authorEmail = call.argument("authorEmail");
288 | String message = call.argument("message");
289 | String dateTimeStr = call.argument("when");
290 |
291 | if (folderPath == null || folderPath.isEmpty()) {
292 | result.error("Invalid Parameters", "folderPath Invalid", null);
293 | return;
294 | }
295 | if (authorName == null || authorName.isEmpty()) {
296 | result.error("Invalid Parameters", "authorName Invalid", null);
297 | return;
298 | }
299 | if (authorEmail == null || authorEmail.isEmpty()) {
300 | result.error("Invalid Parameters", "authorEmail Invalid", null);
301 | return;
302 | }
303 | if (message == null || message.isEmpty()) {
304 | result.error("Invalid Parameters", "message Invalid", null);
305 | return;
306 | }
307 |
308 | AnyThreadResult anyResult = new AnyThreadResult(result);
309 | new GitCommitTask(anyResult).execute(folderPath, authorName, authorEmail, message, dateTimeStr);
310 | return;
311 | } else if (call.method.equals("gitResetLast")) {
312 | String folderPath = call.argument("folderPath");
313 |
314 | if (folderPath == null || folderPath.isEmpty()) {
315 | result.error("Invalid Parameters", "folderPath Invalid", null);
316 | return;
317 | }
318 |
319 | AnyThreadResult anyResult = new AnyThreadResult(result);
320 | new GitResetLastTask(anyResult).execute(folderPath);
321 | return;
322 | } else if (call.method.equals("generateSSHKeys")) {
323 | String comment = call.argument("comment");
324 | if (comment == null || comment.isEmpty()) {
325 | Log.d("generateSSHKeys", "Defaulting to default comment");
326 | comment = "Generated on Android";
327 | }
328 |
329 | String privateKeyPath = call.argument("privateKeyPath");
330 | if (privateKeyPath == null || privateKeyPath.isEmpty()) {
331 | result.error("Invalid Parameters", "privateKeyPath Invalid", null);
332 | return;
333 | }
334 |
335 | String publicKeyPath = call.argument("publicKeyPath");
336 | if (publicKeyPath == null || publicKeyPath.isEmpty()) {
337 | result.error("Invalid Parameters", "publicKeyPath Invalid", null);
338 | return;
339 | }
340 |
341 | AnyThreadResult anyResult = new AnyThreadResult(result);
342 | new GenerateSSHKeysTask(anyResult).execute(publicKeyPath, privateKeyPath, comment);
343 | return;
344 | }
345 |
346 | result.notImplemented();
347 | }
348 |
349 | @Override
350 | public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
351 | }
352 | }
353 |
--------------------------------------------------------------------------------
/android/src/main/java/io/gitjournal/git_bindings/GitCloneTask.java:
--------------------------------------------------------------------------------
1 | package io.gitjournal.git_bindings;
2 |
3 | import android.os.AsyncTask;
4 |
5 | import java.io.File;
6 |
7 | public class GitCloneTask extends AsyncTask {
8 | private final static String TAG = "GitClone";
9 | private AnyThreadResult result;
10 |
11 | public GitCloneTask(AnyThreadResult _result) {
12 | result = _result;
13 | }
14 |
15 | protected Void doInBackground(String... params) {
16 | final String url = params[0];
17 | final String cloneDirPath = params[1];
18 | final String publicKey = params[2];
19 | final String privateKey = params[3];
20 | final String password = params[4];
21 | final String statusFile = params[5];
22 |
23 | Git git = new Git();
24 | String errorStr = git.clone(url, cloneDirPath, publicKey, privateKey, password, statusFile);
25 | if (!errorStr.isEmpty()) {
26 | result.error("FAILED", errorStr, null);
27 | return null;
28 | }
29 |
30 | result.success(null);
31 | return null;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/android/src/main/java/io/gitjournal/git_bindings/GitCommitTask.java:
--------------------------------------------------------------------------------
1 | package io.gitjournal.git_bindings;
2 |
3 | import android.os.AsyncTask;
4 |
5 | import java.io.File;
6 |
7 | public class GitCommitTask extends AsyncTask {
8 | private final static String TAG = "GitCommit";
9 | private AnyThreadResult result;
10 |
11 | public GitCommitTask(AnyThreadResult _result) {
12 | result = _result;
13 | }
14 |
15 | protected Void doInBackground(String... params) {
16 | final String cloneDirPath = params[0];
17 | final String authorName = params[1];
18 | final String authorEmail = params[2];
19 | final String message = params[3];
20 | final String commitDateTimeStr = params[4];
21 |
22 | File cloneDir = new File(cloneDirPath);
23 |
24 | Git git = new Git();
25 | String errorStr = git.commit(cloneDirPath, authorName, authorEmail, message);
26 | if (!errorStr.isEmpty()) {
27 | result.error("FAILED", errorStr, null);
28 | return null;
29 | }
30 |
31 | result.success(null);
32 | return null;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/android/src/main/java/io/gitjournal/git_bindings/GitDefaultBranchTask.java:
--------------------------------------------------------------------------------
1 | package io.gitjournal.git_bindings;
2 |
3 | import android.util.Log;
4 | import android.os.AsyncTask;
5 |
6 | public class GitDefaultBranchTask extends AsyncTask {
7 | private final static String TAG = "GitDefaultBranch";
8 | private AnyThreadResult result;
9 |
10 | public GitDefaultBranchTask(AnyThreadResult _result) {
11 | result = _result;
12 | }
13 |
14 | protected Void doInBackground(String... params) {
15 | String cloneDirPath = params[0];
16 | final String publicKey = params[1];
17 | final String privateKey = params[2];
18 | final String password = params[3];
19 | final String remote = params[4];
20 |
21 | Git git = new Git();
22 | String str = git.defaultBranch(cloneDirPath, remote, publicKey, privateKey, password);
23 | Log.i("GitJournalAndroid", "GitDefaultBranchTask: " + str);
24 | if (str.startsWith("gj:")) {
25 | String branch = "";
26 | if (str.length() > 3) {
27 | branch = str.substring(3);
28 | }
29 | result.success(branch);
30 | return null;
31 | }
32 | if (!str.isEmpty()) {
33 | result.error("FAILED", str, null);
34 | return null;
35 | }
36 |
37 | // FIXME: This should never occur
38 | result.success(null);
39 | return null;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/android/src/main/java/io/gitjournal/git_bindings/GitFetchTask.java:
--------------------------------------------------------------------------------
1 | package io.gitjournal.git_bindings;
2 |
3 | import android.os.AsyncTask;
4 |
5 | public class GitFetchTask extends AsyncTask {
6 | private final static String TAG = "GitFetch";
7 | private AnyThreadResult result;
8 |
9 | public GitFetchTask(AnyThreadResult _result) {
10 | result = _result;
11 | }
12 |
13 | protected Void doInBackground(String... params) {
14 | String cloneDirPath = params[0];
15 | final String publicKey = params[1];
16 | final String privateKey = params[2];
17 | final String password = params[3];
18 | final String remote = params[4];
19 | final String statusFile = params[5];
20 |
21 | Git git = new Git();
22 | String errorStr = git.fetch(cloneDirPath, remote, publicKey, privateKey, password, statusFile);
23 | if (!errorStr.isEmpty()) {
24 | result.error("FAILED", errorStr, null);
25 | return null;
26 | }
27 |
28 | result.success(null);
29 | return null;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/android/src/main/java/io/gitjournal/git_bindings/GitMergeTask.java:
--------------------------------------------------------------------------------
1 | package io.gitjournal.git_bindings;
2 |
3 | import android.os.AsyncTask;
4 |
5 | public class GitMergeTask extends AsyncTask {
6 | private final static String TAG = "GitMerge";
7 | private AnyThreadResult result;
8 |
9 | public GitMergeTask(AnyThreadResult _result) {
10 | result = _result;
11 | }
12 |
13 | protected Void doInBackground(String... params) {
14 | String cloneDirPath = params[0];
15 | final String branch = params[1];
16 | final String authorName = params[2];
17 | final String authorEmail = params[3];
18 |
19 | Git git = new Git();
20 | String errorStr = git.merge(cloneDirPath, branch, authorName, authorEmail);
21 | if (!errorStr.isEmpty()) {
22 | result.error("FAILED", errorStr, null);
23 | return null;
24 | }
25 |
26 | result.success(null);
27 | return null;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/android/src/main/java/io/gitjournal/git_bindings/GitPushTask.java:
--------------------------------------------------------------------------------
1 | package io.gitjournal.git_bindings;
2 |
3 | import android.os.AsyncTask;
4 |
5 | public class GitPushTask extends AsyncTask {
6 | private final static String TAG = "GitPush";
7 | private AnyThreadResult result;
8 |
9 | public GitPushTask(AnyThreadResult _result) {
10 | result = _result;
11 | }
12 |
13 | protected Void doInBackground(String... params) {
14 | String cloneDirPath = params[0];
15 | final String publicKey = params[1];
16 | final String privateKey = params[2];
17 | final String password = params[3];
18 | final String remote = params[4];
19 | final String statusFile = params[5];
20 |
21 | Git git = new Git();
22 | String errorStr = git.push(cloneDirPath, remote, publicKey, privateKey, password, statusFile);
23 | if (!errorStr.isEmpty()) {
24 | result.error("FAILED", errorStr, null);
25 | return null;
26 | }
27 |
28 | result.success(null);
29 | return null;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/android/src/main/java/io/gitjournal/git_bindings/GitResetLastTask.java:
--------------------------------------------------------------------------------
1 | package io.gitjournal.git_bindings;
2 |
3 | import android.os.AsyncTask;
4 |
5 | public class GitResetLastTask extends AsyncTask {
6 | private final static String TAG = "GitResetLastTask";
7 | private AnyThreadResult result;
8 |
9 | public GitResetLastTask(AnyThreadResult _result) {
10 | result = _result;
11 | }
12 |
13 | protected Void doInBackground(String... params) {
14 | final String cloneDirPath = params[0];
15 |
16 | Git git = new Git();
17 | String errorStr = git.resetHard(cloneDirPath, "HEAD^");
18 | if (!errorStr.isEmpty()) {
19 | result.error("FAILED", errorStr, null);
20 | return null;
21 | }
22 |
23 | result.success(null);
24 | return null;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/android/src/main/java/io/gitjournal/git_bindings/GitRmTask.java:
--------------------------------------------------------------------------------
1 | package io.gitjournal.git_bindings;
2 |
3 | import android.os.AsyncTask;
4 |
5 | import java.io.File;
6 |
7 | public class GitRmTask extends AsyncTask {
8 | private final static String TAG = "GitRm";
9 | private AnyThreadResult result;
10 |
11 | public GitRmTask(AnyThreadResult _result) {
12 | result = _result;
13 | }
14 |
15 | protected Void doInBackground(String... params) {
16 | final String cloneDirPath = params[0];
17 | final String filePattern = params[1];
18 |
19 | File cloneDir = new File(cloneDirPath);
20 |
21 | Git git = new Git();
22 | String errorStr = git.rm(cloneDirPath, filePattern);
23 | if (!errorStr.isEmpty()) {
24 | result.error("FAILED", errorStr, null);
25 | return null;
26 | }
27 |
28 | result.success(null);
29 | return null;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/example/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 |
12 | # IntelliJ related
13 | *.iml
14 | *.ipr
15 | *.iws
16 | .idea/
17 |
18 | # The .vscode folder contains launch configuration and tasks you configure in
19 | # VS Code which you may wish to be included in version control, so this line
20 | # is commented out by default.
21 | #.vscode/
22 |
23 | # Flutter/Dart/Pub related
24 | **/doc/api/
25 | .dart_tool/
26 | .flutter-plugins
27 | .flutter-plugins-dependencies
28 | .packages
29 | .pub-cache/
30 | .pub/
31 | /build/
32 |
33 | # Web related
34 | lib/generated_plugin_registrant.dart
35 |
36 | # Exceptions to above rules.
37 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
38 |
--------------------------------------------------------------------------------
/example/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: 27321ebbad34b0a3fafe99fac037102196d655ff
8 | channel: stable
9 |
10 | project_type: app
11 |
--------------------------------------------------------------------------------
/example/README.md:
--------------------------------------------------------------------------------
1 | # git_bindings_example
2 |
3 | Demonstrates how to use the git_bindings plugin.
4 |
5 | ## Getting Started
6 |
7 | This project is a starting point for a Flutter application.
8 |
9 | A few resources to get you started if this is your first Flutter project:
10 |
11 | - [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
13 |
14 | For help getting started with Flutter, view our
15 | [online documentation](https://flutter.dev/docs), which offers tutorials,
16 | samples, guidance on mobile development, and a full API reference.
17 |
--------------------------------------------------------------------------------
/example/android/.gitignore:
--------------------------------------------------------------------------------
1 | gradle-wrapper.jar
2 | /.gradle
3 | /captures/
4 | /gradlew
5 | /gradlew.bat
6 | /local.properties
7 | GeneratedPluginRegistrant.java
8 |
--------------------------------------------------------------------------------
/example/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | def localProperties = new Properties()
2 | def localPropertiesFile = rootProject.file('local.properties')
3 | if (localPropertiesFile.exists()) {
4 | localPropertiesFile.withReader('UTF-8') { reader ->
5 | localProperties.load(reader)
6 | }
7 | }
8 |
9 | def flutterRoot = localProperties.getProperty('flutter.sdk')
10 | if (flutterRoot == null) {
11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12 | }
13 |
14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
15 | if (flutterVersionCode == null) {
16 | flutterVersionCode = '1'
17 | }
18 |
19 | def flutterVersionName = localProperties.getProperty('flutter.versionName')
20 | if (flutterVersionName == null) {
21 | flutterVersionName = '1.0'
22 | }
23 |
24 | apply plugin: 'com.android.application'
25 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
26 |
27 | android {
28 | compileSdkVersion 28
29 |
30 | lintOptions {
31 | disable 'InvalidPackage'
32 | }
33 |
34 | defaultConfig {
35 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
36 | applicationId "com.example.git_bindings_example"
37 | minSdkVersion 21
38 | targetSdkVersion 28
39 | versionCode flutterVersionCode.toInteger()
40 | versionName flutterVersionName
41 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
42 | }
43 |
44 | buildTypes {
45 | release {
46 | // TODO: Add your own signing config for the release build.
47 | // Signing with the debug keys for now, so `flutter run --release` works.
48 | signingConfig signingConfigs.debug
49 | }
50 | }
51 | }
52 |
53 | flutter {
54 | source '../..'
55 | }
56 |
57 | dependencies {
58 | testImplementation 'junit:junit:4.12'
59 | androidTestImplementation 'androidx.test:runner:1.1.1'
60 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
61 | }
62 |
--------------------------------------------------------------------------------
/example/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
8 |
12 |
19 |
20 |
21 |
22 |
23 |
24 |
26 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/example/android/app/src/main/java/com/example/git_bindings_example/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.git_bindings_example;
2 |
3 | import androidx.annotation.NonNull;
4 | import io.flutter.embedding.android.FlutterActivity;
5 | import io.flutter.embedding.engine.FlutterEngine;
6 | import io.flutter.plugins.GeneratedPluginRegistrant;
7 |
8 | public class MainActivity extends FlutterActivity {
9 | @Override
10 | public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
11 | GeneratedPluginRegistrant.registerWith(flutterEngine);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/drawable/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitJournal/git_bindings/ba1db24a7f9c29f4e5c9c4116c24687605f6d903/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitJournal/git_bindings/ba1db24a7f9c29f4e5c9c4116c24687605f6d903/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitJournal/git_bindings/ba1db24a7f9c29f4e5c9c4116c24687605f6d903/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitJournal/git_bindings/ba1db24a7f9c29f4e5c9c4116c24687605f6d903/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitJournal/git_bindings/ba1db24a7f9c29f4e5c9c4116c24687605f6d903/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
--------------------------------------------------------------------------------
/example/android/app/src/profile/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | google()
4 | jcenter()
5 | }
6 |
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:3.2.1'
9 | }
10 | }
11 |
12 | allprojects {
13 | repositories {
14 | google()
15 | jcenter()
16 | }
17 | }
18 |
19 | rootProject.buildDir = '../build'
20 | subprojects {
21 | project.buildDir = "${rootProject.buildDir}/${project.name}"
22 | }
23 | subprojects {
24 | project.evaluationDependsOn(':app')
25 | }
26 |
27 | task clean(type: Delete) {
28 | delete rootProject.buildDir
29 | }
30 |
--------------------------------------------------------------------------------
/example/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | android.enableR8=true
3 | android.useAndroidX=true
4 | android.enableJetifier=true
5 |
--------------------------------------------------------------------------------
/example/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Jun 23 08:50:38 CEST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
7 |
--------------------------------------------------------------------------------
/example/android/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
4 |
5 | def plugins = new Properties()
6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
7 | if (pluginsFile.exists()) {
8 | pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
9 | }
10 |
11 | plugins.each { name, path ->
12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
13 | include ":$name"
14 | project(":$name").projectDir = pluginDirectory
15 | }
16 |
--------------------------------------------------------------------------------
/example/ios/.gitignore:
--------------------------------------------------------------------------------
1 | *.mode1v3
2 | *.mode2v3
3 | *.moved-aside
4 | *.pbxuser
5 | *.perspectivev3
6 | **/*sync/
7 | .sconsign.dblite
8 | .tags*
9 | **/.vagrant/
10 | **/DerivedData/
11 | Icon?
12 | **/Pods/
13 | **/.symlinks/
14 | profile
15 | xcuserdata
16 | **/.generated/
17 | Flutter/App.framework
18 | Flutter/Flutter.framework
19 | Flutter/Flutter.podspec
20 | Flutter/Generated.xcconfig
21 | Flutter/app.flx
22 | Flutter/app.zip
23 | Flutter/flutter_assets/
24 | Flutter/flutter_export_environment.sh
25 | ServiceDefinitions.json
26 | Runner/GeneratedPluginRegistrant.*
27 |
28 | # Exceptions to above rules.
29 | !default.mode1v3
30 | !default.mode2v3
31 | !default.pbxuser
32 | !default.perspectivev3
33 |
--------------------------------------------------------------------------------
/example/ios/Flutter/AppFrameworkInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | App
9 | CFBundleIdentifier
10 | io.flutter.flutter.app
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | App
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 | MinimumOSVersion
24 | 8.0
25 |
26 |
27 |
--------------------------------------------------------------------------------
/example/ios/Flutter/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
2 | #include "Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/example/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
2 | #include "Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/example/ios/Podfile:
--------------------------------------------------------------------------------
1 | # Uncomment this line to define a global platform for your project
2 | # platform :ios, '9.0'
3 |
4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true'
6 |
7 | project 'Runner', {
8 | 'Debug' => :debug,
9 | 'Profile' => :release,
10 | 'Release' => :release,
11 | }
12 |
13 | def parse_KV_file(file, separator='=')
14 | file_abs_path = File.expand_path(file)
15 | if !File.exists? file_abs_path
16 | return [];
17 | end
18 | generated_key_values = {}
19 | skip_line_start_symbols = ["#", "/"]
20 | File.foreach(file_abs_path) do |line|
21 | next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
22 | plugin = line.split(pattern=separator)
23 | if plugin.length == 2
24 | podname = plugin[0].strip()
25 | path = plugin[1].strip()
26 | podpath = File.expand_path("#{path}", file_abs_path)
27 | generated_key_values[podname] = podpath
28 | else
29 | puts "Invalid plugin specification: #{line}"
30 | end
31 | end
32 | generated_key_values
33 | end
34 |
35 | target 'Runner' do
36 | # Flutter Pod
37 |
38 | copied_flutter_dir = File.join(__dir__, 'Flutter')
39 | copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
40 | copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
41 | unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
42 | # Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
43 | # That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
44 | # CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
45 |
46 | generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
47 | unless File.exist?(generated_xcode_build_settings_path)
48 | raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
49 | end
50 | generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
51 | cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];
52 |
53 | unless File.exist?(copied_framework_path)
54 | FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
55 | end
56 | unless File.exist?(copied_podspec_path)
57 | FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
58 | end
59 | end
60 |
61 | # Keep pod path relative so it can be checked into Podfile.lock.
62 | pod 'Flutter', :path => 'Flutter'
63 |
64 | # Plugin Pods
65 |
66 | # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
67 | # referring to absolute paths on developers' machines.
68 | system('rm -rf .symlinks')
69 | system('mkdir -p .symlinks/plugins')
70 | plugin_pods = parse_KV_file('../.flutter-plugins')
71 | plugin_pods.each do |name, path|
72 | symlink = File.join('.symlinks', 'plugins', name)
73 | File.symlink(path, symlink)
74 | pod name, :path => File.join(symlink, 'ios')
75 | end
76 | end
77 |
78 | # Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
79 | install! 'cocoapods', :disable_input_output_paths => true
80 |
81 | post_install do |installer|
82 | installer.pods_project.targets.each do |target|
83 | target.build_configurations.each do |config|
84 | config.build_settings['ENABLE_BITCODE'] = 'NO'
85 | end
86 | end
87 | end
88 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
11 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
12 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
13 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
14 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
15 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
16 | 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
17 | 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
18 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
19 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
20 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
21 | /* End PBXBuildFile section */
22 |
23 | /* Begin PBXCopyFilesBuildPhase section */
24 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = {
25 | isa = PBXCopyFilesBuildPhase;
26 | buildActionMask = 2147483647;
27 | dstPath = "";
28 | dstSubfolderSpec = 10;
29 | files = (
30 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */,
31 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */,
32 | );
33 | name = "Embed Frameworks";
34 | runOnlyForDeploymentPostprocessing = 0;
35 | };
36 | /* End PBXCopyFilesBuildPhase section */
37 |
38 | /* Begin PBXFileReference section */
39 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; };
40 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; };
41 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; };
42 | 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; };
43 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; };
44 | 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
45 | 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
46 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; };
47 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; };
48 | 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; };
49 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
50 | 97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
51 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
52 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
53 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
54 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
55 | /* End PBXFileReference section */
56 |
57 | /* Begin PBXFrameworksBuildPhase section */
58 | 97C146EB1CF9000F007C117D /* Frameworks */ = {
59 | isa = PBXFrameworksBuildPhase;
60 | buildActionMask = 2147483647;
61 | files = (
62 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
63 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
64 | );
65 | runOnlyForDeploymentPostprocessing = 0;
66 | };
67 | /* End PBXFrameworksBuildPhase section */
68 |
69 | /* Begin PBXGroup section */
70 | 9740EEB11CF90186004384FC /* Flutter */ = {
71 | isa = PBXGroup;
72 | children = (
73 | 3B80C3931E831B6300D905FE /* App.framework */,
74 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
75 | 9740EEBA1CF902C7004384FC /* Flutter.framework */,
76 | 9740EEB21CF90195004384FC /* Debug.xcconfig */,
77 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
78 | 9740EEB31CF90195004384FC /* Generated.xcconfig */,
79 | );
80 | name = Flutter;
81 | sourceTree = "";
82 | };
83 | 97C146E51CF9000F007C117D = {
84 | isa = PBXGroup;
85 | children = (
86 | 9740EEB11CF90186004384FC /* Flutter */,
87 | 97C146F01CF9000F007C117D /* Runner */,
88 | 97C146EF1CF9000F007C117D /* Products */,
89 | CF3B75C9A7D2FA2A4C99F110 /* Frameworks */,
90 | );
91 | sourceTree = "";
92 | };
93 | 97C146EF1CF9000F007C117D /* Products */ = {
94 | isa = PBXGroup;
95 | children = (
96 | 97C146EE1CF9000F007C117D /* Runner.app */,
97 | );
98 | name = Products;
99 | sourceTree = "";
100 | };
101 | 97C146F01CF9000F007C117D /* Runner */ = {
102 | isa = PBXGroup;
103 | children = (
104 | 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */,
105 | 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */,
106 | 97C146FA1CF9000F007C117D /* Main.storyboard */,
107 | 97C146FD1CF9000F007C117D /* Assets.xcassets */,
108 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
109 | 97C147021CF9000F007C117D /* Info.plist */,
110 | 97C146F11CF9000F007C117D /* Supporting Files */,
111 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
112 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
113 | );
114 | path = Runner;
115 | sourceTree = "";
116 | };
117 | 97C146F11CF9000F007C117D /* Supporting Files */ = {
118 | isa = PBXGroup;
119 | children = (
120 | 97C146F21CF9000F007C117D /* main.m */,
121 | );
122 | name = "Supporting Files";
123 | sourceTree = "";
124 | };
125 | /* End PBXGroup section */
126 |
127 | /* Begin PBXNativeTarget section */
128 | 97C146ED1CF9000F007C117D /* Runner */ = {
129 | isa = PBXNativeTarget;
130 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
131 | buildPhases = (
132 | 9740EEB61CF901F6004384FC /* Run Script */,
133 | 97C146EA1CF9000F007C117D /* Sources */,
134 | 97C146EB1CF9000F007C117D /* Frameworks */,
135 | 97C146EC1CF9000F007C117D /* Resources */,
136 | 9705A1C41CF9048500538489 /* Embed Frameworks */,
137 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */,
138 | );
139 | buildRules = (
140 | );
141 | dependencies = (
142 | );
143 | name = Runner;
144 | productName = Runner;
145 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */;
146 | productType = "com.apple.product-type.application";
147 | };
148 | /* End PBXNativeTarget section */
149 |
150 | /* Begin PBXProject section */
151 | 97C146E61CF9000F007C117D /* Project object */ = {
152 | isa = PBXProject;
153 | attributes = {
154 | LastUpgradeCheck = 1020;
155 | ORGANIZATIONNAME = "The Chromium Authors";
156 | TargetAttributes = {
157 | 97C146ED1CF9000F007C117D = {
158 | CreatedOnToolsVersion = 7.3.1;
159 | };
160 | };
161 | };
162 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */;
163 | compatibilityVersion = "Xcode 3.2";
164 | developmentRegion = en;
165 | hasScannedForEncodings = 0;
166 | knownRegions = (
167 | en,
168 | Base,
169 | );
170 | mainGroup = 97C146E51CF9000F007C117D;
171 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
172 | projectDirPath = "";
173 | projectRoot = "";
174 | targets = (
175 | 97C146ED1CF9000F007C117D /* Runner */,
176 | );
177 | };
178 | /* End PBXProject section */
179 |
180 | /* Begin PBXResourcesBuildPhase section */
181 | 97C146EC1CF9000F007C117D /* Resources */ = {
182 | isa = PBXResourcesBuildPhase;
183 | buildActionMask = 2147483647;
184 | files = (
185 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */,
186 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
187 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
188 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
189 | );
190 | runOnlyForDeploymentPostprocessing = 0;
191 | };
192 | /* End PBXResourcesBuildPhase section */
193 |
194 | /* Begin PBXShellScriptBuildPhase section */
195 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
196 | isa = PBXShellScriptBuildPhase;
197 | buildActionMask = 2147483647;
198 | files = (
199 | );
200 | inputPaths = (
201 | );
202 | name = "Thin Binary";
203 | outputPaths = (
204 | );
205 | runOnlyForDeploymentPostprocessing = 0;
206 | shellPath = /bin/sh;
207 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
208 | };
209 | 9740EEB61CF901F6004384FC /* Run Script */ = {
210 | isa = PBXShellScriptBuildPhase;
211 | buildActionMask = 2147483647;
212 | files = (
213 | );
214 | inputPaths = (
215 | );
216 | name = "Run Script";
217 | outputPaths = (
218 | );
219 | runOnlyForDeploymentPostprocessing = 0;
220 | shellPath = /bin/sh;
221 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
222 | };
223 | /* End PBXShellScriptBuildPhase section */
224 |
225 | /* Begin PBXSourcesBuildPhase section */
226 | 97C146EA1CF9000F007C117D /* Sources */ = {
227 | isa = PBXSourcesBuildPhase;
228 | buildActionMask = 2147483647;
229 | files = (
230 | 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */,
231 | 97C146F31CF9000F007C117D /* main.m in Sources */,
232 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
233 | );
234 | runOnlyForDeploymentPostprocessing = 0;
235 | };
236 | /* End PBXSourcesBuildPhase section */
237 |
238 | /* Begin PBXVariantGroup section */
239 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = {
240 | isa = PBXVariantGroup;
241 | children = (
242 | 97C146FB1CF9000F007C117D /* Base */,
243 | );
244 | name = Main.storyboard;
245 | sourceTree = "";
246 | };
247 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = {
248 | isa = PBXVariantGroup;
249 | children = (
250 | 97C147001CF9000F007C117D /* Base */,
251 | );
252 | name = LaunchScreen.storyboard;
253 | sourceTree = "";
254 | };
255 | /* End PBXVariantGroup section */
256 |
257 | /* Begin XCBuildConfiguration section */
258 | 249021D3217E4FDB00AE95B9 /* Profile */ = {
259 | isa = XCBuildConfiguration;
260 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
261 | buildSettings = {
262 | ALWAYS_SEARCH_USER_PATHS = NO;
263 | CLANG_ANALYZER_NONNULL = YES;
264 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
265 | CLANG_CXX_LIBRARY = "libc++";
266 | CLANG_ENABLE_MODULES = YES;
267 | CLANG_ENABLE_OBJC_ARC = YES;
268 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
269 | CLANG_WARN_BOOL_CONVERSION = YES;
270 | CLANG_WARN_COMMA = YES;
271 | CLANG_WARN_CONSTANT_CONVERSION = YES;
272 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
273 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
274 | CLANG_WARN_EMPTY_BODY = YES;
275 | CLANG_WARN_ENUM_CONVERSION = YES;
276 | CLANG_WARN_INFINITE_RECURSION = YES;
277 | CLANG_WARN_INT_CONVERSION = YES;
278 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
279 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
280 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
281 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
282 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
283 | CLANG_WARN_STRICT_PROTOTYPES = YES;
284 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
285 | CLANG_WARN_UNREACHABLE_CODE = YES;
286 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
287 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
288 | COPY_PHASE_STRIP = NO;
289 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
290 | ENABLE_NS_ASSERTIONS = NO;
291 | ENABLE_STRICT_OBJC_MSGSEND = YES;
292 | GCC_C_LANGUAGE_STANDARD = gnu99;
293 | GCC_NO_COMMON_BLOCKS = YES;
294 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
295 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
296 | GCC_WARN_UNDECLARED_SELECTOR = YES;
297 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
298 | GCC_WARN_UNUSED_FUNCTION = YES;
299 | GCC_WARN_UNUSED_VARIABLE = YES;
300 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
301 | MTL_ENABLE_DEBUG_INFO = NO;
302 | SDKROOT = iphoneos;
303 | SUPPORTED_PLATFORMS = iphoneos;
304 | TARGETED_DEVICE_FAMILY = "1,2";
305 | VALIDATE_PRODUCT = YES;
306 | };
307 | name = Profile;
308 | };
309 | 249021D4217E4FDB00AE95B9 /* Profile */ = {
310 | isa = XCBuildConfiguration;
311 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
312 | buildSettings = {
313 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
314 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
315 | ENABLE_BITCODE = NO;
316 | FRAMEWORK_SEARCH_PATHS = (
317 | "$(inherited)",
318 | "$(PROJECT_DIR)/Flutter",
319 | );
320 | INFOPLIST_FILE = Runner/Info.plist;
321 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
322 | LIBRARY_SEARCH_PATHS = (
323 | "$(inherited)",
324 | "$(PROJECT_DIR)/Flutter",
325 | );
326 | PRODUCT_BUNDLE_IDENTIFIER = com.example.gitBindingsExample;
327 | PRODUCT_NAME = "$(TARGET_NAME)";
328 | VERSIONING_SYSTEM = "apple-generic";
329 | };
330 | name = Profile;
331 | };
332 | 97C147031CF9000F007C117D /* Debug */ = {
333 | isa = XCBuildConfiguration;
334 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
335 | buildSettings = {
336 | ALWAYS_SEARCH_USER_PATHS = NO;
337 | CLANG_ANALYZER_NONNULL = YES;
338 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
339 | CLANG_CXX_LIBRARY = "libc++";
340 | CLANG_ENABLE_MODULES = YES;
341 | CLANG_ENABLE_OBJC_ARC = YES;
342 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
343 | CLANG_WARN_BOOL_CONVERSION = YES;
344 | CLANG_WARN_COMMA = YES;
345 | CLANG_WARN_CONSTANT_CONVERSION = YES;
346 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
347 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
348 | CLANG_WARN_EMPTY_BODY = YES;
349 | CLANG_WARN_ENUM_CONVERSION = YES;
350 | CLANG_WARN_INFINITE_RECURSION = YES;
351 | CLANG_WARN_INT_CONVERSION = YES;
352 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
353 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
354 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
355 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
356 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
357 | CLANG_WARN_STRICT_PROTOTYPES = YES;
358 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
359 | CLANG_WARN_UNREACHABLE_CODE = YES;
360 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
361 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
362 | COPY_PHASE_STRIP = NO;
363 | DEBUG_INFORMATION_FORMAT = dwarf;
364 | ENABLE_STRICT_OBJC_MSGSEND = YES;
365 | ENABLE_TESTABILITY = YES;
366 | GCC_C_LANGUAGE_STANDARD = gnu99;
367 | GCC_DYNAMIC_NO_PIC = NO;
368 | GCC_NO_COMMON_BLOCKS = YES;
369 | GCC_OPTIMIZATION_LEVEL = 0;
370 | GCC_PREPROCESSOR_DEFINITIONS = (
371 | "DEBUG=1",
372 | "$(inherited)",
373 | );
374 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
375 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
376 | GCC_WARN_UNDECLARED_SELECTOR = YES;
377 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
378 | GCC_WARN_UNUSED_FUNCTION = YES;
379 | GCC_WARN_UNUSED_VARIABLE = YES;
380 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
381 | MTL_ENABLE_DEBUG_INFO = YES;
382 | ONLY_ACTIVE_ARCH = YES;
383 | SDKROOT = iphoneos;
384 | TARGETED_DEVICE_FAMILY = "1,2";
385 | };
386 | name = Debug;
387 | };
388 | 97C147041CF9000F007C117D /* Release */ = {
389 | isa = XCBuildConfiguration;
390 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
391 | buildSettings = {
392 | ALWAYS_SEARCH_USER_PATHS = NO;
393 | CLANG_ANALYZER_NONNULL = YES;
394 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
395 | CLANG_CXX_LIBRARY = "libc++";
396 | CLANG_ENABLE_MODULES = YES;
397 | CLANG_ENABLE_OBJC_ARC = YES;
398 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
399 | CLANG_WARN_BOOL_CONVERSION = YES;
400 | CLANG_WARN_COMMA = YES;
401 | CLANG_WARN_CONSTANT_CONVERSION = YES;
402 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
403 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
404 | CLANG_WARN_EMPTY_BODY = YES;
405 | CLANG_WARN_ENUM_CONVERSION = YES;
406 | CLANG_WARN_INFINITE_RECURSION = YES;
407 | CLANG_WARN_INT_CONVERSION = YES;
408 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
409 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
410 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
411 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
412 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
413 | CLANG_WARN_STRICT_PROTOTYPES = YES;
414 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
415 | CLANG_WARN_UNREACHABLE_CODE = YES;
416 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
417 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
418 | COPY_PHASE_STRIP = NO;
419 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
420 | ENABLE_NS_ASSERTIONS = NO;
421 | ENABLE_STRICT_OBJC_MSGSEND = YES;
422 | GCC_C_LANGUAGE_STANDARD = gnu99;
423 | GCC_NO_COMMON_BLOCKS = YES;
424 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
425 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
426 | GCC_WARN_UNDECLARED_SELECTOR = YES;
427 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
428 | GCC_WARN_UNUSED_FUNCTION = YES;
429 | GCC_WARN_UNUSED_VARIABLE = YES;
430 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
431 | MTL_ENABLE_DEBUG_INFO = NO;
432 | SDKROOT = iphoneos;
433 | SUPPORTED_PLATFORMS = iphoneos;
434 | TARGETED_DEVICE_FAMILY = "1,2";
435 | VALIDATE_PRODUCT = YES;
436 | };
437 | name = Release;
438 | };
439 | 97C147061CF9000F007C117D /* Debug */ = {
440 | isa = XCBuildConfiguration;
441 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
442 | buildSettings = {
443 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
444 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
445 | ENABLE_BITCODE = NO;
446 | FRAMEWORK_SEARCH_PATHS = (
447 | "$(inherited)",
448 | "$(PROJECT_DIR)/Flutter",
449 | );
450 | INFOPLIST_FILE = Runner/Info.plist;
451 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
452 | LIBRARY_SEARCH_PATHS = (
453 | "$(inherited)",
454 | "$(PROJECT_DIR)/Flutter",
455 | );
456 | PRODUCT_BUNDLE_IDENTIFIER = com.example.gitBindingsExample;
457 | PRODUCT_NAME = "$(TARGET_NAME)";
458 | VERSIONING_SYSTEM = "apple-generic";
459 | };
460 | name = Debug;
461 | };
462 | 97C147071CF9000F007C117D /* Release */ = {
463 | isa = XCBuildConfiguration;
464 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
465 | buildSettings = {
466 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
467 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
468 | ENABLE_BITCODE = NO;
469 | FRAMEWORK_SEARCH_PATHS = (
470 | "$(inherited)",
471 | "$(PROJECT_DIR)/Flutter",
472 | );
473 | INFOPLIST_FILE = Runner/Info.plist;
474 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
475 | LIBRARY_SEARCH_PATHS = (
476 | "$(inherited)",
477 | "$(PROJECT_DIR)/Flutter",
478 | );
479 | PRODUCT_BUNDLE_IDENTIFIER = com.example.gitBindingsExample;
480 | PRODUCT_NAME = "$(TARGET_NAME)";
481 | VERSIONING_SYSTEM = "apple-generic";
482 | };
483 | name = Release;
484 | };
485 | /* End XCBuildConfiguration section */
486 |
487 | /* Begin XCConfigurationList section */
488 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = {
489 | isa = XCConfigurationList;
490 | buildConfigurations = (
491 | 97C147031CF9000F007C117D /* Debug */,
492 | 97C147041CF9000F007C117D /* Release */,
493 | 249021D3217E4FDB00AE95B9 /* Profile */,
494 | );
495 | defaultConfigurationIsVisible = 0;
496 | defaultConfigurationName = Release;
497 | };
498 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = {
499 | isa = XCConfigurationList;
500 | buildConfigurations = (
501 | 97C147061CF9000F007C117D /* Debug */,
502 | 97C147071CF9000F007C117D /* Release */,
503 | 249021D4217E4FDB00AE95B9 /* Profile */,
504 | );
505 | defaultConfigurationIsVisible = 0;
506 | defaultConfigurationName = Release;
507 | };
508 | /* End XCConfigurationList section */
509 | };
510 | rootObject = 97C146E61CF9000F007C117D /* Project object */;
511 | }
512 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/ios/Runner/AppDelegate.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | @interface AppDelegate : FlutterAppDelegate
5 |
6 | @end
7 |
--------------------------------------------------------------------------------
/example/ios/Runner/AppDelegate.m:
--------------------------------------------------------------------------------
1 | #import "AppDelegate.h"
2 | #import "GeneratedPluginRegistrant.h"
3 |
4 | @implementation AppDelegate
5 |
6 | - (BOOL)application:(UIApplication *)application
7 | didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
8 | [GeneratedPluginRegistrant registerWithRegistry:self];
9 | // Override point for customization after application launch.
10 | return [super application:application didFinishLaunchingWithOptions:launchOptions];
11 | }
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "20x20",
5 | "idiom" : "iphone",
6 | "filename" : "Icon-App-20x20@2x.png",
7 | "scale" : "2x"
8 | },
9 | {
10 | "size" : "20x20",
11 | "idiom" : "iphone",
12 | "filename" : "Icon-App-20x20@3x.png",
13 | "scale" : "3x"
14 | },
15 | {
16 | "size" : "29x29",
17 | "idiom" : "iphone",
18 | "filename" : "Icon-App-29x29@1x.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "29x29",
23 | "idiom" : "iphone",
24 | "filename" : "Icon-App-29x29@2x.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "29x29",
29 | "idiom" : "iphone",
30 | "filename" : "Icon-App-29x29@3x.png",
31 | "scale" : "3x"
32 | },
33 | {
34 | "size" : "40x40",
35 | "idiom" : "iphone",
36 | "filename" : "Icon-App-40x40@2x.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "40x40",
41 | "idiom" : "iphone",
42 | "filename" : "Icon-App-40x40@3x.png",
43 | "scale" : "3x"
44 | },
45 | {
46 | "size" : "60x60",
47 | "idiom" : "iphone",
48 | "filename" : "Icon-App-60x60@2x.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "60x60",
53 | "idiom" : "iphone",
54 | "filename" : "Icon-App-60x60@3x.png",
55 | "scale" : "3x"
56 | },
57 | {
58 | "size" : "20x20",
59 | "idiom" : "ipad",
60 | "filename" : "Icon-App-20x20@1x.png",
61 | "scale" : "1x"
62 | },
63 | {
64 | "size" : "20x20",
65 | "idiom" : "ipad",
66 | "filename" : "Icon-App-20x20@2x.png",
67 | "scale" : "2x"
68 | },
69 | {
70 | "size" : "29x29",
71 | "idiom" : "ipad",
72 | "filename" : "Icon-App-29x29@1x.png",
73 | "scale" : "1x"
74 | },
75 | {
76 | "size" : "29x29",
77 | "idiom" : "ipad",
78 | "filename" : "Icon-App-29x29@2x.png",
79 | "scale" : "2x"
80 | },
81 | {
82 | "size" : "40x40",
83 | "idiom" : "ipad",
84 | "filename" : "Icon-App-40x40@1x.png",
85 | "scale" : "1x"
86 | },
87 | {
88 | "size" : "40x40",
89 | "idiom" : "ipad",
90 | "filename" : "Icon-App-40x40@2x.png",
91 | "scale" : "2x"
92 | },
93 | {
94 | "size" : "76x76",
95 | "idiom" : "ipad",
96 | "filename" : "Icon-App-76x76@1x.png",
97 | "scale" : "1x"
98 | },
99 | {
100 | "size" : "76x76",
101 | "idiom" : "ipad",
102 | "filename" : "Icon-App-76x76@2x.png",
103 | "scale" : "2x"
104 | },
105 | {
106 | "size" : "83.5x83.5",
107 | "idiom" : "ipad",
108 | "filename" : "Icon-App-83.5x83.5@2x.png",
109 | "scale" : "2x"
110 | },
111 | {
112 | "size" : "1024x1024",
113 | "idiom" : "ios-marketing",
114 | "filename" : "Icon-App-1024x1024@1x.png",
115 | "scale" : "1x"
116 | }
117 | ],
118 | "info" : {
119 | "version" : 1,
120 | "author" : "xcode"
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitJournal/git_bindings/ba1db24a7f9c29f4e5c9c4116c24687605f6d903/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitJournal/git_bindings/ba1db24a7f9c29f4e5c9c4116c24687605f6d903/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitJournal/git_bindings/ba1db24a7f9c29f4e5c9c4116c24687605f6d903/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitJournal/git_bindings/ba1db24a7f9c29f4e5c9c4116c24687605f6d903/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitJournal/git_bindings/ba1db24a7f9c29f4e5c9c4116c24687605f6d903/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitJournal/git_bindings/ba1db24a7f9c29f4e5c9c4116c24687605f6d903/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitJournal/git_bindings/ba1db24a7f9c29f4e5c9c4116c24687605f6d903/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitJournal/git_bindings/ba1db24a7f9c29f4e5c9c4116c24687605f6d903/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitJournal/git_bindings/ba1db24a7f9c29f4e5c9c4116c24687605f6d903/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitJournal/git_bindings/ba1db24a7f9c29f4e5c9c4116c24687605f6d903/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitJournal/git_bindings/ba1db24a7f9c29f4e5c9c4116c24687605f6d903/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitJournal/git_bindings/ba1db24a7f9c29f4e5c9c4116c24687605f6d903/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitJournal/git_bindings/ba1db24a7f9c29f4e5c9c4116c24687605f6d903/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitJournal/git_bindings/ba1db24a7f9c29f4e5c9c4116c24687605f6d903/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitJournal/git_bindings/ba1db24a7f9c29f4e5c9c4116c24687605f6d903/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchImage.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchImage@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "filename" : "LaunchImage@3x.png",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitJournal/git_bindings/ba1db24a7f9c29f4e5c9c4116c24687605f6d903/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitJournal/git_bindings/ba1db24a7f9c29f4e5c9c4116c24687605f6d903/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitJournal/git_bindings/ba1db24a7f9c29f4e5c9c4116c24687605f6d903/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md:
--------------------------------------------------------------------------------
1 | # Launch Screen Assets
2 |
3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory.
4 |
5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.
--------------------------------------------------------------------------------
/example/ios/Runner/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/example/ios/Runner/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/example/ios/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | git_bindings_example
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | $(FLUTTER_BUILD_NAME)
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(FLUTTER_BUILD_NUMBER)
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UISupportedInterfaceOrientations
30 |
31 | UIInterfaceOrientationPortrait
32 | UIInterfaceOrientationLandscapeLeft
33 | UIInterfaceOrientationLandscapeRight
34 |
35 | UISupportedInterfaceOrientations~ipad
36 |
37 | UIInterfaceOrientationPortrait
38 | UIInterfaceOrientationPortraitUpsideDown
39 | UIInterfaceOrientationLandscapeLeft
40 | UIInterfaceOrientationLandscapeRight
41 |
42 | UIViewControllerBasedStatusBarAppearance
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/example/ios/Runner/main.m:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 | #import "AppDelegate.h"
4 |
5 | int main(int argc, char* argv[]) {
6 | @autoreleasepool {
7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/example/lib/main.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter/services.dart';
3 |
4 | import 'package:path/path.dart' as p;
5 | import 'package:path_provider/path_provider.dart';
6 |
7 | import 'package:git_bindings/git_bindings.dart';
8 |
9 | void main() {
10 | runApp(GitApp());
11 | }
12 |
13 | const gitFolderName = "journal";
14 |
15 | class GitApp extends StatefulWidget {
16 | @override
17 | _GitAppState createState() => _GitAppState();
18 | }
19 |
20 | class _GitAppState extends State {
21 | final GlobalKey _scaffoldKey = GlobalKey();
22 | GitRepo gitRepo;
23 |
24 | var cloneUrl = "git@github.com:GitJournal/journal_test.git";
25 | TextEditingController cloneUrlController;
26 |
27 | String publicKey = "";
28 |
29 | @override
30 | void initState() {
31 | super.initState();
32 |
33 | cloneUrlController = TextEditingController(text: cloneUrl);
34 |
35 | getApplicationSupportDirectory().then((dir) async {
36 | var repoPath = p.join(dir.path, gitFolderName);
37 | gitRepo = GitRepo(
38 | folderPath: repoPath,
39 | );
40 | print("GitRepo Initialized");
41 | });
42 | }
43 |
44 | @override
45 | Widget build(BuildContext context) {
46 | var cloneUrlWidget = TextField(
47 | decoration: InputDecoration(
48 | border: OutlineInputBorder(),
49 | hintText: "Clone URL",
50 | ),
51 | onChanged: (newValue) {
52 | setState(() {
53 | cloneUrl = newValue;
54 | });
55 | },
56 | controller: cloneUrlController,
57 | );
58 |
59 | var publicKeyWidget = Container(
60 | child: Text(publicKey),
61 | margin: const EdgeInsets.all(15.0),
62 | padding: const EdgeInsets.all(3.0),
63 | decoration: BoxDecoration(border: Border.all(color: Colors.blueAccent)),
64 | );
65 |
66 | var columns = Column(
67 | children: [
68 | cloneUrlWidget,
69 | ..._buildGitButtons(),
70 | publicKeyWidget,
71 | ],
72 | crossAxisAlignment: CrossAxisAlignment.center,
73 | mainAxisAlignment: MainAxisAlignment.center,
74 | );
75 |
76 | return MaterialApp(
77 | title: 'Git App',
78 | home: Scaffold(
79 | key: _scaffoldKey,
80 | appBar: AppBar(
81 | title: const Text('Git Test'),
82 | ),
83 | body: Padding(
84 | padding: EdgeInsets.all(8.0),
85 | child: SingleChildScrollView(child: columns),
86 | ),
87 | ),
88 | );
89 | }
90 |
91 | void _sendSuccess() {
92 | var text = "Success";
93 | _scaffoldKey.currentState
94 | ..removeCurrentSnackBar()
95 | ..showSnackBar(SnackBar(content: Text(text)));
96 | }
97 |
98 | /*
99 | void _sendError(String text) {
100 | _scaffoldKey.currentState
101 | ..removeCurrentSnackBar()
102 | ..showSnackBar(SnackBar(content: Text("ERROR: " + text)));
103 | }
104 | */
105 |
106 | List _buildGitButtons() {
107 | return [
108 | RaisedButton(
109 | child: const Text("Copy Key to Clipboard"),
110 | onPressed: () async {
111 | await Clipboard.setData(ClipboardData(text: publicKey));
112 | _sendSuccess();
113 | },
114 | ),
115 | RaisedButton(
116 | child: const Text("Git Pull"),
117 | onPressed: () async {
118 | //await gitRepo.fetch("origin");
119 | await gitRepo.merge(
120 | branch: "origin/master",
121 | authorName: "Vishesh Handa",
122 | authorEmail: "noemail@example.com",
123 | );
124 | },
125 | ),
126 | RaisedButton(
127 | child: const Text("Git Add"),
128 | onPressed: () async {
129 | gitRepo.add(".");
130 | },
131 | ),
132 | RaisedButton(
133 | child: const Text("Git Push"),
134 | onPressed: () async {
135 | //gitRepo.push("origin");
136 | },
137 | ),
138 | RaisedButton(
139 | child: const Text("Git Commit"),
140 | onPressed: () async {
141 | gitRepo.commit(
142 | message: "Default message from GitJournal",
143 | when: "2017-10-20T01:21:10+02:00",
144 | authorName: "Vishesh Handa",
145 | authorEmail: "noemail@example.com",
146 | );
147 | },
148 | ),
149 | RaisedButton(
150 | child: const Text("Git Reset Last"),
151 | onPressed: () async {
152 | gitRepo.resetLast();
153 | },
154 | ),
155 | ];
156 | }
157 | }
158 |
--------------------------------------------------------------------------------
/example/pubspec.lock:
--------------------------------------------------------------------------------
1 | # Generated by pub
2 | # See https://dart.dev/tools/pub/glossary#lockfile
3 | packages:
4 | async:
5 | dependency: transitive
6 | description:
7 | name: async
8 | url: "https://pub.dartlang.org"
9 | source: hosted
10 | version: "2.8.2"
11 | boolean_selector:
12 | dependency: transitive
13 | description:
14 | name: boolean_selector
15 | url: "https://pub.dartlang.org"
16 | source: hosted
17 | version: "2.1.0"
18 | characters:
19 | dependency: transitive
20 | description:
21 | name: characters
22 | url: "https://pub.dartlang.org"
23 | source: hosted
24 | version: "1.2.0"
25 | charcode:
26 | dependency: transitive
27 | description:
28 | name: charcode
29 | url: "https://pub.dartlang.org"
30 | source: hosted
31 | version: "1.3.1"
32 | clock:
33 | dependency: transitive
34 | description:
35 | name: clock
36 | url: "https://pub.dartlang.org"
37 | source: hosted
38 | version: "1.1.0"
39 | collection:
40 | dependency: transitive
41 | description:
42 | name: collection
43 | url: "https://pub.dartlang.org"
44 | source: hosted
45 | version: "1.15.0"
46 | cupertino_icons:
47 | dependency: "direct main"
48 | description:
49 | name: cupertino_icons
50 | url: "https://pub.dartlang.org"
51 | source: hosted
52 | version: "0.1.3"
53 | fake_async:
54 | dependency: transitive
55 | description:
56 | name: fake_async
57 | url: "https://pub.dartlang.org"
58 | source: hosted
59 | version: "1.2.0"
60 | flutter:
61 | dependency: "direct main"
62 | description: flutter
63 | source: sdk
64 | version: "0.0.0"
65 | flutter_test:
66 | dependency: "direct dev"
67 | description: flutter
68 | source: sdk
69 | version: "0.0.0"
70 | git_bindings:
71 | dependency: "direct main"
72 | description:
73 | path: ".."
74 | relative: true
75 | source: path
76 | version: "0.0.18"
77 | matcher:
78 | dependency: transitive
79 | description:
80 | name: matcher
81 | url: "https://pub.dartlang.org"
82 | source: hosted
83 | version: "0.12.11"
84 | material_color_utilities:
85 | dependency: transitive
86 | description:
87 | name: material_color_utilities
88 | url: "https://pub.dartlang.org"
89 | source: hosted
90 | version: "0.1.3"
91 | meta:
92 | dependency: transitive
93 | description:
94 | name: meta
95 | url: "https://pub.dartlang.org"
96 | source: hosted
97 | version: "1.7.0"
98 | path:
99 | dependency: transitive
100 | description:
101 | name: path
102 | url: "https://pub.dartlang.org"
103 | source: hosted
104 | version: "1.8.0"
105 | path_provider:
106 | dependency: "direct main"
107 | description:
108 | name: path_provider
109 | url: "https://pub.dartlang.org"
110 | source: hosted
111 | version: "1.5.1"
112 | platform:
113 | dependency: transitive
114 | description:
115 | name: platform
116 | url: "https://pub.dartlang.org"
117 | source: hosted
118 | version: "2.2.1"
119 | sky_engine:
120 | dependency: transitive
121 | description: flutter
122 | source: sdk
123 | version: "0.0.99"
124 | source_span:
125 | dependency: transitive
126 | description:
127 | name: source_span
128 | url: "https://pub.dartlang.org"
129 | source: hosted
130 | version: "1.8.1"
131 | stack_trace:
132 | dependency: transitive
133 | description:
134 | name: stack_trace
135 | url: "https://pub.dartlang.org"
136 | source: hosted
137 | version: "1.10.0"
138 | stream_channel:
139 | dependency: transitive
140 | description:
141 | name: stream_channel
142 | url: "https://pub.dartlang.org"
143 | source: hosted
144 | version: "2.1.0"
145 | string_scanner:
146 | dependency: transitive
147 | description:
148 | name: string_scanner
149 | url: "https://pub.dartlang.org"
150 | source: hosted
151 | version: "1.1.0"
152 | term_glyph:
153 | dependency: transitive
154 | description:
155 | name: term_glyph
156 | url: "https://pub.dartlang.org"
157 | source: hosted
158 | version: "1.2.0"
159 | test_api:
160 | dependency: transitive
161 | description:
162 | name: test_api
163 | url: "https://pub.dartlang.org"
164 | source: hosted
165 | version: "0.4.8"
166 | typed_data:
167 | dependency: transitive
168 | description:
169 | name: typed_data
170 | url: "https://pub.dartlang.org"
171 | source: hosted
172 | version: "1.3.0"
173 | vector_math:
174 | dependency: transitive
175 | description:
176 | name: vector_math
177 | url: "https://pub.dartlang.org"
178 | source: hosted
179 | version: "2.1.1"
180 | sdks:
181 | dart: ">=2.14.0 <3.0.0"
182 | flutter: ">=1.10.7"
183 |
--------------------------------------------------------------------------------
/example/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: git_bindings_example
2 | description: Demonstrates how to use the git_bindings plugin.
3 | publish_to: "none"
4 |
5 | environment:
6 | sdk: ">=2.3.0 <3.0.0"
7 |
8 | dependencies:
9 | flutter:
10 | sdk: flutter
11 |
12 | # The following adds the Cupertino Icons font to your application.
13 | # Use with the CupertinoIcons class for iOS style icons.
14 | cupertino_icons: ^0.1.2
15 | path_provider: ^1.5.1
16 | git_bindings:
17 | path: ../
18 |
19 | dev_dependencies:
20 | flutter_test:
21 | sdk: flutter
22 |
23 | flutter:
24 | uses-material-design: true
25 |
--------------------------------------------------------------------------------
/git_bindings.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/gj_common/.dockerignore:
--------------------------------------------------------------------------------
1 | test
2 | test.dSYM
3 | .vscode
4 |
--------------------------------------------------------------------------------
/gj_common/.gitignore:
--------------------------------------------------------------------------------
1 | test
2 | test.dSYM
3 | infer-out
4 |
--------------------------------------------------------------------------------
/gj_common/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM ubuntu:18.10
2 |
3 | ENV DEBIAN_FRONTEND noninteractive
4 | ENV TZ Europe/Madrid
5 |
6 | RUN apt-get update
7 | RUN apt-get install -y libssh2-1-dev curl gdb cppcheck xz-utils sudo libtinfo5
8 | RUN apt-get install -y cmake libssl-dev pkg-config zlib1g-dev clang tzdata git vim
9 |
10 | COPY . /opt
11 | RUN cd /opt && ./build-libgit2.sh
12 |
--------------------------------------------------------------------------------
/gj_common/Makefile:
--------------------------------------------------------------------------------
1 | CC=clang
2 |
3 | test: gitjournal.c test.c keygen.c common.c
4 | $(CC) -o test -g test.c common.c gitjournal.c keygen.c -lgit2 -lssl -lcrypto
5 |
6 | build-env: Dockerfile
7 | docker build -t gitjournal_lib .
8 |
9 | shell:
10 | docker run --rm -it -v `pwd`:/code -w /code gitjournal_lib bash
11 |
12 | cppcheck:
13 | cppcheck --enable=all --suppress=unusedFunction common.c gitjournal.c keygen.c
14 |
--------------------------------------------------------------------------------
/gj_common/build-libgit2.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -eux
4 |
5 | LIBGIT2_VERSION="0.28.1"
6 | if [ ! -f "libgit2.tar.gz" ]; then
7 | curl https://codeload.github.com/libgit2/libgit2/tar.gz/v${LIBGIT2_VERSION} -o libgit2.tar.gz
8 | fi
9 |
10 | tar -xzf libgit2.tar.gz
11 | cd libgit2-${LIBGIT2_VERSION}
12 |
13 | mkdir build
14 | cd build
15 |
16 | cmake ../ \
17 | -DCMAKE_BUILD_TYPE=Release \
18 | -DCMAKE_INSTALL_PREFIX=/usr \
19 |
20 | if [ $? -ne 0 ]; then
21 | echo "Error executing cmake"
22 | exit 1
23 | fi
24 |
25 | cmake --build .
26 |
27 | if [ $? -ne 0 ]; then
28 | echo "Error building"
29 | exit 1
30 | fi
31 |
32 | make install
33 |
--------------------------------------------------------------------------------
/gj_common/common.c:
--------------------------------------------------------------------------------
1 | #include "gitjournal.h"
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | #include
9 | #include
10 |
11 | void gj_log_internal(const char *format, ...)
12 | {
13 | char buffer[1024];
14 | va_list args;
15 | va_start(args, format);
16 | vsprintf(buffer, format, args);
17 | gj_log(buffer);
18 | va_end(args);
19 | }
20 |
21 | gj_error *gj_error_info(int err)
22 | {
23 | if (err == 0)
24 | return NULL;
25 |
26 | gj_log_internal("gj_error_info: %d\n", err);
27 |
28 | gj_error *error = (gj_error *)malloc(sizeof(gj_error));
29 | if (error == NULL)
30 | {
31 | gj_log_internal("Failed to allocate gj_error\n");
32 | return NULL;
33 | }
34 | error->message_allocated = false;
35 | if (err <= GJ_ERR_FIRST && err >= GJ_ERR_LAST)
36 | {
37 | switch (err)
38 | {
39 | case GJ_ERR_EMPTY_COMMIT:
40 | error->code = err;
41 | error->message = "Empty Commit";
42 | break;
43 |
44 | case GJ_ERR_PULL_INVALID_STATE:
45 | error->code = err;
46 | error->message = "GitPull Invalid State";
47 | break;
48 |
49 | case GJ_ERR_OPENSSL:
50 | error->code = ERR_peek_last_error();
51 | error->message_allocated = true;
52 | error->message = (char *)malloc(256);
53 | ERR_error_string(error->code, error->message);
54 | break;
55 |
56 | case GJ_ERR_INVALID_CREDENTIALS:
57 | error->code = err;
58 | error->message = "Invalid Credentials";
59 | break;
60 |
61 | case GJ_ERR_MISSING_PUBLIC_KEY:
62 | error->code = err;
63 | error->message = "Missing Public SSH Key";
64 | break;
65 |
66 | case GJ_ERR_MISSING_PRIVATE_KEY:
67 | error->code = err;
68 | error->message = "Missing Private SSH Key";
69 | break;
70 | }
71 | return error;
72 | }
73 |
74 | const git_error *e = git_error_last();
75 | if (e)
76 | {
77 | error->code = e->klass;
78 | error->message = (char *)malloc(strlen(e->message));
79 | if (error->message != NULL)
80 | {
81 | strcpy(error->message, e->message);
82 | error->message_allocated = true;
83 | }
84 | else
85 | {
86 | error->message = "Unknown Error - Malloc Failed";
87 | }
88 | }
89 | else
90 | {
91 | error->code = 1000;
92 | error->message = "Unknown Error";
93 | }
94 |
95 | return error;
96 | }
97 |
98 | void gj_error_free(const gj_error *err)
99 | {
100 | if (err->message_allocated)
101 | free(err->message);
102 | free((void *)err);
103 | }
104 |
--------------------------------------------------------------------------------
/gj_common/gitjournal.c:
--------------------------------------------------------------------------------
1 | #include "gitjournal.h"
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | #include
11 |
12 | #define UNUSED(x) (void)(x)
13 |
14 | typedef struct
15 | {
16 | bool first_time;
17 | int error_code;
18 | bool ssh_in_memory;
19 | char *status_file;
20 | } gj_credentials_payload;
21 |
22 | int match_cb(const char *path, const char *spec, void *payload)
23 | {
24 | UNUSED(spec);
25 | UNUSED(payload);
26 |
27 | gj_log_internal("Add Match: %s\n", path);
28 | return 0;
29 | }
30 |
31 | int gj_git_add(const char *git_base_path, const char *pattern)
32 | {
33 | int err;
34 | git_repository *repo = NULL;
35 | git_index *index = NULL;
36 |
37 | err = git_repository_open(&repo, git_base_path);
38 | if (err < 0)
39 | goto cleanup;
40 |
41 | err = git_repository_index(&index, repo);
42 | if (err < 0)
43 | goto cleanup;
44 |
45 | char *paths[] = {(char *)pattern};
46 | git_strarray pathspec = {paths, 1};
47 |
48 | err = git_index_add_all(index, &pathspec, GIT_INDEX_ADD_DEFAULT, match_cb, NULL);
49 | if (err < 0)
50 | goto cleanup;
51 |
52 | err = git_index_write(index);
53 | if (err < 0)
54 | goto cleanup;
55 |
56 | cleanup:
57 | git_index_free(index);
58 | git_repository_free(repo);
59 |
60 | return err;
61 | }
62 |
63 | int rm_match_cb(const char *path, const char *spec, void *payload)
64 | {
65 | UNUSED(spec);
66 | UNUSED(payload);
67 |
68 | char *git_base_path = (char *)payload;
69 | if (!git_base_path)
70 | {
71 | gj_log_internal("git_base_path not in payload. Why?\n");
72 | return 1;
73 | }
74 |
75 | int full_path_length = strlen(git_base_path) + 1 + strlen(path);
76 | char *full_path = (char *)malloc(full_path_length);
77 | if (full_path == NULL)
78 | {
79 | gj_log_internal("rm_match_cb: Malloc Failed");
80 | return 1;
81 | }
82 | strcpy(full_path, git_base_path);
83 | strcat(full_path, "/"); // FIXME: Will not work on windows!
84 | strcat(full_path, path);
85 |
86 | gj_log_internal("Removing File: %s\n", full_path);
87 | int err = remove(full_path);
88 | if (err != 0)
89 | {
90 | gj_log_internal("File could not be deleted: %s %d\n", full_path, errno);
91 | if (errno == ENOENT)
92 | {
93 | gj_log_internal("ENOENT\n");
94 | }
95 | }
96 |
97 | free(full_path);
98 | return 0;
99 | }
100 |
101 | int gj_git_rm(const char *git_base_path, const char *pattern)
102 | {
103 | int err;
104 | git_repository *repo = NULL;
105 | git_index *index = NULL;
106 |
107 | err = git_repository_open(&repo, git_base_path);
108 | if (err < 0)
109 | goto cleanup;
110 |
111 | err = git_repository_index(&index, repo);
112 | if (err < 0)
113 | goto cleanup;
114 |
115 | char *paths[] = {(char *)pattern};
116 | git_strarray pathspec = {paths, 1};
117 |
118 | gj_log_internal("Calling git rm with pathspec %s", pattern);
119 | err = git_index_remove_all(index, &pathspec, rm_match_cb, (void *)git_base_path);
120 | if (err < 0)
121 | goto cleanup;
122 |
123 | err = git_index_write(index);
124 | if (err < 0)
125 | goto cleanup;
126 |
127 | cleanup:
128 | git_index_free(index);
129 | git_repository_free(repo);
130 |
131 | return err;
132 | }
133 |
134 | int gj_git_reset_hard(const char *git_base_path, const char *ref)
135 | {
136 | int err = 0;
137 | git_repository *repo = NULL;
138 | git_object *obj = NULL;
139 |
140 | err = git_repository_open(&repo, git_base_path);
141 | if (err < 0)
142 | goto cleanup;
143 |
144 | err = git_revparse_single(&obj, repo, ref);
145 | if (err < 0)
146 | goto cleanup;
147 |
148 | err = git_reset(repo, obj, GIT_RESET_HARD, NULL);
149 | if (err < 0)
150 | goto cleanup;
151 |
152 | cleanup:
153 | git_object_free(obj);
154 | git_repository_free(repo);
155 |
156 | return err;
157 | }
158 |
159 | int gj_git_commit(const char *git_base_path, const char *author_name,
160 | const char *author_email, const char *message, long long commit_time, int commit_time_offset)
161 | {
162 | int err = 0;
163 | git_signature *sig = NULL;
164 | git_index *index = NULL;
165 | git_oid tree_id, commit_id;
166 | git_tree *tree = NULL;
167 | git_repository *repo = NULL;
168 | git_oid parent_id;
169 | git_commit *parent_commit = NULL;
170 |
171 | err = git_repository_open(&repo, git_base_path);
172 | if (err < 0)
173 | goto cleanup;
174 |
175 | err = git_repository_index(&index, repo);
176 | if (err < 0)
177 | goto cleanup;
178 |
179 | /*
180 | FIXME: This returns 0 when a file is set to be removed
181 | How do we figure out when the index is empty?
182 | int numOps = git_index_entrycount(index);
183 | if (numOps == 0)
184 | {
185 | err = GJ_ERR_EMPTY_COMMIT;
186 | goto cleanup;
187 | }
188 | */
189 |
190 | if (commit_time == 0)
191 | {
192 | err = git_signature_now(&sig, author_name, author_email);
193 | if (err < 0)
194 | goto cleanup;
195 | }
196 | else
197 | {
198 | err = git_signature_new(&sig, author_name, author_email, commit_time, commit_time_offset);
199 | if (err < 0)
200 | goto cleanup;
201 | }
202 |
203 | err = git_index_write_tree(&tree_id, index);
204 | if (err < 0)
205 | goto cleanup;
206 |
207 | err = git_tree_lookup(&tree, repo, &tree_id);
208 | if (err < 0)
209 | goto cleanup;
210 |
211 | err = git_reference_name_to_id(&parent_id, repo, "HEAD");
212 | if (err < 0)
213 | {
214 | if (err != GIT_ENOTFOUND)
215 | goto cleanup;
216 |
217 | git_error_clear();
218 |
219 | err = git_commit_create(&commit_id, repo, "HEAD", sig, sig, NULL, message, tree, 0, NULL);
220 | if (err < 0)
221 | goto cleanup;
222 | }
223 | else
224 | {
225 | err = git_commit_lookup(&parent_commit, repo, &parent_id);
226 | if (err < 0)
227 | goto cleanup;
228 |
229 | const git_commit *parents = {parent_commit};
230 | err = git_commit_create(&commit_id, repo, "HEAD", sig, sig, NULL, message, tree, 1, &parents);
231 | if (err < 0)
232 | goto cleanup;
233 | }
234 |
235 | cleanup:
236 | git_index_free(index);
237 | git_commit_free(parent_commit);
238 | git_tree_free(tree);
239 | git_repository_free(repo);
240 | git_signature_free(sig);
241 |
242 | return err;
243 | }
244 |
245 | int fetch_progress(const git_transfer_progress *stats, void *payload)
246 | {
247 | int fetch_percent =
248 | (100 * stats->received_objects) /
249 | stats->total_objects;
250 | int index_percent =
251 | (100 * stats->indexed_objects) /
252 | stats->total_objects;
253 | int kbytes = stats->received_bytes / 1024;
254 |
255 | gj_log_internal("network %3d%% (%4d kb, %5d/%5d) /"
256 | " index %3d%% (%5d/%5d)\n",
257 | fetch_percent, kbytes,
258 | stats->received_objects, stats->total_objects,
259 | index_percent,
260 | stats->indexed_objects, stats->total_objects);
261 |
262 | gj_credentials_payload *gj_payload = (gj_credentials_payload *)payload;
263 | if (gj_payload != 0)
264 | {
265 | if (gj_payload->status_file != 0)
266 | {
267 | FILE *fp = fopen(gj_payload->status_file, "w");
268 | char str[180];
269 | memset(str, 0, sizeof(str));
270 | sprintf(str, "%d %d %d %d %d %d %d \n", stats->total_objects, stats->indexed_objects, stats->received_objects, stats->local_objects, stats->total_deltas, stats->indexed_deltas, (int)stats->received_bytes);
271 | fwrite(str, 1, sizeof(str), fp);
272 | fclose(fp);
273 | }
274 | }
275 |
276 | return 0;
277 | }
278 |
279 | char *g_public_key = NULL;
280 | char *g_private_key = NULL;
281 | char *g_public_key_path = NULL;
282 | char *g_private_key_path = NULL;
283 | char *g_passcode = NULL;
284 |
285 | int write_to_path(char *path, char *value)
286 | {
287 | FILE *fptr = fopen(path, "w");
288 |
289 | if (fptr == NULL)
290 | {
291 | gj_log_internal("Failed to write to file: %s\n", path);
292 | return -1;
293 | }
294 |
295 | fprintf(fptr, "%s\n", value);
296 | fclose(fptr);
297 | return 0;
298 | }
299 |
300 | char *build_git_path(char *base_url, char *filename)
301 | {
302 | char *str = malloc(strlen(base_url) + strlen(filename) + 10);
303 | strcpy(str, base_url);
304 | strcat(str, "/.git/");
305 | strcat(str, filename);
306 |
307 | return str;
308 | }
309 |
310 | char *build_path(char *base_url, char *filename)
311 | {
312 | char *str = malloc(strlen(base_url) + strlen(filename) + 10);
313 | strcpy(str, base_url);
314 | strcat(str, "/");
315 | strcat(str, filename);
316 |
317 | return str;
318 | }
319 |
320 | void write_keys_to_file(char *base_url)
321 | {
322 | if (g_public_key_path != NULL)
323 | {
324 | free(g_public_key_path);
325 | g_public_key_path = NULL;
326 | }
327 | if (g_private_key_path != NULL)
328 | {
329 | free(g_private_key_path);
330 | g_private_key_path = NULL;
331 | }
332 |
333 | // Make sure the base_url exists
334 | struct stat sb;
335 | if (stat(base_url, &sb) == 0 && S_ISDIR(sb.st_mode))
336 | {
337 | // Directory exists
338 | g_private_key_path = build_git_path(base_url, "id_ed25519");
339 | g_public_key_path = build_git_path(base_url, "id_ed25519.pub");
340 | }
341 | else
342 | {
343 | base_url = dirname(base_url);
344 | g_private_key_path = build_path(base_url, "id_ed25519");
345 | g_public_key_path = build_path(base_url, "id_ed25519.pub");
346 | }
347 |
348 | gj_log_internal("Public Key Path: %s\n", g_public_key_path);
349 | gj_log_internal("Private Key Path: %s\n", g_private_key_path);
350 |
351 | write_to_path(g_public_key_path, g_public_key);
352 | write_to_path(g_private_key_path, g_private_key);
353 |
354 | chmod(g_private_key_path, 0600);
355 | }
356 |
357 | void delete_keys_from_file()
358 | {
359 | if (g_public_key_path != NULL)
360 | {
361 | remove(g_public_key_path);
362 |
363 | free(g_public_key_path);
364 | g_public_key_path = NULL;
365 | }
366 |
367 | if (g_private_key_path != NULL)
368 | {
369 | remove(g_private_key_path);
370 |
371 | free(g_private_key_path);
372 | g_private_key_path = NULL;
373 | }
374 | }
375 |
376 | bool file_exists(char *filename)
377 | {
378 | struct stat buffer;
379 | return (stat(filename, &buffer) == 0);
380 | }
381 |
382 | int credentials_cb(git_cred **out, const char *url, const char *username_from_url,
383 | unsigned int allowed_types, void *payload)
384 | {
385 | if (!payload)
386 | {
387 | gj_log_internal("credentials_cb has no payload\n");
388 | return -1;
389 | }
390 | gj_credentials_payload *gj_payload = (gj_credentials_payload *)payload;
391 | if (!gj_payload->first_time)
392 | {
393 | gj_payload->error_code = GJ_ERR_INVALID_CREDENTIALS;
394 | gj_log_internal("GitJournal: Credentials have been tried and they failed\n");
395 | return GJ_ERR_INVALID_CREDENTIALS;
396 | }
397 |
398 | gj_log_internal("Url: %s\n", url);
399 |
400 | if (!((allowed_types & GIT_CREDTYPE_SSH_KEY) | (allowed_types & GIT_CREDTYPE_USERPASS_PLAINTEXT)))
401 | {
402 | gj_log_internal("Some other auth mechanism is being used: %d\n", allowed_types);
403 | return -1;
404 | }
405 |
406 | if (gj_payload->ssh_in_memory)
407 | {
408 | if (strlen(g_public_key) == 0)
409 | {
410 | gj_payload->error_code = GJ_ERR_MISSING_PUBLIC_KEY;
411 | gj_log_internal("Public Key is empty\n");
412 | return GJ_ERR_MISSING_PUBLIC_KEY;
413 | }
414 |
415 | if (strlen(g_private_key) == 0)
416 | {
417 | gj_payload->error_code = GJ_ERR_MISSING_PRIVATE_KEY;
418 | gj_log_internal("Private Key is empty\n");
419 | return GJ_ERR_MISSING_PRIVATE_KEY;
420 | }
421 |
422 | gj_payload->first_time = false;
423 | return git_cred_ssh_key_memory_new(out, username_from_url,
424 | g_public_key, g_private_key, g_passcode);
425 | }
426 | else
427 | {
428 | if (strlen(g_public_key_path) == 0)
429 | {
430 | gj_payload->error_code = GJ_ERR_MISSING_PUBLIC_KEY;
431 | gj_log_internal("Public Key is empty\n");
432 | return GJ_ERR_MISSING_PUBLIC_KEY;
433 | }
434 |
435 | if (strlen(g_private_key_path) == 0)
436 | {
437 | gj_payload->error_code = GJ_ERR_MISSING_PRIVATE_KEY;
438 | gj_log_internal("Private Key is empty\n");
439 | return GJ_ERR_MISSING_PRIVATE_KEY;
440 | }
441 |
442 | gj_payload->first_time = false;
443 | return git_cred_ssh_key_new(out, username_from_url,
444 | g_public_key_path, g_private_key_path, g_passcode);
445 | }
446 | }
447 |
448 | int certificate_check_cb(git_cert *cert, int valid, const char *host, void *payload)
449 | {
450 | gj_log_internal("Valid: %d\n", valid);
451 | gj_log_internal("CertType: %d\n", cert->cert_type);
452 |
453 | if (valid == 0)
454 | {
455 | gj_log_internal("%s: Invalid certificate\n", host);
456 | }
457 |
458 | if (cert->cert_type == GIT_CERT_HOSTKEY_LIBSSH2)
459 | {
460 | gj_log_internal("LibSSH2 Key: %p\n", payload);
461 | return 0;
462 | }
463 | if (cert->cert_type == GIT_CERT_X509)
464 | {
465 | gj_log_internal("Cert X509 Key: %p\n", payload);
466 | return 0;
467 | }
468 |
469 | // FIXME: We should be checking the certificate
470 | gj_log_internal("Unknown Certificate Accepted\n");
471 | return 0;
472 | }
473 |
474 | int gj_git_push(const char *git_base_path, const char *remote_name, char *public_key, char *private_key, char *passcode, bool ssh_in_memory, char *status_file)
475 | {
476 | g_public_key = public_key;
477 | g_private_key = private_key;
478 | g_passcode = passcode;
479 |
480 | if (!ssh_in_memory)
481 | {
482 | write_keys_to_file((char *)git_base_path);
483 | }
484 |
485 | int err = 0;
486 | git_repository *repo = NULL;
487 | git_remote *remote = NULL;
488 | git_reference *ref_head = NULL;
489 | char *name = NULL;
490 |
491 | err = git_repository_open(&repo, git_base_path);
492 | if (err < 0)
493 | goto cleanup;
494 |
495 | err = git_remote_lookup(&remote, repo, remote_name);
496 | if (err < 0)
497 | goto cleanup;
498 |
499 | // Get current branch
500 | err = git_repository_head(&ref_head, repo);
501 | if (err < 0)
502 | goto cleanup;
503 |
504 | git_reference_t head_type = git_reference_type(ref_head);
505 | if (head_type != GIT_REFERENCE_DIRECT)
506 | {
507 | // vHanda: Why are you a direct reference!!
508 | gj_log_internal("git push: head is not a direct ref: %d\n", head_type);
509 | goto cleanup;
510 | }
511 |
512 | char *ref_head_name = (char *)git_reference_name(ref_head);
513 | const git_strarray refs = {&ref_head_name, 1};
514 |
515 | git_push_options options = GIT_PUSH_OPTIONS_INIT;
516 |
517 | if (status_file != 0 && strlen(status_file) == 0)
518 | {
519 | status_file = 0;
520 | }
521 |
522 | gj_credentials_payload gj_payload = {true, 0, ssh_in_memory, status_file};
523 | options.callbacks.payload = (void *)&gj_payload;
524 | options.callbacks.credentials = credentials_cb;
525 |
526 | err = git_remote_push(remote, &refs, &options);
527 | if (err < 0)
528 | goto cleanup;
529 |
530 | cleanup:
531 | free(name);
532 | git_reference_free(ref_head);
533 | git_remote_free(remote);
534 | git_repository_free(repo);
535 |
536 | if (!ssh_in_memory)
537 | {
538 | delete_keys_from_file();
539 | }
540 |
541 | return err;
542 | }
543 |
544 | int gj_git_default_branch(const char *git_base_path, const char *remote_name, char *public_key, char *private_key, char *passcode, bool ssh_in_memory, char *default_branch)
545 | {
546 | g_public_key = public_key;
547 | g_private_key = private_key;
548 | g_passcode = passcode;
549 |
550 | if (!ssh_in_memory)
551 | {
552 | write_keys_to_file((char *)git_base_path);
553 | }
554 |
555 | int err = 0;
556 | git_repository *repo = NULL;
557 | git_remote *remote = NULL;
558 | git_buf buf = {NULL};
559 |
560 | err = git_repository_open(&repo, git_base_path);
561 | if (err < 0)
562 | goto cleanup;
563 |
564 | err = git_remote_lookup(&remote, repo, remote_name);
565 | if (err < 0)
566 | goto cleanup;
567 |
568 | git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT;
569 |
570 | gj_credentials_payload gj_payload = {true, 0, ssh_in_memory, 0};
571 | callbacks.payload = (void *)&gj_payload;
572 | callbacks.credentials = credentials_cb;
573 |
574 | err = git_remote_connect(remote, GIT_DIRECTION_FETCH, &callbacks, NULL, NULL);
575 | if (err < 0)
576 | goto cleanup;
577 |
578 | err = git_remote_default_branch(&buf, remote);
579 | if (err == GIT_ENOTFOUND)
580 | {
581 | default_branch[0] = 0;
582 | }
583 | else if (err < 0)
584 | goto cleanup;
585 | else
586 | {
587 | strncpy(default_branch, buf.ptr, buf.size);
588 | default_branch[buf.size] = 0;
589 | gj_log_internal("git_default_branch %s : %d\n", default_branch, buf.size);
590 | }
591 | cleanup:
592 | git_buf_dispose(&buf);
593 | git_remote_free(remote);
594 | git_repository_free(repo);
595 |
596 | if (!ssh_in_memory)
597 | {
598 | delete_keys_from_file();
599 | }
600 |
601 | return err;
602 | }
603 |
604 | // Taken from merge.c libgit2 examples
605 | static int perform_fastforward(git_repository *repo, const git_oid *target_oid)
606 | {
607 | git_checkout_options ff_checkout_options = GIT_CHECKOUT_OPTIONS_INIT;
608 | git_reference *target_ref = NULL;
609 | git_reference *new_target_ref = NULL;
610 | git_object *target = NULL;
611 | int err = 0;
612 |
613 | err = git_repository_head(&target_ref, repo);
614 | if (err != 0)
615 | goto cleanup;
616 |
617 | /* Lookup the target object */
618 | err = git_object_lookup(&target, repo, target_oid, GIT_OBJECT_COMMIT);
619 | if (err != 0)
620 | goto cleanup;
621 |
622 | /* Checkout the result so the workdir is in the expected state */
623 | ff_checkout_options.checkout_strategy = GIT_CHECKOUT_SAFE;
624 | err = git_checkout_tree(repo, target, &ff_checkout_options);
625 | if (err != 0)
626 | goto cleanup;
627 |
628 | /* Move the target reference to the target OID */
629 | err = git_reference_set_target(&new_target_ref, target_ref, target_oid, NULL);
630 | if (err != 0)
631 | goto cleanup;
632 |
633 | cleanup:
634 | git_reference_free(target_ref);
635 | git_reference_free(new_target_ref);
636 | git_object_free(target);
637 |
638 | return err;
639 | }
640 |
641 | void gj_resolve_conflict(const char *git_base_path, git_index_entry *ancesstor_index,
642 | git_index_entry *our_index, git_index_entry *their_index)
643 | {
644 | gj_log_internal("gj_resolve_conflict %x %x %x\n", ancesstor_index, our_index, their_index);
645 |
646 | int err = 0;
647 | git_odb *odb = NULL;
648 | char *objects_path = NULL;
649 | git_odb_object *odb_object = NULL;
650 | char *file_full_path = NULL;
651 | FILE *file = NULL;
652 |
653 | char *objects_suffix = "/.git/objects";
654 | objects_path = malloc(strlen(git_base_path) + strlen(objects_suffix));
655 | objects_path[0] = 0;
656 |
657 | strcat(objects_path, git_base_path);
658 | strcat(objects_path, objects_suffix);
659 |
660 | err = git_odb_open(&odb, objects_path);
661 | if (err != 0)
662 | goto cleanup;
663 |
664 | err = git_odb_read(&odb_object, odb, &our_index->id);
665 | if (err != 0)
666 | goto cleanup;
667 |
668 | // We should check that it is a blob
669 | const char *file_data = (char *)git_odb_object_data(odb_object);
670 |
671 | const char *file_path = our_index->path;
672 | file_full_path = malloc(strlen(git_base_path) + 1 + strlen(file_path));
673 | file_full_path[0] = 0;
674 |
675 | strcat(file_full_path, git_base_path);
676 | strcat(file_full_path, "/");
677 | strcat(file_full_path, file_path);
678 |
679 | file = fopen(file_full_path, "w");
680 | fwrite((void *)file_data, strlen(file_data), 1, file);
681 |
682 | cleanup:
683 | if (file != NULL)
684 | fclose(file);
685 | free(file_full_path);
686 | git_odb_object_free(odb_object);
687 | free(objects_path);
688 | git_odb_free(odb);
689 | }
690 |
691 | int gj_git_fetch(const char *git_base_path, const char *remote_name, char *public_key, char *private_key, char *passcode, bool ssh_in_memory, char *status_file)
692 | {
693 | g_public_key = public_key;
694 | g_private_key = private_key;
695 | g_passcode = passcode;
696 |
697 | if (!ssh_in_memory)
698 | {
699 | write_keys_to_file((char *)git_base_path);
700 | }
701 |
702 | int err = 0;
703 | git_repository *repo = NULL;
704 | git_remote *remote = NULL;
705 |
706 | err = git_repository_open(&repo, git_base_path);
707 | if (err < 0)
708 | goto cleanup;
709 |
710 | git_repository_state_t state = git_repository_state(repo);
711 | if (state != GIT_REPOSITORY_STATE_NONE)
712 | {
713 | err = GJ_ERR_PULL_INVALID_STATE;
714 | goto cleanup;
715 | }
716 |
717 | err = git_remote_lookup(&remote, repo, remote_name);
718 | if (err < 0)
719 | goto cleanup;
720 |
721 | git_fetch_options options = GIT_FETCH_OPTIONS_INIT;
722 |
723 | if (status_file != 0 && strlen(status_file) == 0)
724 | {
725 | status_file = 0;
726 | }
727 |
728 | gj_credentials_payload gj_payload = {true, 0, ssh_in_memory, status_file};
729 | options.callbacks.payload = (void *)&gj_payload;
730 | options.callbacks.credentials = credentials_cb;
731 | options.callbacks.transfer_progress = fetch_progress;
732 |
733 | err = git_remote_fetch(remote, NULL, &options, NULL);
734 | if (err < 0)
735 | goto cleanup;
736 |
737 | cleanup:
738 | git_remote_free(remote);
739 | git_repository_free(repo);
740 |
741 | if (!ssh_in_memory)
742 | {
743 | delete_keys_from_file();
744 | }
745 |
746 | return err;
747 | }
748 |
749 | int gj_git_clone(const char *clone_url, const char *git_base_path, char *public_key, char *private_key, char *passcode, bool ssh_in_memory, char *status_file)
750 | {
751 | g_public_key = public_key;
752 | g_private_key = private_key;
753 | g_passcode = passcode;
754 |
755 | if (!ssh_in_memory)
756 | {
757 | write_keys_to_file((char *)git_base_path);
758 | }
759 |
760 | int err = 0;
761 | git_repository *repo = NULL;
762 | git_clone_options options = GIT_CLONE_OPTIONS_INIT;
763 | options.fetch_opts.callbacks.transfer_progress = fetch_progress;
764 | options.fetch_opts.callbacks.certificate_check = certificate_check_cb;
765 |
766 | if (status_file != 0 && strlen(status_file) == 0)
767 | {
768 | status_file = 0;
769 | }
770 |
771 | gj_credentials_payload gj_payload = {true, 0, ssh_in_memory, status_file};
772 | options.fetch_opts.callbacks.payload = (void *)&gj_payload;
773 | options.fetch_opts.callbacks.credentials = credentials_cb;
774 |
775 | err = git_clone(&repo, clone_url, git_base_path, &options);
776 | if (err < 0)
777 | goto cleanup;
778 |
779 | cleanup:
780 | git_repository_free(repo);
781 |
782 | if (!ssh_in_memory)
783 | {
784 | delete_keys_from_file();
785 | }
786 |
787 | if (gj_payload.error_code != 0)
788 | return gj_payload.error_code;
789 | return err;
790 | }
791 |
792 | int gj_git_merge(const char *git_base_path, const char *source_branch, const char *author_name, const char *author_email)
793 | {
794 | int err = 0;
795 | git_repository *repo = NULL;
796 | git_annotated_commit *origin_annotated_commit = NULL;
797 | git_reference *head_ref = NULL;
798 | git_reference *origin_head_ref = NULL;
799 | git_index *index = NULL;
800 | git_index_conflict_iterator *conflict_iter = NULL;
801 | git_signature *sig = NULL;
802 |
803 | git_commit *head_commit = NULL;
804 | git_commit *origin_head_commit = NULL;
805 | git_tree *tree = NULL;
806 | git_oid tree_id;
807 | char *name = NULL;
808 |
809 | err = git_repository_open(&repo, git_base_path);
810 | if (err < 0)
811 | goto cleanup;
812 |
813 | git_repository_state_t state = git_repository_state(repo);
814 | if (state != GIT_REPOSITORY_STATE_NONE)
815 | {
816 | err = GJ_ERR_PULL_INVALID_STATE;
817 | goto cleanup;
818 | }
819 |
820 | err = git_repository_head(&head_ref, repo);
821 | if (err < 0)
822 | goto cleanup;
823 |
824 | err = git_branch_lookup(&origin_head_ref, repo, source_branch, GIT_BRANCH_REMOTE);
825 | if (err < 0)
826 | goto cleanup;
827 |
828 | err = git_annotated_commit_from_ref(&origin_annotated_commit, repo, origin_head_ref);
829 | if (err < 0)
830 | goto cleanup;
831 |
832 | git_merge_analysis_t merge_analysis;
833 | git_merge_preference_t merge_preference;
834 |
835 | git_annotated_commit *annotated_commits[] = {origin_annotated_commit};
836 | err = git_merge_analysis(&merge_analysis, &merge_preference, repo,
837 | (const git_annotated_commit **)annotated_commits, 1);
838 | if (err < 0)
839 | goto cleanup;
840 |
841 | if (merge_analysis & GIT_MERGE_ANALYSIS_UP_TO_DATE)
842 | {
843 | goto cleanup;
844 | }
845 | else if (merge_analysis & GIT_MERGE_ANALYSIS_UNBORN)
846 | {
847 | err = 5000;
848 | gj_log("GitPull merge_analysis unborn\n");
849 | goto cleanup;
850 | }
851 | else if (merge_analysis & GIT_MERGE_ANALYSIS_FASTFORWARD)
852 | {
853 | gj_log("GitPull: Performing FastForward\n");
854 |
855 | err = perform_fastforward(repo, git_annotated_commit_id(origin_annotated_commit));
856 | if (err < 0)
857 | goto cleanup;
858 | }
859 | else if (merge_analysis & GIT_MERGE_ANALYSIS_NORMAL)
860 | {
861 | gj_log("GitPull: Performing Normal Merge\n");
862 |
863 | git_merge_options merge_options = GIT_MERGE_OPTIONS_INIT;
864 | git_checkout_options checkout_options = GIT_CHECKOUT_OPTIONS_INIT;
865 |
866 | err = git_merge(repo, (const git_annotated_commit **)annotated_commits, 1,
867 | &merge_options, &checkout_options);
868 | if (err < 0)
869 | goto cleanup;
870 |
871 | err = git_repository_index(&index, repo);
872 | if (err < 0)
873 | goto cleanup;
874 |
875 | err = git_index_conflict_iterator_new(&conflict_iter, index);
876 | if (err < 0)
877 | goto cleanup;
878 |
879 | // Handle Conflicts
880 | while (1)
881 | {
882 | git_index_entry *ancestor_out;
883 | git_index_entry *our_out;
884 | git_index_entry *their_out;
885 | err = git_index_conflict_next((const git_index_entry **)&ancestor_out,
886 | (const git_index_entry **)&our_out,
887 | (const git_index_entry **)&their_out,
888 | conflict_iter);
889 |
890 | if (err == GIT_ITEROVER)
891 | {
892 | gj_log_internal(" Done with Conflicts\n");
893 | break;
894 | }
895 | if (err < 0)
896 | goto cleanup;
897 |
898 | gj_log_internal("GitPull: Conflict on file %s\n", their_out->path);
899 |
900 | // 1. We resolve the conflict by choosing their changes
901 | gj_resolve_conflict(git_base_path, ancestor_out, our_out, their_out);
902 | gj_log_internal("Resolved conflict on file %s\n", their_out->path);
903 |
904 | // 2. We remove it from the list of conflicts
905 | err = git_index_conflict_remove(index, our_out->path);
906 | if (err < 0)
907 | goto cleanup;
908 |
909 | // 3. We add it to the index
910 | git_strarray paths = {(char **)&our_out->path, 1};
911 | err = git_index_add_all(index, &paths, 0, NULL, NULL);
912 | if (err < 0)
913 | goto cleanup;
914 |
915 | err = git_index_write(index);
916 | if (err < 0)
917 | goto cleanup;
918 | }
919 |
920 | err = git_index_write_tree(&tree_id, index);
921 | if (err < 0)
922 | goto cleanup;
923 |
924 | err = git_tree_lookup(&tree, repo, &tree_id);
925 | if (err < 0)
926 | goto cleanup;
927 |
928 | //
929 | // Make the commit
930 | //
931 | err = git_signature_now(&sig, author_name, author_email);
932 | if (err < 0)
933 | goto cleanup;
934 |
935 | // Get the parents
936 | git_oid head_id;
937 | err = git_reference_name_to_id(&head_id, repo, "HEAD");
938 | if (err < 0)
939 | goto cleanup;
940 |
941 | err = git_commit_lookup(&head_commit, repo, &head_id);
942 | if (err < 0)
943 | goto cleanup;
944 |
945 | err = git_commit_lookup(&origin_head_commit, repo,
946 | git_annotated_commit_id(origin_annotated_commit));
947 | if (err < 0)
948 | goto cleanup;
949 |
950 | const git_commit *parents[] = {head_commit, origin_head_commit};
951 | char *message = "Custom Merge commit";
952 | git_oid commit_id;
953 |
954 | err = git_commit_create(&commit_id, repo, "HEAD", sig, sig, NULL, message, tree, 2, parents);
955 | if (err < 0)
956 | goto cleanup;
957 | }
958 |
959 | cleanup:
960 | git_tree_free(tree);
961 | git_commit_free(head_commit);
962 | git_commit_free(origin_head_commit);
963 | git_signature_free(sig);
964 | if (repo != 0)
965 | git_repository_state_cleanup(repo);
966 | git_index_conflict_iterator_free(conflict_iter);
967 | git_index_free(index);
968 | git_reference_free(head_ref);
969 | git_reference_free(origin_head_ref);
970 | git_annotated_commit_free(origin_annotated_commit);
971 | git_repository_free(repo);
972 | free(name);
973 |
974 | return err;
975 | }
976 |
977 | int gj_init()
978 | {
979 | return git_libgit2_init();
980 | }
981 |
982 | int gj_shutdown()
983 | {
984 | return git_libgit2_shutdown();
985 | }
986 |
--------------------------------------------------------------------------------
/gj_common/gitjournal.h:
--------------------------------------------------------------------------------
1 | #ifndef _GITJOURNAL_H_
2 | #define _GITJOURNAL_H_
3 |
4 | #include
5 |
6 | int gj_init();
7 | int gj_shutdown();
8 |
9 | int gj_git_merge(const char *git_base_path, const char *source_branch,
10 | const char *author_name, const char *author_email);
11 |
12 | int gj_git_fetch(const char *git_base_path, const char *remote_name, char *public_key, char *private_key, char *passcode, bool ssh_in_memory, char *status_file);
13 | int gj_git_push(const char *git_base_path, const char *remote_name, char *public_key, char *private_key, char *passcode, bool ssh_in_memory, char *status_file);
14 | int gj_git_default_branch(const char *git_base_path, const char *remote_name, char *public_key, char *private_key, char *passcode, bool ssh_in_memory, char *default_branch);
15 | int gj_git_clone(const char *clone_url, const char *git_base_path, char *public_key, char *private_key, char *passcode, bool ssh_in_memory, char *status_file);
16 |
17 | // commit_time_offset is in minutes
18 | int gj_git_commit(const char *git_base_path, const char *author_name,
19 | const char *author_email, const char *message, long long commit_time, int commit_time_offset);
20 | int gj_git_reset_hard(const char *git_base_path, const char *ref);
21 | int gj_git_add(const char *git_base_path, const char *pattern);
22 | int gj_git_rm(const char *git_base_path, const char *pattern);
23 |
24 | typedef struct
25 | {
26 | char *message;
27 | bool message_allocated;
28 | int code;
29 | } gj_error;
30 |
31 | gj_error *gj_error_info(int err);
32 | void gj_error_free(const gj_error *err);
33 |
34 | // This must be implemented by you
35 | void gj_log(const char *message);
36 |
37 | void gj_log_internal(const char *format, ...);
38 |
39 | int gj_generate_ssh_keys(const char *private_key_path,
40 | const char *public_key_path, const char *comment);
41 |
42 | #define GJ_ERR_FIRST -954
43 | #define GJ_ERR_EMPTY_COMMIT -954
44 | #define GJ_ERR_PULL_INVALID_STATE -955
45 | #define GJ_ERR_OPENSSL -956
46 | #define GJ_ERR_INVALID_CREDENTIALS -957
47 | #define GJ_ERR_MISSING_PUBLIC_KEY -958
48 | #define GJ_ERR_MISSING_PRIVATE_KEY -959
49 | #define GJ_ERR_LAST -959
50 |
51 | #endif
52 |
--------------------------------------------------------------------------------
/gj_common/keygen.c:
--------------------------------------------------------------------------------
1 | #include "gitjournal.h"
2 |
3 | #include
4 | #include
5 | #include
6 |
7 | #include
8 |
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 |
15 | static unsigned char pSshHeader[11] = {0x00, 0x00, 0x00, 0x07, 0x73, 0x73, 0x68, 0x2D, 0x72, 0x73, 0x61};
16 |
17 | static int SshEncodeBuffer(unsigned char *pEncoding, int bufferLen, unsigned char *pBuffer)
18 | {
19 | int adjustedLen = bufferLen, index;
20 | if (*pBuffer & 0x80)
21 | {
22 | adjustedLen++;
23 | pEncoding[4] = 0;
24 | index = 5;
25 | }
26 | else
27 | {
28 | index = 4;
29 | }
30 | pEncoding[0] = (unsigned char)(adjustedLen >> 24);
31 | pEncoding[1] = (unsigned char)(adjustedLen >> 16);
32 | pEncoding[2] = (unsigned char)(adjustedLen >> 8);
33 | pEncoding[3] = (unsigned char)(adjustedLen);
34 | memcpy(&pEncoding[index], pBuffer, bufferLen);
35 | return index + bufferLen;
36 | }
37 |
38 | int write_rsa_public_key(RSA *pRsa, const char *file_path, const char *comment)
39 | {
40 | int ret = 0;
41 | int encodingLength = 0;
42 | int index = 0;
43 | unsigned char *nBytes = NULL, *eBytes = NULL;
44 | unsigned char *pEncoding = NULL;
45 | FILE *pFile = NULL;
46 | BIO *bio, *b64;
47 |
48 | ERR_load_crypto_strings();
49 | OpenSSL_add_all_algorithms();
50 |
51 | const BIGNUM *pRsa_mod = NULL;
52 | const BIGNUM *pRsa_exp = NULL;
53 |
54 | RSA_get0_key(pRsa, &pRsa_mod, &pRsa_exp, NULL);
55 |
56 | // reading the modulus
57 | int nLen = BN_num_bytes(pRsa_mod);
58 | nBytes = (unsigned char *)malloc(nLen);
59 | ret = BN_bn2bin(pRsa_mod, nBytes);
60 | if (ret <= 0)
61 | goto cleanup;
62 |
63 | // reading the public exponent
64 | int eLen = BN_num_bytes(pRsa_exp);
65 | eBytes = (unsigned char *)malloc(eLen);
66 | if (eBytes == NULL)
67 | {
68 | gj_log_internal("write_rsa_public_key malloc failed. Length: %d", eLen);
69 | ret = -1;
70 | goto cleanup;
71 | }
72 | ret = BN_bn2bin(pRsa_exp, eBytes);
73 | if (ret <= 0)
74 | goto cleanup;
75 |
76 | encodingLength = 11 + 4 + eLen + 4 + nLen;
77 | // correct depending on the MSB of e and N
78 | if (eBytes[0] & 0x80)
79 | encodingLength++;
80 | if (nBytes[0] & 0x80)
81 | encodingLength++;
82 |
83 | pEncoding = (unsigned char *)malloc(encodingLength);
84 | memset(pEncoding, 0, encodingLength);
85 | memcpy(pEncoding, pSshHeader, 11);
86 |
87 | index = SshEncodeBuffer(&pEncoding[11], eLen, eBytes);
88 | SshEncodeBuffer(&pEncoding[11 + index], nLen, nBytes);
89 |
90 | b64 = BIO_new(BIO_f_base64());
91 | BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
92 |
93 | pFile = fopen(file_path, "w");
94 | bio = BIO_new_fp(pFile, BIO_CLOSE);
95 | BIO_printf(bio, "ssh-rsa ");
96 | bio = BIO_push(b64, bio);
97 | BIO_write(bio, pEncoding, encodingLength);
98 | BIO_flush(bio);
99 | bio = BIO_pop(b64);
100 | BIO_printf(bio, " %s\n", comment);
101 | BIO_flush(bio);
102 | BIO_free_all(bio);
103 | BIO_free(b64);
104 |
105 | cleanup:
106 | if (pFile)
107 | fclose(pFile);
108 |
109 | free(nBytes);
110 | free(eBytes);
111 | free(pEncoding);
112 |
113 | EVP_cleanup();
114 | ERR_free_strings();
115 |
116 | return ret > 0 ? 1 : ret;
117 | }
118 |
119 | int gj_generate_ssh_keys(const char *private_key_path,
120 | const char *public_key_path, const char *comment)
121 | {
122 | int ret = 0;
123 | RSA *rsa = NULL;
124 |
125 | BIGNUM *bne = NULL;
126 | BIO *bp_private = NULL;
127 |
128 | int bits = 1024 * 4;
129 | unsigned long e = RSA_F4;
130 |
131 | // Generate rsa key
132 | bne = BN_new();
133 | ret = BN_set_word(bne, e);
134 | if (ret != 1)
135 | goto cleanup;
136 |
137 | rsa = RSA_new();
138 | ret = RSA_generate_key_ex(rsa, bits, bne, NULL);
139 | if (ret != 1)
140 | {
141 | gj_log_internal("Failed to generate RSA key of %d bits\n", bits);
142 | goto cleanup;
143 | }
144 |
145 | // Save private key
146 | bp_private = BIO_new_file(private_key_path, "w+");
147 | ret = PEM_write_bio_RSAPrivateKey(bp_private, rsa, NULL, NULL, 0, NULL, NULL);
148 | if (ret != 1)
149 | {
150 | gj_log_internal("Failed to write private key to %s\n", private_key_path);
151 | goto cleanup;
152 | }
153 | chmod(private_key_path, 0600);
154 |
155 | // Save public key
156 | ret = write_rsa_public_key(rsa, public_key_path, comment);
157 | if (ret != 1)
158 | {
159 | gj_log_internal("Failed to write public key to %s\n", public_key_path);
160 | goto cleanup;
161 | }
162 |
163 | cleanup:
164 | BIO_free_all(bp_private);
165 | RSA_free(rsa);
166 | BN_free(bne);
167 |
168 | if (ret != 1)
169 | return GJ_ERR_OPENSSL;
170 | return 0;
171 | }
172 |
--------------------------------------------------------------------------------
/gj_common/test.c:
--------------------------------------------------------------------------------
1 | #include "gitjournal.h"
2 |
3 | #include
4 |
5 | int handle_error(int err)
6 | {
7 | if (err != 0)
8 | {
9 | const gj_error *e = gj_error_info(err);
10 | if (e)
11 | {
12 | printf("Error %d/%d: %s\n", err, e->code, e->message);
13 | gj_error_free(e);
14 | }
15 | }
16 | return err;
17 | }
18 |
19 | void gj_log(const char *message)
20 | {
21 | printf("%s", message);
22 | }
23 |
24 | int main(int argc, char *argv[])
25 | {
26 | gj_init();
27 |
28 | char *publickey = "./.ssh/id_rsa.pub";
29 | char *privatekey = "./.ssh/id_rsa";
30 | char *passphrase = "";
31 |
32 | //gj_set_ssh_keys_paths(publickey, privatekey, passphrase);
33 |
34 | int err;
35 | char *git_base_path = "/tmp/test";
36 | //char *clone_url = "https://github.com/GitJournal/journal_test.git";
37 | //char *clone_url = "git@github.com:GitJournal/journal_test.git";
38 | char *clone_url = "git@github.com:vhanda/test_gj.git";
39 | //char *clone_url = "root@pi.local:git/test";
40 | char *add_pattern = ".";
41 | char *author_name = "TestMan";
42 | char *author_email = "TestMan@example.com";
43 | char *message = "Commit message for GitJournal";
44 |
45 | //err = gj_generate_ssh_keys("/tmp/t/id_rsa", "/tmp/t/id_rsa.pub", "Cookie");
46 | //err = gj_git_commit(git_base_path, author_name, author_email, message);
47 | err = gj_git_push(git_base_path, "origin");
48 | //err = gj_git_fetch(git_base_path, "origin");
49 | //err = gj_git_merge(git_base_path, "origin/master", author_name, author_email);
50 | //err = gj_git_add(git_base_path, "9.md");
51 | //err = gj_git_rm(git_base_path, "9.md");
52 | //err = gj_git_reset_hard(git_base_path, "HEAD^");
53 |
54 | if (err < 0)
55 | handle_error(err);
56 | printf("We seem to be done\n");
57 |
58 | gj_shutdown();
59 |
60 | /*
61 | int features = git_libgit2_features();
62 | bool supports_threading = features & GIT_FEATURE_THREADS;
63 | bool supports_https2 = features & GIT_FEATURE_HTTPS;
64 | bool supports_ssh = features & GIT_FEATURE_SSH;
65 | printf("Threading: %d\n", supports_threading);
66 | printf("Https: %d\n", supports_https2);
67 | printf("SSH: %d\n", supports_ssh);
68 | */
69 | return 0;
70 | }
71 |
--------------------------------------------------------------------------------
/ios/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
2 | .vagrant/
3 | .sconsign.dblite
4 | .svn/
5 |
6 | .DS_Store
7 | *.swp
8 | profile
9 |
10 | DerivedData/
11 | build/
12 | GeneratedPluginRegistrant.h
13 | GeneratedPluginRegistrant.m
14 |
15 | .generated/
16 |
17 | *.pbxuser
18 | *.mode1v3
19 | *.mode2v3
20 | *.perspectivev3
21 |
22 | !default.pbxuser
23 | !default.mode1v3
24 | !default.mode2v3
25 | !default.perspectivev3
26 |
27 | xcuserdata
28 |
29 | *.moved-aside
30 |
31 | *.pyc
32 | *sync/
33 | Icon?
34 | .tags*
35 |
36 | /Flutter/Generated.xcconfig
37 | /Flutter/flutter_export_environment.sh
--------------------------------------------------------------------------------
/ios/Assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GitJournal/git_bindings/ba1db24a7f9c29f4e5c9c4116c24687605f6d903/ios/Assets/.gitkeep
--------------------------------------------------------------------------------
/ios/Classes/GitBindingsPlugin.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | @interface GitBindingsPlugin : NSObject
4 | @end
5 |
--------------------------------------------------------------------------------
/ios/Classes/GitBindingsPlugin.m:
--------------------------------------------------------------------------------
1 | #import "GitBindingsPlugin.h"
2 |
3 | @implementation GitBindingsPlugin
4 | + (void)registerWithRegistrar:(NSObject *)registrar {
5 | FlutterMethodChannel *channel =
6 | [FlutterMethodChannel methodChannelWithName:@"io.gitjournal.git_bindings"
7 | binaryMessenger:[registrar messenger]];
8 | GitBindingsPlugin *instance = [[GitBindingsPlugin alloc] init];
9 | [registrar addMethodCallDelegate:instance channel:channel];
10 | }
11 |
12 | - (void)handleMethodCall:(FlutterMethodCall *)call
13 | result:(FlutterResult)result {
14 | if ([@"getPlatformVersion" isEqualToString:call.method]) {
15 | result([@"iOS "
16 | stringByAppendingString:[[UIDevice currentDevice] systemVersion]]);
17 | } else {
18 | result(FlutterMethodNotImplemented);
19 | }
20 | }
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/ios/git_bindings.podspec:
--------------------------------------------------------------------------------
1 | #
2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
3 | # Run `pod lib lint git_bindings.podspec' to validate before publishing.
4 | #
5 | Pod::Spec.new do |s|
6 | s.name = 'git_bindings'
7 | s.version = '0.0.1'
8 | s.summary = 'A new flutter plugin project.'
9 | s.description = <<-DESC
10 | A new flutter plugin project.
11 | DESC
12 | s.homepage = 'https://gitjournal.io'
13 | s.license = { :file => '../LICENSE' }
14 | s.author = { 'Vishesh Handa' => 'vhanda@gitjournal.io' }
15 | s.source = { :path => '.' }
16 | s.source_files = 'Classes/**/*', '../gj_common/gitjournal.c', '../gj_common/common.c', '../gj_common/keygen.c'
17 | s.public_header_files = 'Classes/**/*.h', '../gj_common/gitjournal.h'
18 | s.dependency 'Flutter'
19 | s.platform = :ios, '8.0'
20 |
21 | # Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported.
22 | s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' }
23 |
24 | s.vendored_frameworks = 'Frameworks/libssl.framework', 'Frameworks/libcrypto.framework', 'Frameworks/libssh2.framework', 'Frameworks/libgit2.framework'
25 | end
26 |
--------------------------------------------------------------------------------
/lib/git_bindings.dart:
--------------------------------------------------------------------------------
1 | import 'dart:async';
2 | import 'dart:io';
3 |
4 | import 'package:flutter/services.dart';
5 |
6 | // Hack because I don't understand how to link libraries in ios
7 | var channelName =
8 | Platform.isIOS ? "gitjournal.io/git" : 'io.gitjournal.git_bindings';
9 | var _platform = MethodChannel(channelName);
10 |
11 | Future invokePlatformMethod(String method, [dynamic arguments]) async {
12 | return _platform.invokeMethod(method, arguments);
13 | }
14 |
15 | class GitRepo {
16 | final String folderPath;
17 |
18 | const GitRepo({
19 | required this.folderPath,
20 | });
21 |
22 | Future fetch({
23 | required String remote,
24 | required String publicKey,
25 | required String privateKey,
26 | required String password,
27 | required String statusFile,
28 | }) async {
29 | try {
30 | await invokePlatformMethod('gitFetch', {
31 | 'folderPath': folderPath,
32 | 'remote': remote,
33 | 'publicKey': publicKey,
34 | 'privateKey': privateKey,
35 | 'password': password,
36 | 'statusFile': statusFile,
37 | });
38 | } on PlatformException catch (e) {
39 | throw createGitException(e.message!);
40 | }
41 | }
42 |
43 | Future merge({
44 | required String branch,
45 | required String authorName,
46 | required String authorEmail,
47 | }) async {
48 | try {
49 | await invokePlatformMethod('gitMerge', {
50 | 'folderPath': folderPath,
51 | 'branch': branch,
52 | 'authorName': authorName,
53 | 'authorEmail': authorEmail,
54 | });
55 | } on PlatformException catch (e) {
56 | throw createGitException(e.message!);
57 | }
58 | }
59 |
60 | Future add(String filePattern) async {
61 | try {
62 | await invokePlatformMethod('gitAdd', {
63 | 'folderPath': folderPath,
64 | 'filePattern': filePattern,
65 | });
66 | } on PlatformException catch (e) {
67 | throw createGitException(e.message!);
68 | }
69 | }
70 |
71 | Future rm(String filePattern) async {
72 | try {
73 | await invokePlatformMethod('gitRm', {
74 | 'folderPath': folderPath,
75 | 'filePattern': filePattern,
76 | });
77 | } on PlatformException catch (e) {
78 | throw createGitException(e.message!);
79 | }
80 | }
81 |
82 | Future push({
83 | required String remote,
84 | required String publicKey,
85 | required String privateKey,
86 | required String password,
87 | required String statusFile,
88 | }) async {
89 | try {
90 | await invokePlatformMethod('gitPush', {
91 | 'folderPath': folderPath,
92 | 'remote': remote,
93 | 'publicKey': publicKey,
94 | 'privateKey': privateKey,
95 | 'password': password,
96 | 'statusFile': statusFile,
97 | });
98 | } on PlatformException catch (e) {
99 | throw createGitException(e.message!);
100 | }
101 | }
102 |
103 | static Future clone({
104 | required String folderPath,
105 | required String cloneUrl,
106 | required String publicKey,
107 | required String privateKey,
108 | required String password,
109 | required String statusFile,
110 | }) async {
111 | try {
112 | await invokePlatformMethod('gitClone', {
113 | 'cloneUrl': cloneUrl,
114 | 'folderPath': folderPath,
115 | 'publicKey': publicKey,
116 | 'privateKey': privateKey,
117 | 'password': password,
118 | 'statusFile': statusFile,
119 | });
120 | } on PlatformException catch (e) {
121 | throw createGitException(e.message!);
122 | }
123 | }
124 |
125 | Future defaultBranch({
126 | required String remote,
127 | required String publicKey,
128 | required String privateKey,
129 | required String password,
130 | }) async {
131 | try {
132 | var ret = await invokePlatformMethod('gitDefaultBranch', {
133 | 'folderPath': folderPath,
134 | 'remote': remote,
135 | 'publicKey': publicKey,
136 | 'privateKey': privateKey,
137 | 'password': password,
138 | });
139 | String? br = ret;
140 | if (br != null && br.startsWith('refs/heads/')) {
141 | br = br.substring(11);
142 | }
143 | return br;
144 | } on PlatformException catch (e) {
145 | throw createGitException(e.message!);
146 | }
147 | }
148 |
149 | // FIXME: Change this method to just resetHard
150 | Future resetLast() async {
151 | try {
152 | await invokePlatformMethod('gitResetLast', {
153 | 'folderPath': folderPath,
154 | });
155 | } on PlatformException catch (e) {
156 | throw createGitException(e.message!);
157 | }
158 | }
159 |
160 | // FIXME: Change the datetime
161 | // FIXME: Actually implement the 'when'
162 | Future commit({
163 | required String message,
164 | required String authorName,
165 | required String authorEmail,
166 | String? when,
167 | }) async {
168 | try {
169 | await invokePlatformMethod('gitCommit', {
170 | 'folderPath': folderPath,
171 | 'authorName': authorName,
172 | 'authorEmail': authorEmail,
173 | 'message': message,
174 | 'when': when,
175 | });
176 | } on PlatformException catch (e) {
177 | throw createGitException(e.message!);
178 | }
179 | }
180 | }
181 |
182 | class GitException implements Exception {
183 | final String cause;
184 | GitException(this.cause);
185 |
186 | @override
187 | String toString() {
188 | return "GitException: " + cause;
189 | }
190 | }
191 |
192 | GitException createGitException(String msg) {
193 | if (msg.contains("ENETUNREACH")) {
194 | return GitException("No Connection");
195 | }
196 | if (msg.contains("Remote origin did not advertise Ref for branch master")) {
197 | return GitException("No master branch");
198 | }
199 | if (msg.contains("Nothing to push")) {
200 | return GitException("Nothing to push.");
201 | }
202 | return GitException(msg);
203 | }
204 |
205 | Future generateSSHKeys({
206 | required String privateKeyPath,
207 | required String publicKeyPath,
208 | required String comment,
209 | }) async {
210 | await invokePlatformMethod('generateSSHKeys', {
211 | 'privateKeyPath': privateKeyPath,
212 | 'publicKeyPath': publicKeyPath,
213 | 'comment': comment,
214 | });
215 | }
216 |
--------------------------------------------------------------------------------
/pubspec.lock:
--------------------------------------------------------------------------------
1 | # Generated by pub
2 | # See https://dart.dev/tools/pub/glossary#lockfile
3 | packages:
4 | _fe_analyzer_shared:
5 | dependency: transitive
6 | description:
7 | name: _fe_analyzer_shared
8 | url: "https://pub.dartlang.org"
9 | source: hosted
10 | version: "31.0.0"
11 | analyzer:
12 | dependency: transitive
13 | description:
14 | name: analyzer
15 | url: "https://pub.dartlang.org"
16 | source: hosted
17 | version: "2.8.0"
18 | archive:
19 | dependency: transitive
20 | description:
21 | name: archive
22 | url: "https://pub.dartlang.org"
23 | source: hosted
24 | version: "3.1.6"
25 | args:
26 | dependency: transitive
27 | description:
28 | name: args
29 | url: "https://pub.dartlang.org"
30 | source: hosted
31 | version: "2.3.1"
32 | async:
33 | dependency: transitive
34 | description:
35 | name: async
36 | url: "https://pub.dartlang.org"
37 | source: hosted
38 | version: "2.8.2"
39 | boolean_selector:
40 | dependency: transitive
41 | description:
42 | name: boolean_selector
43 | url: "https://pub.dartlang.org"
44 | source: hosted
45 | version: "2.1.0"
46 | characters:
47 | dependency: transitive
48 | description:
49 | name: characters
50 | url: "https://pub.dartlang.org"
51 | source: hosted
52 | version: "1.2.0"
53 | charcode:
54 | dependency: transitive
55 | description:
56 | name: charcode
57 | url: "https://pub.dartlang.org"
58 | source: hosted
59 | version: "1.3.1"
60 | cli_util:
61 | dependency: transitive
62 | description:
63 | name: cli_util
64 | url: "https://pub.dartlang.org"
65 | source: hosted
66 | version: "0.3.5"
67 | clock:
68 | dependency: transitive
69 | description:
70 | name: clock
71 | url: "https://pub.dartlang.org"
72 | source: hosted
73 | version: "1.1.0"
74 | collection:
75 | dependency: transitive
76 | description:
77 | name: collection
78 | url: "https://pub.dartlang.org"
79 | source: hosted
80 | version: "1.15.0"
81 | convert:
82 | dependency: transitive
83 | description:
84 | name: convert
85 | url: "https://pub.dartlang.org"
86 | source: hosted
87 | version: "3.0.1"
88 | coverage:
89 | dependency: transitive
90 | description:
91 | name: coverage
92 | url: "https://pub.dartlang.org"
93 | source: hosted
94 | version: "1.0.3"
95 | crypto:
96 | dependency: transitive
97 | description:
98 | name: crypto
99 | url: "https://pub.dartlang.org"
100 | source: hosted
101 | version: "3.0.1"
102 | fake_async:
103 | dependency: transitive
104 | description:
105 | name: fake_async
106 | url: "https://pub.dartlang.org"
107 | source: hosted
108 | version: "1.2.0"
109 | file:
110 | dependency: transitive
111 | description:
112 | name: file
113 | url: "https://pub.dartlang.org"
114 | source: hosted
115 | version: "6.1.2"
116 | flutter:
117 | dependency: "direct main"
118 | description: flutter
119 | source: sdk
120 | version: "0.0.0"
121 | flutter_driver:
122 | dependency: "direct dev"
123 | description: flutter
124 | source: sdk
125 | version: "0.0.0"
126 | flutter_test:
127 | dependency: "direct dev"
128 | description: flutter
129 | source: sdk
130 | version: "0.0.0"
131 | frontend_server_client:
132 | dependency: transitive
133 | description:
134 | name: frontend_server_client
135 | url: "https://pub.dartlang.org"
136 | source: hosted
137 | version: "2.1.2"
138 | fuchsia_remote_debug_protocol:
139 | dependency: transitive
140 | description: flutter
141 | source: sdk
142 | version: "0.0.0"
143 | glob:
144 | dependency: transitive
145 | description:
146 | name: glob
147 | url: "https://pub.dartlang.org"
148 | source: hosted
149 | version: "2.0.2"
150 | http_multi_server:
151 | dependency: transitive
152 | description:
153 | name: http_multi_server
154 | url: "https://pub.dartlang.org"
155 | source: hosted
156 | version: "3.2.0"
157 | http_parser:
158 | dependency: transitive
159 | description:
160 | name: http_parser
161 | url: "https://pub.dartlang.org"
162 | source: hosted
163 | version: "4.0.0"
164 | io:
165 | dependency: transitive
166 | description:
167 | name: io
168 | url: "https://pub.dartlang.org"
169 | source: hosted
170 | version: "1.0.3"
171 | js:
172 | dependency: transitive
173 | description:
174 | name: js
175 | url: "https://pub.dartlang.org"
176 | source: hosted
177 | version: "0.6.3"
178 | logging:
179 | dependency: transitive
180 | description:
181 | name: logging
182 | url: "https://pub.dartlang.org"
183 | source: hosted
184 | version: "1.0.2"
185 | matcher:
186 | dependency: transitive
187 | description:
188 | name: matcher
189 | url: "https://pub.dartlang.org"
190 | source: hosted
191 | version: "0.12.11"
192 | material_color_utilities:
193 | dependency: transitive
194 | description:
195 | name: material_color_utilities
196 | url: "https://pub.dartlang.org"
197 | source: hosted
198 | version: "0.1.3"
199 | meta:
200 | dependency: transitive
201 | description:
202 | name: meta
203 | url: "https://pub.dartlang.org"
204 | source: hosted
205 | version: "1.7.0"
206 | mime:
207 | dependency: transitive
208 | description:
209 | name: mime
210 | url: "https://pub.dartlang.org"
211 | source: hosted
212 | version: "1.0.2"
213 | node_preamble:
214 | dependency: transitive
215 | description:
216 | name: node_preamble
217 | url: "https://pub.dartlang.org"
218 | source: hosted
219 | version: "2.0.1"
220 | package_config:
221 | dependency: transitive
222 | description:
223 | name: package_config
224 | url: "https://pub.dartlang.org"
225 | source: hosted
226 | version: "2.0.2"
227 | path:
228 | dependency: transitive
229 | description:
230 | name: path
231 | url: "https://pub.dartlang.org"
232 | source: hosted
233 | version: "1.8.0"
234 | platform:
235 | dependency: transitive
236 | description:
237 | name: platform
238 | url: "https://pub.dartlang.org"
239 | source: hosted
240 | version: "3.1.0"
241 | pool:
242 | dependency: transitive
243 | description:
244 | name: pool
245 | url: "https://pub.dartlang.org"
246 | source: hosted
247 | version: "1.5.0"
248 | process:
249 | dependency: transitive
250 | description:
251 | name: process
252 | url: "https://pub.dartlang.org"
253 | source: hosted
254 | version: "4.2.4"
255 | pub_semver:
256 | dependency: transitive
257 | description:
258 | name: pub_semver
259 | url: "https://pub.dartlang.org"
260 | source: hosted
261 | version: "2.1.1"
262 | shelf:
263 | dependency: transitive
264 | description:
265 | name: shelf
266 | url: "https://pub.dartlang.org"
267 | source: hosted
268 | version: "1.3.0"
269 | shelf_packages_handler:
270 | dependency: transitive
271 | description:
272 | name: shelf_packages_handler
273 | url: "https://pub.dartlang.org"
274 | source: hosted
275 | version: "3.0.0"
276 | shelf_static:
277 | dependency: transitive
278 | description:
279 | name: shelf_static
280 | url: "https://pub.dartlang.org"
281 | source: hosted
282 | version: "1.1.0"
283 | shelf_web_socket:
284 | dependency: transitive
285 | description:
286 | name: shelf_web_socket
287 | url: "https://pub.dartlang.org"
288 | source: hosted
289 | version: "1.0.1"
290 | sky_engine:
291 | dependency: transitive
292 | description: flutter
293 | source: sdk
294 | version: "0.0.99"
295 | source_map_stack_trace:
296 | dependency: transitive
297 | description:
298 | name: source_map_stack_trace
299 | url: "https://pub.dartlang.org"
300 | source: hosted
301 | version: "2.1.0"
302 | source_maps:
303 | dependency: transitive
304 | description:
305 | name: source_maps
306 | url: "https://pub.dartlang.org"
307 | source: hosted
308 | version: "0.10.10"
309 | source_span:
310 | dependency: transitive
311 | description:
312 | name: source_span
313 | url: "https://pub.dartlang.org"
314 | source: hosted
315 | version: "1.8.1"
316 | stack_trace:
317 | dependency: transitive
318 | description:
319 | name: stack_trace
320 | url: "https://pub.dartlang.org"
321 | source: hosted
322 | version: "1.10.0"
323 | stream_channel:
324 | dependency: transitive
325 | description:
326 | name: stream_channel
327 | url: "https://pub.dartlang.org"
328 | source: hosted
329 | version: "2.1.0"
330 | string_scanner:
331 | dependency: transitive
332 | description:
333 | name: string_scanner
334 | url: "https://pub.dartlang.org"
335 | source: hosted
336 | version: "1.1.0"
337 | sync_http:
338 | dependency: transitive
339 | description:
340 | name: sync_http
341 | url: "https://pub.dartlang.org"
342 | source: hosted
343 | version: "0.3.0"
344 | term_glyph:
345 | dependency: transitive
346 | description:
347 | name: term_glyph
348 | url: "https://pub.dartlang.org"
349 | source: hosted
350 | version: "1.2.0"
351 | test:
352 | dependency: "direct dev"
353 | description:
354 | name: test
355 | url: "https://pub.dartlang.org"
356 | source: hosted
357 | version: "1.19.5"
358 | test_api:
359 | dependency: transitive
360 | description:
361 | name: test_api
362 | url: "https://pub.dartlang.org"
363 | source: hosted
364 | version: "0.4.8"
365 | test_core:
366 | dependency: transitive
367 | description:
368 | name: test_core
369 | url: "https://pub.dartlang.org"
370 | source: hosted
371 | version: "0.4.9"
372 | typed_data:
373 | dependency: transitive
374 | description:
375 | name: typed_data
376 | url: "https://pub.dartlang.org"
377 | source: hosted
378 | version: "1.3.0"
379 | vector_math:
380 | dependency: transitive
381 | description:
382 | name: vector_math
383 | url: "https://pub.dartlang.org"
384 | source: hosted
385 | version: "2.1.1"
386 | vm_service:
387 | dependency: transitive
388 | description:
389 | name: vm_service
390 | url: "https://pub.dartlang.org"
391 | source: hosted
392 | version: "7.5.0"
393 | watcher:
394 | dependency: transitive
395 | description:
396 | name: watcher
397 | url: "https://pub.dartlang.org"
398 | source: hosted
399 | version: "1.0.1"
400 | web_socket_channel:
401 | dependency: transitive
402 | description:
403 | name: web_socket_channel
404 | url: "https://pub.dartlang.org"
405 | source: hosted
406 | version: "2.2.0"
407 | webdriver:
408 | dependency: transitive
409 | description:
410 | name: webdriver
411 | url: "https://pub.dartlang.org"
412 | source: hosted
413 | version: "3.0.0"
414 | webkit_inspection_protocol:
415 | dependency: transitive
416 | description:
417 | name: webkit_inspection_protocol
418 | url: "https://pub.dartlang.org"
419 | source: hosted
420 | version: "1.0.1"
421 | yaml:
422 | dependency: transitive
423 | description:
424 | name: yaml
425 | url: "https://pub.dartlang.org"
426 | source: hosted
427 | version: "3.1.0"
428 | sdks:
429 | dart: ">=2.16.0 <3.0.0"
430 | flutter: ">=1.10.7"
431 |
--------------------------------------------------------------------------------
/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: git_bindings
2 | description: Provides a Git Higher level API using libgit2. It can be used
3 | with both iOS and Android.
4 | version: 0.0.19
5 | homepage: https://gitjournal.io
6 |
7 | environment:
8 | sdk: '>=2.12.0 <3.0.0'
9 | flutter: ">=1.10.7 <2.0.0"
10 |
11 | dependencies:
12 | flutter:
13 | sdk: flutter
14 |
15 | dev_dependencies:
16 | test: ^1.5.1
17 | flutter_test:
18 | sdk: flutter
19 | flutter_driver:
20 | sdk: flutter
21 |
22 | flutter:
23 | plugin:
24 | platforms:
25 | android:
26 | package: io.gitjournal.git_bindings
27 | pluginClass: GitBindingsPlugin
28 |
--------------------------------------------------------------------------------