diff options
author | knuthy <knuthy@gmail.com> | 2014-10-04 18:26:54 +0200 |
---|---|---|
committer | knuthy <knuthy@gmail.com> | 2014-10-04 18:26:54 +0200 |
commit | adbdad88b1898e400552b97ccff7719b248f6176 (patch) | |
tree | eaf8b327fb906f920bd6a253cd5a8b08f0e59387 /app | |
parent | 7ad91f5356a729e1ff013cb651bc8cfc6fca1412 (diff) | |
parent | 27ac841e6d176da293e5cead48566bc00541fc00 (diff) |
Merge branch 'jgit_beta'
Diffstat (limited to 'app')
-rw-r--r-- | app/app-release.apk | bin | 1724217 -> 1725081 bytes | |||
-rw-r--r-- | app/build.gradle | 2 | ||||
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/PasswordStore.java | 11 | ||||
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java | 30 |
4 files changed, 15 insertions, 28 deletions
diff --git a/app/app-release.apk b/app/app-release.apk Binary files differindex 4273d0b8..908f6f07 100644 --- a/app/app-release.apk +++ b/app/app-release.apk diff --git a/app/build.gradle b/app/build.gradle index 03205f67..e053108f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -31,7 +31,7 @@ repositories { dependencies { //compile fileTree(dir: 'libs', include: ['*.jar']) compile project(':libraries:openpgp-api-lib') - compile 'org.eclipse.jgit:org.eclipse.jgit:3.4.1.+' + compile 'org.eclipse.jgit:org.eclipse.jgit:3.5.+' compile 'org.apache.commons:commons-io:1.3.2' compile ('com.fortysevendeg.swipelistview:swipelistview:1.0-SNAPSHOT@aar') { transitive = true diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java index a613b021..20f58cfb 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java @@ -156,15 +156,24 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI File localDir = new File(getFilesDir() + "/store/"); localDir.mkdir(); try { + PasswordRepository.createRepository(localDir); + // we take only the first key-id, we have to think about how to handle multiple keys, and why should we do that... // also, for compatibility use short-version of the key-id FileUtils.writeStringToFile(new File(localDir.getAbsolutePath() + "/.gpg-id"), keyId.substring(keyId.length() - 8)); + + Git git = new Git(PasswordRepository.getRepository(new File(""))); + GitAsyncTask tasks = new GitAsyncTask(this, false, false, CommitCommand.class); + tasks.execute( + git.add().addFilepattern("."), + git.commit().setMessage("[ANDROID PwdStore] Initialized store with keyID: " + keyId) + ); } catch (Exception e) { + e.printStackTrace(); localDir.delete(); return; } - PasswordRepository.createRepository(localDir); checkLocalRepository(); } diff --git a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java index 24a1524c..bc36f1cb 100644 --- a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java +++ b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java @@ -14,10 +14,8 @@ import org.eclipse.jgit.transport.URIish; import java.io.File; import java.io.FileFilter; -import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Set; @@ -34,7 +32,7 @@ public class PasswordRepository { if (repository == null) { FileRepositoryBuilder builder = new FileRepositoryBuilder(); try { - repository = builder.setGitDir(localDir) + repository = builder.setWorkTree(localDir) .readEnvironment() .findGitDir() .build(); @@ -54,31 +52,11 @@ public class PasswordRepository { initialized = v; } - public static void createRepository(File localDir) { + public static void createRepository(File localDir) throws Exception{ localDir.delete(); - try { - - // create the directory - Repository repository = FileRepositoryBuilder.create(new File(localDir, ".git")); - repository.create(); - - Git.init() - .setDirectory(localDir) - .call(); - - getRepository(localDir); - - new Git(repository) - .branchCreate() - .setName("master") - .call(); - - initialized = true; - } catch (Exception e) { - e.printStackTrace(); - return; - } + Git.init().setDirectory(localDir).call(); + getRepository(localDir); } // TODO add remote edition later-on |