當前位置: 首頁>>代碼示例>>Java>>正文


Java Repository.resolve方法代碼示例

本文整理匯總了Java中org.eclipse.jgit.lib.Repository.resolve方法的典型用法代碼示例。如果您正苦於以下問題:Java Repository.resolve方法的具體用法?Java Repository.resolve怎麽用?Java Repository.resolve使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jgit.lib.Repository的用法示例。


在下文中一共展示了Repository.resolve方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getOriginalCommit

import org.eclipse.jgit.lib.Repository; //導入方法依賴的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

示例2: main

import org.eclipse.jgit.lib.Repository; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException, GitAPIException {

        Repository repo = Commands.getRepo(Consts.META_REPO_PATH);

        // Get the id of the tree associated to the two commits
        ObjectId head = repo.resolve("HEAD^{tree}");
        ObjectId previousHead = repo.resolve("HEAD~^{tree}");

        List<DiffEntry> list = listDiffs(repo, previousHead, head);
        if(list != null){            
            // Simply display the diff between the two commits
            list.forEach((diff) -> {
                System.out.println(diff);
            });
        }
    }
 
開發者ID:alexmy21,項目名稱:gmds,代碼行數:17,代碼來源:Diffs.java

示例3: getLastLocalCommit

import org.eclipse.jgit.lib.Repository; //導入方法依賴的package包/類
/**
 * Finds the last local commit in the repository
 * 
 * @return the last local commit
 */
public ObjectId getLastLocalCommit() {
	Repository repo = git.getRepository();
	try {
		return repo.resolve("HEAD^{commit}");
	} catch (IOException e) {
		if (logger.isDebugEnabled()) {
			logger.debug(e, e);
		}
	}
	return null;
}
 
開發者ID:oxygenxml,項目名稱:oxygen-git-plugin,代碼行數:17,代碼來源:GitAccess.java

示例4: getRemoteCommit

import org.eclipse.jgit.lib.Repository; //導入方法依賴的package包/類
/**
 * Finds the last remote commit from the remote repository
 * 
 * @return the last remote commit
 */
public ObjectId getRemoteCommit(BranchInfo branchInfo) {
	Repository repo = git.getRepository();
	ObjectId remoteCommit = null;
	try {
		remoteCommit = repo.resolve("origin/" + branchInfo.getBranchName() + "^{commit}");
		return remoteCommit;
	} catch (IOException e) {
		if (logger.isDebugEnabled()) {
			logger.debug(e, e);
		}
	}
	return remoteCommit;
}
 
開發者ID:oxygenxml,項目名稱:oxygen-git-plugin,代碼行數:19,代碼來源:GitAccess.java

示例5: getBaseCommit

import org.eclipse.jgit.lib.Repository; //導入方法依賴的package包/類
/**
 * Finds the base commit from the last local commit and the remote commit
 * 
 * @param branchInfo Current branch info or <code>null</code> if unknown.
 * 
 * @return the base commit
 */
public ObjectId getBaseCommit(BranchInfo branchInfo) {
  if (branchInfo == null) {
    branchInfo = getBranchInfo();
  }
	Repository repository = git.getRepository();
	RevWalk walk = new RevWalk(repository);
	ObjectId localCommit = null;
	ObjectId remoteCommit = null;
	ObjectId baseCommit = null;
	try {
		remoteCommit = repository.resolve("origin/" + branchInfo.getBranchName() + "^{commit}");
		localCommit = repository.resolve("HEAD^{commit}");
		if (remoteCommit != null && localCommit != null) {
			RevCommit base = getCommonAncestor(walk, walk.parseCommit(localCommit), walk.parseCommit(remoteCommit));
			if (base != null) {
				baseCommit = base.toObjectId();
			}
		}
	} catch (IOException e) {
		if (logger.isDebugEnabled()) {
			logger.debug(e, e);
		}
	}
	walk.close();
	return baseCommit;
}
 
開發者ID:oxygenxml,項目名稱:oxygen-git-plugin,代碼行數:34,代碼來源:GitAccess.java

示例6: resolveCommit

import org.eclipse.jgit.lib.Repository; //導入方法依賴的package包/類
public RevCommit resolveCommit(Repository repository, String commitId) throws Exception {
	ObjectId oid = repository.resolve(commitId);
	if (oid == null) {
		return null;
	}
	try (RevWalk rw = new RevWalk(repository)) {
		return rw.parseCommit(oid);
	} catch (MissingObjectException e) {
		return null;
	}
}
 
開發者ID:aserg-ufmg,項目名稱:RefDiff,代碼行數:12,代碼來源:GitHelper.java

示例7: resolveCommit

import org.eclipse.jgit.lib.Repository; //導入方法依賴的package包/類
@Override
public RevCommit resolveCommit(Repository repository, String commitId) throws Exception {
    ObjectId oid = repository.resolve(commitId);
    if (oid == null) {
        return null;
    }
    try (RevWalk rw = new RevWalk(repository)) {
        return rw.parseCommit(oid);
    } catch (MissingObjectException e) {
    	return null;
    }
   }
 
開發者ID:aserg-ufmg,項目名稱:RefDiff,代碼行數:13,代碼來源:GitServiceImpl.java

示例8: main

import org.eclipse.jgit.lib.Repository; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException, GitAPIException {

        Connection conn = null;
        Repository datarepo = Commands.getRepo(Consts.DATA_REPO_PATH + ".git");                             // (1)

        ObjectId lastCommitId = datarepo.resolve(Constants.HEAD);                                           // (2)
        System.out.println("Last Commit: " + lastCommitId);

        try {
            conn = DriverManager.getConnection(URL);

            TreeFormatter tree = new TreeFormatter();                                                       // (3)

            if (conn != null) {
                ObjectJson dbmdJson = new ObjectJson();
                ObjectId treeId = Utils.dataTreeCommit(datarepo, tree, conn, true);                         // (4)
                ObjectId lastTreeId = Commands.getLastCommitTreeId(datarepo, lastCommitId);                 // (5)
                ObjectId commitId = Commands.processCommit(lastCommitId, treeId, datarepo, lastTreeId);     // (6)
                if (commitId != null) {
                    List<DiffEntry> list = Diffs.listDiffs(datarepo, lastTreeId, treeId);                   // (7)
                    if (list != null) {
                        // Simply display the diff between the two commits
                        list.forEach((diff) -> {
                            // TODO
                            // Perform indexing of added to commit objects                                  // (8)
                            
                            // Print trace results
                            System.out.println(diff);
                        });
                        
                        // Index the whole commit tree                                                      // (9)
                        
                        System.out.print(dbmdJson.getObjectAsMap());
                    }
                }
            } else {
                System.out.println("Metadata not supported");
            }
        } catch (SQLException ex1) {
            System.err.println(ex1);
        } finally {
            if (conn != null) {
                try {
                    conn.close();
                } catch (SQLException ex) {
                    Logger.getLogger(DataMain.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
    }
 
開發者ID:alexmy21,項目名稱:gmds,代碼行數:51,代碼來源:DataMain.java

示例9: main

import org.eclipse.jgit.lib.Repository; //導入方法依賴的package包/類
public static void main(String[] args) throws IOException, GitAPIException {

        Connection conn = null;
        Repository repo = Commands.getRepo(Consts.META_REPO_PATH + ".git");                             // (1)

        ObjectId lastCommitId = repo.resolve(Constants.HEAD);                                           // (2)
        System.out.println("Last Commit: " + lastCommitId);

        try {
            conn = DriverManager.getConnection(URL);

            TreeFormatter tree = new TreeFormatter();                                                   // (3)

            if (conn != null) {
                ObjectJson dbmdJson = new ObjectJson();
                ObjectId treeId = Utils.metaTreeCommit(dbmdJson, repo, tree, conn, false);              // (4)
                ObjectId lastTreeId = Commands.getLastCommitTreeId(repo, lastCommitId);                 // (5)
                ObjectId commitId = Commands.processCommit(lastCommitId, treeId, repo, lastTreeId);     // (6)

                if (commitId != null) {
                    List<DiffEntry> list = Diffs.listDiffs(repo, lastTreeId, treeId);                   // (7)
                    if (list != null) {
                        // Simply display the diff between the two commits
                        list.forEach((diff) -> {
                            // TODO
                            // Perform indexing of added to commit objects
                        });
                    }
                    // Index the whole commit tree                                                      // (9)
                    DbIndex dbIndex = new DbIndex(Consts.META_REPO_PATH + ".git", esUrl, esPort);
                    dbIndex.indexCommitTree(repo);
                }
            } else {
                System.out.println("Metadata not supported");
            }
        } catch (SQLException ex1) {
            System.err.println(ex1);
        } finally {
            try {
                if (conn != null) {
                    conn.close();
                }
            } catch (SQLException ex2) {
                System.out.println(ex2.getMessage());
            }
        }
    }
 
開發者ID:alexmy21,項目名稱:gmds,代碼行數:48,代碼來源:MetaMain.java


注:本文中的org.eclipse.jgit.lib.Repository.resolve方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。