Hi again, this is related to #24.
@nevenz, @IvanMalison could one of you please take a look at this draft to just get things working with regards to syncing a git repository? I'm working off the list mentioned in https://github.com/orgzly/orgzly-android/pull/173#issuecomment-336303192 but wanted to check that the base I'll be working on isn't busted first.
A few things I'm not sure about:
- We handle an initially empty git repo by checking for a RevCommit that is null or a getObjectId() that is null, this leads to a few strange checks, see e.g. https://github.com/orgzly/orgzly-android/commit/b3736b224a789580fbc1cd5c28ed6eafa7478b2a#diff-fed1654ff699f68e117dce23ae1625acR157 where null means that we should push.
- DataRepository is now sent as an argument to both GitRepo and RepoPreferences, maybe there's a better way to solve this?
- I'm not sure how sync back should be handled, currently SyncService#handleTwoWaySync checks if loadFile is null and in that case doesn't do much.
- I've made GitFileSynchronize#updateAndCommitFile() public since it seemed to fit what I wanted to do when there are no commits in the repo, thoughts?
Regarding authentication, I'd like to add support for generating a SSH-key as an alternative to user/pass authentication, should I do that in a later PR or can I cram that into this one?
Keeping the list of things to fix here, from #173:
Issues or missing features to be resolved before enabling this in the app
- [x] Warning when syncing from Android Studio
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.1.3 is ignored for fdroidDebug as it may be conflicting with the internal version provided by Android.
-
[x] Building fails when doing ./gradlew build
(proguard-rules.pro
needs updating probably)
-
[x] Asking for Storage permission before entering Git repo creation, leaving user in repos list, see 596ff7f9e604241093011b77df0c9d95d8b73465
-
[ ] Prepopulate directory (Orgzly/repos/git in storage root or similar)
Semi-done, currently a directory is created when none is selected and is auto-selected. But I'm not sure that's what we want to do if the user decides to setup another repo as we'll try to re-use that same folder in that case which won't work out.
-
[x] On tapping checkmark (using [email protected]:nevenz/foo.git
)
11-09 08:05:24.383 7914 7914 W System.err: java.io.IOException: Directory /storage/emulated/0/Download/git is not a git repository.
11-09 08:05:24.383 7914 7914 W System.err: at com.orgzly.android.repos.GitRepo.ensureRepositoryExists(GitRepo.java:109)
11-09 08:05:24.384 7914 7914 W System.err: at com.orgzly.android.repos.GitRepo.ensureRepositoryExists(GitRepo.java:73)
11-09 08:05:24.384 7914 7914 W System.err: at com.orgzly.android.ui.fragments.GitRepoFragment$RepoCloneTask.doInBackground(GitRepoFragment.java:343)
11-09 08:05:24.384 7914 7914 W System.err: at com.orgzly.android.ui.fragments.GitRepoFragment$RepoCloneTask.doInBackground(GitRepoFragment.java:312)
As far as I can tell this has been solved.
-
[x] Had to delete selected (empty, created from browser) directory (can't use just browser, we have to type?)
-
[x] Edit repo, change to non-existing URL, no check (dialog) this time, repo is accepted
-
[x] Trying to sync gives "No repos configured" (with non-existing URL created above). Later discovered that the file from repository was downloaded at one point after all
-
[x] "Unsupported repository type" trying to edit repo (non-existing URL)
11-09 08:15:50.019 7914 7914 W System.err: java.io.IOException: The file /storage/emulated/0/Documents/nevenz/foo2.git does not exist
11-09 08:15:50.019 7914 7914 W System.err: at com.orgzly.android.repos.GitRepo.ensureRepositoryExists(GitRepo.java:105)
11-09 08:15:50.019 7914 7914 W System.err: at com.orgzly.android.repos.GitRepo.ensureRepositoryExists(GitRepo.java:73)
11-09 08:15:50.019 7914 7914 W System.err: at com.orgzly.android.repos.GitRepo.build(GitRepo.java:57)
11-09 08:15:50.019 7914 7914 W System.err: at com.orgzly.android.repos.GitRepo.buildFromUri(GitRepo.java:53)
11-09 08:15:50.019 7914 7914 W System.err: at com.orgzly.android.repos.RepoFactory.getFromUri(RepoFactory.java:49)
11-09 08:15:50.019 7914 7914 W System.err: at com.orgzly.android.repos.RepoFactory.getFromUri(RepoFactory.java:23)
11-09 08:15:50.019 7914 7914 W System.err: at com.orgzly.android.ui.ReposActivity.onRepoEditRequest(ReposActivity.java:188)
11-09 08:15:50.019 7914 7914 W System.err: at com.orgzly.android.ui.fragments.ReposFragment.onListItemClick(ReposFragment.java:130)
Should be fixed, can't reproduce
10-12 23:20:20.008 6287 6416 E AndroidRuntime: Caused by: java.lang.ClassCastException: org.eclipse.jgit.transport.TransportHttp cannot be cast to org.eclipse.jgit.transport.SshTransport
10-12 23:20:20.008 6287 6416 E AndroidRuntime: at com.orgzly.android.git.GitSSHKeyTransportSetter$2.configure(GitSSHKeyTransportSetter.java:40)
10-12 23:20:20.008 6287 6416 E AndroidRuntime: at org.eclipse.jgit.api.TransportCommand.configure(TransportCommand.java:138)
10-12 23:20:20.008 6287 6416 E AndroidRuntime: at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:128)
10-12 23:20:20.008 6287 6416 E AndroidRuntime: at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:193)
10-12 23:20:20.008 6287 6416 E AndroidRuntime: at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:133)
10-12 23:20:20.008 6287 6416 E AndroidRuntime: at com.orgzly.android.repos.GitRepo.ensureRepositoryExists(GitRepo.java:91)
10-12 23:20:20.008 6287 6416 E AndroidRuntime: at com.orgzly.android.repos.GitRepo.ensureRepositoryExists(GitRepo.java:73)
10-12 23:20:20.008 6287 6416 E AndroidRuntime: at com.orgzly.android.ui.fragments.GitRepoFragment$RepoCloneTask.doInBackground(GitRepoFragment.java:343)
10-12 23:20:20.008 6287 6416 E AndroidRuntime: at com.orgzly.android.ui.fragments.GitRepoFragment$RepoCloneTask.doInBackground(GitRepoFragment.java:312)
10-12 23:20:20.008 6287 6416 E AndroidRuntime: at android.os.AsyncTask$2.call(AsyncTask.java:305)
10-12 23:20:20.008 6287 6416 E AndroidRuntime: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
Partially fixed, using https now works, but you can not supply credentials, so this only works when authentication isn't needed. See #643 for the fix.
-
[x] Clicking checkmark immediately (all fields empty): Snackbar with javaj.io.IOException: Failed to clone repository , null
-
[x] Entering "asd" as URL and pressing checkmark
java.io.IOException: Failed to clone repository asd, org.eclipse.jgit.errors.NoRemoteRepositoryException: asd: not found.
this is fixed, however, maybe we should replace the progress modal with a progress bar of some kind?
-
[x] Error checking for all other fields
-
[x] Allow login with user/pass
-
[ ] Update JGit version to a newer one and solve the entrySet() problem
Found during testing/changes from @amberin
- [ ] Changing the storage location for a repo makes the repo unusable
- [ ] mtime correction
- [ ] Change how conflict resolution is handled, push the conflicting merge branch to remote to allow fixing it somewhere else and then allow "force-pulling" a notebook. This probably doesn't fit in this PR but I wanted to remember it.
Minor stuff
-
[x] Big button for Git needs to be added in repos list (between Dropbox and Directory)
-
[x] Change order in +
drop-down (Dropbox, Git, Directory)
-
[x] Can't scroll down (not using ScrollView?)
-
[x] Git branch's input is half a size (top half is cut off)
-
[x] Snackbar displayed below opened keyboard
-
[x] Action button (imeOptions
) - actionNext
for all but last, which should be actionDone
-
[x] Remove "Git" from all hints
-
[x] Git author (e.g. My Name) -> Name (e.g. John Doe)
-
[x] Git email (e.g. [email protected]) -> Email (e.g. [email protected])
-
[x] Git branch (e.g. master) -> Branch
-
[x] Prepopulate branch with "master"
-
[x] Fields with browse button don't have hint displayed when value is set (TextInputLayout
missing?)
-
[x] Git remote address -> Remote URL
-
[x] Extract string resources displayed to user (errors etc.)
-
[ ] Move git package to sync/ or repos/ (for now)
Thanks!