-1
をコミット特定のために行われています、私は1つのファイルに対してコミットする以上のものを持っています。どのようにステータス/アクションを取得することができますコミット。私は、特定のコミットを知ることができますか、そのファイルが新しく追加されたか、それが変更されているか、上記の詳細を取得します。
をコミット特定のために行われています、私は1つのファイルに対してコミットする以上のものを持っています。どのようにステータス/アクションを取得することができますコミット。私は、特定のコミットを知ることができますか、そのファイルが新しく追加されたか、それが変更されているか、上記の詳細を取得します。
JGit
に // find the HEAD
ObjectId lastCommitId = existingRepo.resolve(Constants.HEAD);
// a RevWalk allows to walk over commits based on some filtering that is defined
try (RevWalk revWalk = new RevWalk(existingRepo)) {
RevCommit commit = revWalk.parseCommit(lastCommitId);
// and using commit's tree find the path
RevTree tree = commit.getTree();
// now try to find a specific file
try (TreeWalk treeWalk = new TreeWalk(existingRepo)) {
treeWalk.addTree(tree);
treeWalk.setRecursive(true);
treeWalk.setFilter(PathFilter.create("TestProject/test1"));
if (!treeWalk.next()) {
throw new IllegalStateException("Did not find expected file");
}
ObjectId objectId = treeWalk.getObjectId(0);
ObjectLoader loader = existingRepo.open(objectId);
// and then one can the loader to read the file
loader.copyTo(System.out);
// Get status
Git git = new Git(existingRepo);
StatusCommand status = git.status().addPath(treeWalk.getPathString());
System.out.println("Not Modified : " + status.call().getModified().isEmpty());
}
を使用してgitのファイルのステータスを取得し、あなたはより多くを説明してくださいだろうか? – Alice
添付画像のステータス欄に表示されるので、JGITでAPIを取得したい –
http://stackoverflow.com/questions/23508315/git-status-does-not-show-changes-when-creatingをチェックしましたか? -repo-in-jgit – Alice