mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-08-30 22:05:19 +00:00
Merge branch 'jgit_beta'
This commit is contained in:
Binary file not shown.
@@ -31,7 +31,7 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
//compile fileTree(dir: 'libs', include: ['*.jar'])
|
//compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
compile project(':libraries:openpgp-api-lib')
|
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 'org.apache.commons:commons-io:1.3.2'
|
||||||
compile ('com.fortysevendeg.swipelistview:swipelistview:1.0-SNAPSHOT@aar') {
|
compile ('com.fortysevendeg.swipelistview:swipelistview:1.0-SNAPSHOT@aar') {
|
||||||
transitive = true
|
transitive = true
|
||||||
|
@@ -156,15 +156,24 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI
|
|||||||
File localDir = new File(getFilesDir() + "/store/");
|
File localDir = new File(getFilesDir() + "/store/");
|
||||||
localDir.mkdir();
|
localDir.mkdir();
|
||||||
try {
|
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...
|
// 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
|
// also, for compatibility use short-version of the key-id
|
||||||
FileUtils.writeStringToFile(new File(localDir.getAbsolutePath() + "/.gpg-id"),
|
FileUtils.writeStringToFile(new File(localDir.getAbsolutePath() + "/.gpg-id"),
|
||||||
keyId.substring(keyId.length() - 8));
|
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) {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
localDir.delete();
|
localDir.delete();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PasswordRepository.createRepository(localDir);
|
|
||||||
checkLocalRepository();
|
checkLocalRepository();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,10 +14,8 @@ import org.eclipse.jgit.transport.URIish;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileFilter;
|
import java.io.FileFilter;
|
||||||
import java.lang.reflect.Array;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -34,7 +32,7 @@ public class PasswordRepository {
|
|||||||
if (repository == null) {
|
if (repository == null) {
|
||||||
FileRepositoryBuilder builder = new FileRepositoryBuilder();
|
FileRepositoryBuilder builder = new FileRepositoryBuilder();
|
||||||
try {
|
try {
|
||||||
repository = builder.setGitDir(localDir)
|
repository = builder.setWorkTree(localDir)
|
||||||
.readEnvironment()
|
.readEnvironment()
|
||||||
.findGitDir()
|
.findGitDir()
|
||||||
.build();
|
.build();
|
||||||
@@ -54,31 +52,11 @@ public class PasswordRepository {
|
|||||||
initialized = v;
|
initialized = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void createRepository(File localDir) {
|
public static void createRepository(File localDir) throws Exception{
|
||||||
localDir.delete();
|
localDir.delete();
|
||||||
|
|
||||||
try {
|
Git.init().setDirectory(localDir).call();
|
||||||
|
getRepository(localDir);
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO add remote edition later-on
|
// TODO add remote edition later-on
|
||||||
|
Reference in New Issue
Block a user