本文整理汇总了Java中org.eclipse.egit.github.core.Tree类的典型用法代码示例。如果您正苦于以下问题:Java Tree类的具体用法?Java Tree怎么用?Java Tree使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Tree类属于org.eclipse.egit.github.core包,在下文中一共展示了Tree类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTree
import org.eclipse.egit.github.core.Tree; //导入依赖的package包/类
private Tree createTree(DataService service, RepositoryId repository, Reference ref, List<TreeEntry> entries) throws GitHubException {
try {
int size = entries.size();
log.info(String.format("Creating tree with %s blob entries", size));
String baseTree = null;
if (merge && ref != null) {
Tree currentTree = service.getCommit(repository, ref.getObject().getSha()).getTree();
if (currentTree != null){
baseTree = currentTree.getSha();
}
log.info(MessageFormat.format("Merging with tree {0}", baseTree));
}
return service.createTree(repository, entries, baseTree);
} catch (IOException e) {
throw new GitHubException("Error creating tree: " + e.getMessage(), e);
}
}
示例2: getTree
import org.eclipse.egit.github.core.Tree; //导入依赖的package包/类
/**
* Get tree with given SHA-1
*
* @param repository
* @param sha
* @param recursive
* @return tree
* @throws IOException
*/
public Tree getTree(IRepositoryIdProvider repository, String sha,
boolean recursive) throws IOException {
final String id = getId(repository);
if (sha == null)
throw new IllegalArgumentException("SHA-1 cannot be null"); //$NON-NLS-1$
if (sha.length() == 0)
throw new IllegalArgumentException("SHA-1 cannot be empty"); //$NON-NLS-1$
StringBuilder uri = new StringBuilder();
uri.append(SEGMENT_REPOS);
uri.append('/').append(id);
uri.append(SEGMENT_GIT);
uri.append(SEGMENT_TREES);
uri.append('/').append(sha);
GitHubRequest request = createRequest();
request.setType(Tree.class);
request.setUri(uri);
if (recursive)
request.setParams(Collections.singletonMap("recursive", "1")); //$NON-NLS-1$ //$NON-NLS-2$
return (Tree) client.get(request).getBody();
}
示例3: createTree
import org.eclipse.egit.github.core.Tree; //导入依赖的package包/类
/**
* Create tree
*
* @param repository
* @param entries
* @param baseTree
* @return created tree
* @throws IOException
*/
public Tree createTree(IRepositoryIdProvider repository,
Collection<TreeEntry> entries, String baseTree) throws IOException {
final String id = getId(repository);
StringBuilder uri = new StringBuilder();
uri.append(SEGMENT_REPOS);
uri.append('/').append(id);
uri.append(SEGMENT_GIT);
uri.append(SEGMENT_TREES);
GitHubRequest request = createRequest();
request.setType(Tree.class);
request.setUri(uri);
Map<String, Object> params = new HashMap<String, Object>();
if (entries != null)
params.put("tree", entries.toArray()); //$NON-NLS-1$
if (baseTree != null)
params.put("base_tree", baseTree); //$NON-NLS-1$
return client.post(uri.toString(), params, Tree.class);
}
示例4: run
import org.eclipse.egit.github.core.Tree; //导入依赖的package包/类
@Override
protected FullTree run(Account account) throws Exception {
Reference ref = reference;
String branch = RefUtils.getPath(ref);
if (branch == null) {
branch = repository.getMasterBranch();
if (TextUtils.isEmpty(branch)) {
branch = repoService.getRepository(repository)
.getMasterBranch();
if (TextUtils.isEmpty(branch))
throw new IOException(
"Repository does not have master branch");
}
branch = "heads/" + branch;
}
if (!isValidRef(ref)) {
ref = dataService.getReference(repository, branch);
if (!isValidRef(ref))
throw new IOException(
"Reference does not have associated commit SHA-1");
}
Commit commit = dataService.getCommit(repository, ref.getObject()
.getSha());
if (commit == null || commit.getTree() == null
|| TextUtils.isEmpty(commit.getTree().getSha()))
throw new IOException("Commit does not have associated tree SHA-1");
Tree tree = dataService.getTree(repository, commit.getTree().getSha(),
true);
return new FullTree(tree, ref);
}
示例5: FullTree
import org.eclipse.egit.github.core.Tree; //导入依赖的package包/类
/**
* Create tree with branch
*
* @param tree
* @param reference
*/
public FullTree(final Tree tree, final Reference reference) {
this.tree = tree;
this.reference = reference;
this.branch = RefUtils.getName(reference);
root = new Folder();
List<TreeEntry> entries = tree.getTree();
if (entries != null && !entries.isEmpty())
for (TreeEntry entry : entries)
root.add(entry);
}
示例6: createCommit
import org.eclipse.egit.github.core.Tree; //导入依赖的package包/类
/**
* Create commit in given repository
*
* @param repository
* @param commit
* @return created commit
* @throws IOException
*/
public Commit createCommit(IRepositoryIdProvider repository, Commit commit)
throws IOException {
final String id = getId(repository);
if (commit == null)
throw new IllegalArgumentException("Commit cannot be null"); //$NON-NLS-1$
StringBuilder uri = new StringBuilder();
uri.append(SEGMENT_REPOS);
uri.append('/').append(id);
uri.append(SEGMENT_GIT);
uri.append(SEGMENT_COMMITS);
Map<String, Object> params = new HashMap<String, Object>();
params.put("author", commit.getAuthor()); //$NON-NLS-1$
params.put("committer", commit.getCommitter()); //$NON-NLS-1$
params.put("message", commit.getMessage()); //$NON-NLS-1$
List<Commit> parents = commit.getParents();
if (parents != null && parents.size() > 0) {
List<String> parentIds = new ArrayList<String>();
for (Commit parent : parents)
parentIds.add(parent.getSha());
params.put("parents", parentIds); //$NON-NLS-1$
}
Tree tree = commit.getTree();
if (tree != null)
params.put("tree", tree.getSha()); //$NON-NLS-1$
return client.post(uri.toString(), params, Commit.class);
}
示例7: commitFileToRepository
import org.eclipse.egit.github.core.Tree; //导入依赖的package包/类
private void commitFileToRepository(File commitDirectory, Repository repo,String refString,String accessToken) throws Exception
{
DataService dService=new DataService();
dService.getClient().setOAuth2Token(accessToken);
Reference ref=dService.getReference(repo, refString);
String lastCommitSHA=ref.getObject().getSha();
List<TreeEntry> treeArray=new ArrayList<TreeEntry>();
for(File f:commitDirectory.listFiles())
buildTreeRecusive(f,repo,dService,treeArray);
Tree tree=dService.createTree(repo, treeArray);
logger.info("Try to make up commit");
Commit parentCommit=new Commit();
parentCommit.setSha(lastCommitSHA);
List<Commit> parentCommitList=new ArrayList<Commit>();
parentCommitList.add(parentCommit);
Commit commit=new Commit();
commit.setTree(tree);
commit.setParents(parentCommitList);
commit.setMessage(generateCommitMessage());
commit=dService.createCommit(repo, commit);
logger.info("Try to edit reference");
ref.setRef(refString);
TypedResource res=new TypedResource();
res.setSha(commit.getSha());
res.setType(TypedResource.TYPE_COMMIT);
res.setUrl(commit.getUrl());
ref.setObject(res);
dService.editReference(repo, ref);
}
示例8: getTree
import org.eclipse.egit.github.core.Tree; //导入依赖的package包/类
public Tree getTree(Repository repository, String sha) throws IOException {
return dataService.getTree(repository, sha, true);
}
示例9: getRoot
import org.eclipse.egit.github.core.Tree; //导入依赖的package包/类
public Tree getRoot() {
return root;
}
示例10: setRoot
import org.eclipse.egit.github.core.Tree; //导入依赖的package包/类
public void setRoot(Tree root) {
this.root = root;
}