本文整理汇总了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;
}
示例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);
});
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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);
}
}
}
}
示例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());
}
}
}