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


Java ObjectId类代码示例

本文整理汇总了Java中org.eclipse.jgit.lib.ObjectId的典型用法代码示例。如果您正苦于以下问题:Java ObjectId类的具体用法?Java ObjectId怎么用?Java ObjectId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ObjectId类属于org.eclipse.jgit.lib包,在下文中一共展示了ObjectId类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRepositoryZip

import org.eclipse.jgit.lib.ObjectId; //导入依赖的package包/类
/** 커밋을 입력받으면 당시 파일들을 압축하여 사용자에게 보내줌.
 * @param commitName
 * @param format
 * @param response
 */
public void getRepositoryZip(String commitName,String format, HttpServletResponse response) {

	try {
		ArchiveCommand.registerFormat("zip", new ZipFormat());
		ArchiveCommand.registerFormat("tar", new TarFormat());
		ObjectId revId = this.localRepo.resolve(commitName);
		git.archive().setOutputStream(response.getOutputStream())
		.setFormat(format)
		.setTree(revId)
		.call();

		ArchiveCommand.unregisterFormat("zip");
		ArchiveCommand.unregisterFormat("tar");
		response.flushBuffer();
	} catch (Exception e) {
		System.err.println(e.getMessage());
	}

}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:25,代码来源:GitUtil.java

示例2: getAuthorLineImpact

import org.eclipse.jgit.lib.ObjectId; //导入依赖的package包/类
/**
 * Get line impact of author
 *
 * @param name
 * @return stats
 */
public LineStats getAuthorLineImpact(String name) {
	Set<String> emails = namesToEmails.get(name);
	if (emails == null)
		return new LineStats();
	LineStats stats = new LineStats();
	for (String email : emails) {
		UserCommitActivity activity = authorHistogram.getActivity(email);
		if (activity == null)
			continue;
		for (ObjectId commit : activity.getIds()) {
			CommitImpact impact = mostLines.get(commit);
			if (impact != null) {
				stats.add += impact.getAdd();
				stats.edit += impact.getEdit();
				stats.delete += impact.getDelete();
			}
		}
	}
	return stats;
}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:27,代码来源:GitInfo.java

示例3: isDirectory

import org.eclipse.jgit.lib.ObjectId; //导入依赖的package包/类
/** 파일주소와 커밋아이디를 바탕으로 디렉토리인지 검사함.
 * @param commitID
 * @param filePath
 * @return
 */
public boolean isDirectory(String commitID, String filePath){
	if(filePath.length() == 0)
		return true;
	try{
		ObjectId revId = this.localRepo.resolve(commitID);
		TreeWalk treeWalk = new TreeWalk(this.localRepo);
		treeWalk.addTree(new RevWalk(this.localRepo).parseTree(revId));
		treeWalk.setRecursive(true);
		while (treeWalk.next()) {
			if(treeWalk.getPathString().equals(filePath)){
				return false;
			}
		}
		treeWalk.reset(new RevWalk(this.localRepo).parseTree(revId));
		while (treeWalk.next()) {
			if(treeWalk.getPathString().startsWith(filePath)){
				return true;
			}
		}
	}catch(Exception e){
		return false;
	}
	return false;
}
 
开发者ID:forweaver,项目名称:forweaver2.0,代码行数:30,代码来源:GitUtil.java

示例4: submoduleCompare

import org.eclipse.jgit.lib.ObjectId; //导入依赖的package包/类
/**
 * Returns for the given submodule the SHA-1 commit id for the Index if the
 * given index boolean is <code>true</code> or the SHA-1 commit id for the
 * HEAD if the given index boolean is <code>false</code>
 * 
 * @param submodulePath
 *          - the path to get the submodule
 * @param index
 *          - boolean to determine what commit id to return
 * @return the SHA-1 id
 */
public ObjectId submoduleCompare(String submodulePath, boolean index) {
	try {
		SubmoduleStatus submoduleStatus = git.submoduleStatus().addPath(submodulePath).call().get(submodulePath);
		if (submoduleStatus != null) {
		  if (index) {
		    return submoduleStatus.getIndexId();
		  } else {
		    return submoduleStatus.getHeadId();
		  }
		}
	} catch (GitAPIException e) {
		if (logger.isDebugEnabled()) {
			logger.debug(e, e);
		}
	}
	return null;
}
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:29,代码来源:GitAccess.java

示例5: commit

import org.eclipse.jgit.lib.ObjectId; //导入依赖的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

示例6: getOriginalCommit

import org.eclipse.jgit.lib.ObjectId; //导入依赖的package包/类
private ObjectId getOriginalCommit () throws GitException {
    Repository repository = getRepository();
    File seqHead = new File(getSequencerFolder(), SEQUENCER_HEAD);
    ObjectId originalCommitId = null;
    if (seqHead.canRead()) {
        try {
            byte[] content = IO.readFully(seqHead);
            if (content.length > 0) {
                originalCommitId = ObjectId.fromString(content, 0);
            }
            if (originalCommitId != null) {
                originalCommitId = repository.resolve(originalCommitId.getName() + "^{commit}");
            }
        } catch (IOException e) {
        }
    }
    return originalCommitId;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:CherryPickCommand.java

示例7: open

import org.eclipse.jgit.lib.ObjectId; //导入依赖的package包/类
@Transactional
@Override
public void open(PullRequest request) {
	request.setNumber(getNextNumber(request.getTargetProject()));
	dao.persist(request);
	
	RefUpdate refUpdate = GitUtils.getRefUpdate(request.getTargetProject().getRepository(), request.getBaseRef());
	refUpdate.setNewObjectId(ObjectId.fromString(request.getBaseCommitHash()));
	GitUtils.updateRef(refUpdate);
	
	refUpdate = GitUtils.getRefUpdate(request.getTargetProject().getRepository(), request.getHeadRef());
	refUpdate.setNewObjectId(ObjectId.fromString(request.getHeadCommitHash()));
	GitUtils.updateRef(refUpdate);
	
	for (PullRequestUpdate update: request.getUpdates()) {
		pullRequestUpdateManager.save(update, false);
	}
	
	for (ReviewInvitation invitation: request.getReviewInvitations())
		reviewInvitationManager.save(invitation);

	checkAsync(request);
	
	listenerRegistry.post(new PullRequestOpened(request));
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:26,代码来源:DefaultPullRequestManager.java

示例8: dataTreeCommit

import org.eclipse.jgit.lib.ObjectId; //导入依赖的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

示例9: getLastCommit

import org.eclipse.jgit.lib.ObjectId; //导入依赖的package包/类
@Nullable
@Override
public ObjectId getLastCommit(Project project) {
	Environment env = getEnv(project.getId().toString());
	Store defaultStore = getStore(env, DEFAULT_STORE);

	return env.computeInTransaction(new TransactionalComputable<ObjectId>() {
		
		@Override
		public ObjectId compute(Transaction txn) {
			byte[] bytes = getBytes(defaultStore.get(txn, LAST_COMMIT_KEY));
			return bytes != null? ObjectId.fromRaw(bytes): null;
		}
		
	});
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:17,代码来源:DefaultCommitInfoManager.java

示例10: checkJGitFix

import org.eclipse.jgit.lib.ObjectId; //导入依赖的package包/类
private void checkJGitFix (String branch, File file) throws Exception {
    ObjectId headTree = null;
    try {
        headTree = Utils.findCommit(repository, Constants.HEAD).getTree();
    } catch (GitException.MissingObjectException ex) { }

    DirCache cache = repository.lockDirCache();
    RevCommit commit;
    commit = Utils.findCommit(repository, branch);
    DirCacheCheckout dco = new DirCacheCheckout(repository, headTree, cache, commit.getTree());
    dco.setFailOnConflict(false);
    dco.checkout();
    if (file.exists()) {
        // and do not forget to remove WA in checkout command when JGit is fixed.
        fail("Hey, JGit is fixed, why don't you fix me as well?");
    }
    cache.unlock();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:CheckoutTest.java

示例11: updateMasterRecord

import org.eclipse.jgit.lib.ObjectId; //导入依赖的package包/类
/**
 *
 * @param repo
 * @param objectId
 * @throws IOException
 */
public static void updateMasterRecord(Repository repo, ObjectId objectId) throws IOException {

    RefUpdate refUpdate = repo.updateRef(Constants.HEAD);
    refUpdate.setNewObjectId(objectId);
    final RefUpdate.Result result = refUpdate.forceUpdate();

    switch (result) {
        case NEW:
            System.out.println("New commit!\n");
            break;
        case FORCED:
            System.out.println("Forced change commit!\n");
            break;
        default: {
            System.out.println(result.name());
        }
    }
}
 
开发者ID:alexmy21,项目名称:gmds,代码行数:25,代码来源:Commands.java

示例12: doRefUpdate

import org.eclipse.jgit.lib.ObjectId; //导入依赖的package包/类
@VisibleForTesting
static void doRefUpdate(org.eclipse.jgit.lib.Repository jGitRepository, RevWalk revWalk,
                        String ref, ObjectId commitId) throws IOException {

    if (ref.startsWith(Constants.R_TAGS)) {
        final Ref oldRef = jGitRepository.exactRef(ref);
        if (oldRef != null) {
            throw new StorageException("tag ref exists already: " + ref);
        }
    }

    final RefUpdate refUpdate = jGitRepository.updateRef(ref);
    refUpdate.setNewObjectId(commitId);

    final Result res = refUpdate.update(revWalk);
    switch (res) {
        case NEW:
        case FAST_FORWARD:
            // Expected
            break;
        default:
            throw new StorageException("unexpected refUpdate state: " + res);
    }
}
 
开发者ID:line,项目名称:centraldogma,代码行数:25,代码来源:GitRepository.java

示例13: notifyWatchers

import org.eclipse.jgit.lib.ObjectId; //导入依赖的package包/类
private void notifyWatchers(Revision newRevision, ObjectId prevTreeId, ObjectId nextTreeId) {
    final List<DiffEntry> diff = compareTrees(prevTreeId, nextTreeId, TreeFilter.ALL);
    for (DiffEntry e: diff) {
        switch (e.getChangeType()) {
        case ADD:
            commitWatchers.notify(newRevision, e.getNewPath());
            break;
        case MODIFY:
        case DELETE:
            commitWatchers.notify(newRevision, e.getOldPath());
            break;
        default:
            throw new Error();
        }
    }
}
 
开发者ID:line,项目名称:centraldogma,代码行数:17,代码来源:GitRepository.java

示例14: testDoUpdateRef

import org.eclipse.jgit.lib.ObjectId; //导入依赖的package包/类
private static void testDoUpdateRef(String ref, ObjectId commitId, boolean tagExists) throws Exception {
    final org.eclipse.jgit.lib.Repository jGitRepo = mock(org.eclipse.jgit.lib.Repository.class);
    final RevWalk revWalk = mock(RevWalk.class);
    final RefUpdate refUpdate = mock(RefUpdate.class);

    when(jGitRepo.exactRef(ref)).thenReturn(tagExists ? mock(Ref.class) : null);
    when(jGitRepo.updateRef(ref)).thenReturn(refUpdate);

    when(refUpdate.update(revWalk)).thenReturn(RefUpdate.Result.NEW);
    GitRepository.doRefUpdate(jGitRepo, revWalk, ref, commitId);

    when(refUpdate.update(revWalk)).thenReturn(RefUpdate.Result.FAST_FORWARD);
    GitRepository.doRefUpdate(jGitRepo, revWalk, ref, commitId);

    when(refUpdate.update(revWalk)).thenReturn(RefUpdate.Result.LOCK_FAILURE);
    assertThatThrownBy(() -> GitRepository.doRefUpdate(jGitRepo, revWalk, ref, commitId))
            .isInstanceOf(StorageException.class);
}
 
开发者ID:line,项目名称:centraldogma,代码行数:19,代码来源:GitRepositoryTest.java

示例15: simpleAccess

import org.eclipse.jgit.lib.ObjectId; //导入依赖的package包/类
@Test
public void simpleAccess() throws Exception {
    final int numCommits = 10;
    final ObjectId[] expectedCommitIds = new ObjectId[numCommits + 1];
    for (int i = 1; i <= numCommits; i++) {
        final Revision revision = new Revision(i);
        final ObjectId commitId = randomCommitId();
        expectedCommitIds[i] = commitId;
        db.put(revision, commitId);
        assertThat(db.headRevision()).isEqualTo(revision);
    }

    for (int i = 1; i <= numCommits; i++) {
        assertThat(db.get(new Revision(i))).isEqualTo(expectedCommitIds[i]);
    }

    assertThatThrownBy(() -> db.get(Revision.HEAD))
            .isInstanceOf(IllegalArgumentException.class)
            .hasMessageContaining("absolute revision");
    assertThatThrownBy(() -> db.get(new Revision(numCommits + 1)))
            .isInstanceOf(RevisionNotFoundException.class);
}
 
开发者ID:line,项目名称:centraldogma,代码行数:23,代码来源:CommitIdDatabaseTest.java


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