本文整理汇总了Java中org.eclipse.jgit.storage.file.FileRepositoryBuilder.create方法的典型用法代码示例。如果您正苦于以下问题:Java FileRepositoryBuilder.create方法的具体用法?Java FileRepositoryBuilder.create怎么用?Java FileRepositoryBuilder.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.storage.file.FileRepositoryBuilder
的用法示例。
在下文中一共展示了FileRepositoryBuilder.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRepo
import org.eclipse.jgit.storage.file.FileRepositoryBuilder; //导入方法依赖的package包/类
/**
*
* @param repoPath
* @return
* @throws IOException
*/
public static Repository getRepo(String repoPath) throws IOException {
Repository repo;
File repoFile = new File(repoPath);
if (repoFile.exists()) {
// Open an existing repository
repo = new FileRepositoryBuilder()
.setGitDir(new File(repoPath))
.build();
} else {
// Create a new repository
repo = FileRepositoryBuilder.create(
new File(repoPath));
repo.create(true);
}
System.out.println(repo.getDirectory());
return repo;
}
示例2: onCreateView
import org.eclipse.jgit.storage.file.FileRepositoryBuilder; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
try {
Repository repository = FileRepositoryBuilder.create(gitDirFrom(getArguments()));
RevCommit before = commitFrom(repository, getArguments(), BEFORE_REV), after = commitFrom(repository, getArguments(), AFTER_REV);
Log.d(TAG, "onCreateView before = " + before);
Log.d(TAG, "onCreateView after = " + after);
View v = inflater.inflate(R.layout.rev_commit_view, container, false);
DiffSliderView diffSlider = (DiffSliderView) v.findViewById(R.id.RevCommitDiffSlider);
ExpandableListView expandableList = (ExpandableListView) v.findViewById(android.R.id.list);
expandableList.setAdapter(new CommitChangeListAdapter(repository, after, before, diffSlider,
expandableList, getActivity()));
return v;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例3: setup
import org.eclipse.jgit.storage.file.FileRepositoryBuilder; //导入方法依赖的package包/类
@Before
public void setup() throws IOException {
// Define a Test Directory
File localPath = File.createTempFile("TestGitRepository", "");
// prepare a new folder
if(localPath.exists()) localPath.delete();
// create the repository
repository = FileRepositoryBuilder.create(new File(localPath, ".git"));
repository.create();
// Setup Mocks
when(build.getWorkspace()).thenReturn(new FilePath(new File(getClass().getResource("/").getPath())));
when(listener.getLogger()).thenReturn(System.out);
when(app.getName()).thenReturn("testapp");
when(app.getGitUrl()).thenReturn(repository.getDirectory().getAbsolutePath());
mockStatic(Computer.class);
PowerMockito.when(Computer.currentComputer()).thenReturn(mock(MasterComputer.class));
}
示例4: createNewRepository
import org.eclipse.jgit.storage.file.FileRepositoryBuilder; //导入方法依赖的package包/类
private static Repository createNewRepository() throws IOException {
// prepare a new folder
File localPath = File.createTempFile("TestGitRepository", "");
if(!localPath.delete()) {
throw new IOException("Could not delete temporary file " + localPath);
}
if(!localPath.mkdirs()) {
throw new IOException("Could not create directory " + localPath);
}
// create the directory
Repository repository = FileRepositoryBuilder.create(new File(localPath, ".git"));
repository.create();
return repository;
}
示例5: createRepository
import org.eclipse.jgit.storage.file.FileRepositoryBuilder; //导入方法依赖的package包/类
private static File createRepository() throws IOException, GitAPIException {
File dir = File.createTempFile("gitinit", ".test");
if(!dir.delete()) {
throw new IOException("Could not delete temporary file " + dir);
}
Git.init()
.setDirectory(dir)
.call();
try (Repository repository = FileRepositoryBuilder.create(new File(dir.getAbsolutePath(), ".git"))) {
System.out.println("Created a new repository at " + repository.getDirectory());
}
return dir;
}
示例6: main
import org.eclipse.jgit.storage.file.FileRepositoryBuilder; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException, GitAPIException {
// run the init-call
File dir = File.createTempFile("gitinit", ".test");
if(!dir.delete()) {
throw new IOException("Could not delete file " + dir);
}
// The Git-object has a static method to initialize a new repository
try (Git git = Git.init()
.setDirectory(dir)
.call()) {
System.out.println("Created a new repository at " + git.getRepository().getDirectory());
}
dir = File.createTempFile("repoinit", ".test");
if(!dir.delete()) {
throw new IOException("Could not delete file " + dir);
}
// you can also create a Repository-object directly from the
try (Repository repository = FileRepositoryBuilder.create(new File(dir.getAbsolutePath(), ".git"))) {
System.out.println("Created a new repository at " + repository.getDirectory());
}
}
示例7: ScenarioBuilder
import org.eclipse.jgit.storage.file.FileRepositoryBuilder; //导入方法依赖的package包/类
/**
* Creates a ScenarioBuilder object pointing to a temporary fresh new & empty git repository.
*/
public ScenarioBuilder() {
try {
this.scenario = new Scenario(new File(Files.createTempDir(), ".git"));
this.repository = FileRepositoryBuilder.create(scenario.getRepositoryLocation());
repository.create();
this.git = new Git(repository);
} catch (Exception ex) {
throw new IllegalStateException("failure building scenario", ex);
}
}
示例8: createRepository
import org.eclipse.jgit.storage.file.FileRepositoryBuilder; //导入方法依赖的package包/类
public static Repository createRepository(File repo) throws IOException, GitAPIException {
if (!repo.exists()) {
Files.createDirectory(repo.toPath());
}
Repository repository = FileRepositoryBuilder.create(new File(repo, ".git"));
repository.create();
return repository;
}
示例9: createGitRepo
import org.eclipse.jgit.storage.file.FileRepositoryBuilder; //导入方法依赖的package包/类
public static Git createGitRepo(File dir) throws Exception {
Repository repo = FileRepositoryBuilder.create(dir);
repo.create(false);
Git git = new Git(repo);
// Commit first revision
git.commit().setMessage("Repository created").call();
return git;
}
示例10: testCreate
import org.eclipse.jgit.storage.file.FileRepositoryBuilder; //导入方法依赖的package包/类
/**
* �����½��ֿ�
*/
@Test
public void testCreate() throws IOException {
//�����½��ֿ��ַ
Repository newRepo = FileRepositoryBuilder.create(new File(initPath + "/.git"));
newRepo.create();
}
示例11: before
import org.eclipse.jgit.storage.file.FileRepositoryBuilder; //导入方法依赖的package包/类
@Before
public void before() throws IOException, GitAPIException {
worktree = temp.newFolder().toPath();
Repository repo = FileRepositoryBuilder.create(worktree.resolve(".git").toFile());
repo.create();
git = new Git(repo);
createAndCommitFile(worktree, "file-in-first-commit.xoo");
}
示例12: gitPull
import org.eclipse.jgit.storage.file.FileRepositoryBuilder; //导入方法依赖的package包/类
public static void gitPull(String localPathDynamic) {
Repository localRepo;
try {
localRepo = FileRepositoryBuilder.create(new File(localPathDynamic + File.separator + ".git"));
git = new Git(localRepo);
PullCommand pullCmd = git.pull();
pullCmd.call();
} catch (IOException | GitAPIException e) {
log.error("Error in pulling content from the git repository, hence proceeding with the previously cloned content ," + e);
}
}
示例13: onCreateLoader
import org.eclipse.jgit.storage.file.FileRepositoryBuilder; //导入方法依赖的package包/类
@Override
public Loader<BlobView> onCreateLoader(int id, Bundle b) {
return new AsyncLoader<BlobView>(getActivity()) {
public BlobView loadInBackground() {
Bundle args = getArguments();
try {
Repository repo = FileRepositoryBuilder.create(gitDirFrom(args));
ObjectId revision = repo.resolve(args.getString(UNTIL_REVS));
RevWalk revWalk = new RevWalk(repo);
RevCommit commit = revWalk.parseCommit(revision);
TreeWalk treeWalk = TreeWalk.forPath(repo, args.getString(PATH), commit.getTree());
ObjectId blobId = treeWalk.getObjectId(0);
ObjectLoader objectLoader = revWalk.getObjectReader().open(blobId, Constants.OBJ_BLOB);
ObjectStream binaryTestStream = objectLoader.openStream();
boolean blobIsBinary = RawText.isBinary(binaryTestStream);
binaryTestStream.close();
Log.d(TAG, "blobIsBinary="+blobIsBinary);
return blobIsBinary?new BinaryBlobView(objectLoader, treeWalk.getNameString()):new TextBlobView(objectLoader);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
};
}
示例14: onCreateView
import org.eclipse.jgit.storage.file.FileRepositoryBuilder; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
try {
Repository repository = FileRepositoryBuilder.create(gitDirFrom(getArguments()));
ObjectId commitId = revisionIdFrom(repository, getArguments(), REVISION);
Log.d(TAG, "onCreateView with "+commitId);
View v=inflater.inflate(R.layout.commit_detail_view, container, false);
CommitNavigationView commitNavigationView = (CommitNavigationView) v.findViewById(R.id.commit_navigation);
commitNavigationView.setCommitSelectedListener(commitSelectedListener);
PlotCommit<PlotLane> commit = commitSelectedListener.plotCommitFor(commitId);
commitNavigationView.setCommit(commit);
((ObjectIdView) v.findViewById(R.id.commit_id)).setObjectId(commit);
ViewGroup vg = (ViewGroup) v.findViewById(R.id.commit_people_group);
PersonIdent author = commit.getAuthorIdent(), committer = commit.getCommitterIdent();
if (author.equals(committer)) {
addPerson("Author & Committer", author, vg);
} else {
addPerson("Author", author, vg);
addPerson("Committer", committer, vg);
}
TextView textView = (TextView) v.findViewById(R.id.commit_message_text);
textView.setText(commit.getFullMessage());
return v;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例15: apply
import org.eclipse.jgit.storage.file.FileRepositoryBuilder; //导入方法依赖的package包/类
public RepoSummary apply(File gitdir) {
try {
Repository repo = FileRepositoryBuilder.create(gitdir);
return new RepoSummary(repo);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}