本文整理汇总了Java中org.eclipse.jgit.lib.Repository.newObjectInserter方法的典型用法代码示例。如果您正苦于以下问题:Java Repository.newObjectInserter方法的具体用法?Java Repository.newObjectInserter怎么用?Java Repository.newObjectInserter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.lib.Repository
的用法示例。
在下文中一共展示了Repository.newObjectInserter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: metaTreeCommit
import org.eclipse.jgit.lib.Repository; //导入方法依赖的package包/类
/**
*
* @param dbmdJson
* @param repo
* @param tree
* @param conn
* @param clmnTree
* @return
* @throws IOException
* @throws SQLException
*/
public static ObjectId metaTreeCommit(ObjectJson dbmdJson, Repository repo, TreeFormatter tree,
Connection conn, Boolean clmnTree) throws IOException, SQLException {
DatabaseMetaData dbmd = conn.getMetaData();
// ObjectJson dbmdJson = new ObjectJson();
String mapString = metaDbInfo(dbmd);
ObjectInserter objectInserter = repo.newObjectInserter();
ObjectId blobId = objectInserter.insert(Constants.OBJ_BLOB, mapString.getBytes());
objectInserter.flush();
tree.append(Consts.DATABASE, FileMode.REGULAR_FILE, blobId);
Utils.putTableMeta(repo, conn, dbmd, objectInserter, tree, clmnTree);
ObjectId treeId = objectInserter.insert(tree);
objectInserter.flush();
System.out.println("Tree ID: " + treeId.getName());
return treeId;
}
示例2: dataTreeCommit
import org.eclipse.jgit.lib.Repository; //导入方法依赖的package包/类
/**
*
* @param datarepo
* @param tree
* @param conn
* @param clmnTree
* @return
* @throws SQLException
* @throws IOException
*/
public static ObjectId dataTreeCommit(Repository datarepo, TreeFormatter tree, Connection conn, Boolean clmnTree) throws SQLException, IOException {
DatabaseMetaData dbmd = conn.getMetaData();
// ObjectJson dbmdJson = new ObjectJson();
String mapString = metaDbInfo(dbmd);
// Build Db_Info object, general info about Database
ObjectInserter objectInserter = datarepo.newObjectInserter();
ObjectId blobId = objectInserter.insert(Constants.OBJ_BLOB, mapString.getBytes());
objectInserter.flush();
tree.append("DATABASE", FileMode.REGULAR_FILE, blobId);
// Continue building Database Tree
Utils.putTableMeta(datarepo, conn, dbmd, objectInserter, tree, clmnTree);
ObjectId treeId = objectInserter.insert(tree);
objectInserter.flush();
System.out.println("Tree ID: " + treeId.getName());
return treeId;
}
示例3: commit
import org.eclipse.jgit.lib.Repository; //导入方法依赖的package包/类
/**
*
* @param commitBuilder
* @param treeId
* @param repo
* @return
* @throws UnsupportedEncodingException
* @throws IOException
*/
public static ObjectId commit(CommitBuilder commitBuilder, ObjectId treeId, Repository repo) throws UnsupportedEncodingException, IOException {
commitBuilder.setTreeId(treeId);
commitBuilder.setMessage(System.currentTimeMillis() + ": My commit!\n");
PersonIdent person = new PersonIdent("Alex", "[email protected]");
commitBuilder.setAuthor(person);
commitBuilder.setCommitter(person);
commitBuilder.build();
ObjectInserter commitInserter = repo.newObjectInserter();
ObjectId commitId = commitInserter.insert(commitBuilder);
commitInserter.flush();
updateMasterRecord(repo, commitId);
System.out.println("Commit Object ID: " + commitId.getName());
return commitId;
}
示例4: rebase
import org.eclipse.jgit.lib.Repository; //导入方法依赖的package包/类
@Nullable
public static ObjectId rebase(Repository repository, ObjectId source, ObjectId target, PersonIdent committer) {
try ( RevWalk revWalk = new RevWalk(repository);
ObjectInserter inserter = repository.newObjectInserter();) {
RevCommit sourceCommit = revWalk.parseCommit(source);
RevCommit targetCommit = revWalk.parseCommit(target);
revWalk.setRevFilter(RevFilter.NO_MERGES);
List<RevCommit> commits = RevWalkUtils.find(revWalk, sourceCommit, targetCommit);
Collections.reverse(commits);
RevCommit headCommit = targetCommit;
for (RevCommit commit: commits) {
ResolveMerger merger = (ResolveMerger) MergeStrategy.RECURSIVE.newMerger(repository, true);
merger.setBase(commit.getParent(0));
if (merger.merge(headCommit, commit)) {
if (!headCommit.getTree().getId().equals(merger.getResultTreeId())) {
CommitBuilder newCommit = new CommitBuilder();
newCommit.setAuthor(commit.getAuthorIdent());
newCommit.setCommitter(committer);
newCommit.setParentId(headCommit);
newCommit.setMessage(commit.getFullMessage());
newCommit.setTreeId(merger.getResultTreeId());
headCommit = revWalk.parseCommit(inserter.insert(newCommit));
}
} else {
return null;
}
}
inserter.flush();
return headCommit.copy();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例5: merge
import org.eclipse.jgit.lib.Repository; //导入方法依赖的package包/类
@Nullable
public static ObjectId merge(Repository repository, ObjectId source, ObjectId target,
boolean squash, PersonIdent committer, String commitMessage) {
try ( RevWalk revWalk = new RevWalk(repository);
ObjectInserter inserter = repository.newObjectInserter();) {
RevCommit sourceCommit = revWalk.parseCommit(source);
RevCommit targetCommit = revWalk.parseCommit(target);
Merger merger = MergeStrategy.RECURSIVE.newMerger(repository, true);
if (merger.merge(targetCommit, sourceCommit)) {
CommitBuilder mergedCommit = new CommitBuilder();
mergedCommit.setAuthor(sourceCommit.getAuthorIdent());
mergedCommit.setCommitter(committer);
if (squash)
mergedCommit.setParentId(targetCommit);
else
mergedCommit.setParentIds(targetCommit, sourceCommit);
mergedCommit.setMessage(commitMessage);
mergedCommit.setTreeId(merger.getResultTreeId());
ObjectId mergedCommitId = inserter.insert(mergedCommit);
inserter.flush();
return mergedCommitId;
} else {
return null;
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}