当前位置: 首页>>代码示例>>Java>>正文


Java Repository.newObjectInserter方法代码示例

本文整理汇总了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;
    }
 
开发者ID:alexmy21,项目名称:gmds,代码行数:32,代码来源:Utils.java

示例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;
    }
 
开发者ID:alexmy21,项目名称:gmds,代码行数:33,代码来源:Utils.java

示例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;
}
 
开发者ID:alexmy21,项目名称:gmds,代码行数:29,代码来源:Commands.java

示例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);
}
  }
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:34,代码来源:GitUtils.java

示例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);
}
  }
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:29,代码来源:GitUtils.java


注:本文中的org.eclipse.jgit.lib.Repository.newObjectInserter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。