• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Reference类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createTree

import org.eclipse.egit.github.core.Reference; //导入依赖的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);
	}
}
 
开发者ID:opoo,项目名称:opoopress,代码行数:20,代码来源:GitHub.java


示例2: getReference

import org.eclipse.egit.github.core.Reference; //导入依赖的package包/类
/**
 * Get reference with given name
 *
 * @param repository
 * @param name
 * @return reference
 * @throws IOException
 */
public Reference getReference(IRepositoryIdProvider repository, String name)
		throws IOException {
	final String id = getId(repository);
	if (name == null)
		throw new IllegalArgumentException("Name cannot be null"); //$NON-NLS-1$
	if (name.length() == 0)
		throw new IllegalArgumentException("Name cannot be empty"); //$NON-NLS-1$

	StringBuilder uri = new StringBuilder();
	uri.append(SEGMENT_REPOS);
	uri.append('/').append(id);
	uri.append(SEGMENT_GIT);
	if (!name.startsWith("refs/")) //$NON-NLS-1$
		uri.append(SEGMENT_REFS);
	uri.append('/').append(name);
	GitHubRequest request = createRequest();
	request.setType(Reference.class);
	request.setUri(uri);
	return (Reference) client.get(request).getBody();
}
 
开发者ID:tsangiotis,项目名称:JekyllForAndroid,代码行数:29,代码来源:DataService.java


示例3: createReference

import org.eclipse.egit.github.core.Reference; //导入依赖的package包/类
/**
 * Create reference
 *
 * @param repository
 * @param reference
 * @return created reference
 * @throws IOException
 */
public Reference createReference(IRepositoryIdProvider repository,
		Reference reference) throws IOException {
	final String id = getId(repository);
	if (reference == null)
		throw new IllegalArgumentException("Reference cannot be null"); //$NON-NLS-1$
	TypedResource object = reference.getObject();
	if (object == null)
		throw new IllegalArgumentException(
				"Reference object 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_REFS);
	Map<String, String> params = new HashMap<String, String>();
	params.put("sha", object.getSha()); //$NON-NLS-1$
	params.put("ref", reference.getRef()); //$NON-NLS-1$
	return client.post(uri.toString(), params, Reference.class);
}
 
开发者ID:tsangiotis,项目名称:JekyllForAndroid,代码行数:29,代码来源:DataService.java


示例4: getRepositoryRefs

import org.eclipse.egit.github.core.Reference; //导入依赖的package包/类
private List<Reference> getRepositoryRefs(Repository repo,String accessToken) throws Exception
{
	DataService dService=new DataService();
	dService.getClient().setOAuth2Token(accessToken);
	try
	{
		return dService.getReferences(repo);
	}
	catch(IOException e)
	{
		if(e.getMessage().contains("409"))
		{
			return new ArrayList<Reference>();
		}
		else
		{
			throw e;
		}
	}
}
 
开发者ID:GitHubPager,项目名称:GitHubPager,代码行数:21,代码来源:PageManager.java


示例5: switchRefs

import org.eclipse.egit.github.core.Reference; //导入依赖的package包/类
private void switchRefs() {
    if (ref == null)
        return;

    if (dialog == null)
        dialog = new RefDialog((DialogFragmentActivity) getActivity(),
                REF_UPDATE, repository, dataService);
    dialog.show(new Reference().setRef(ref));
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:10,代码来源:CommitListFragment.java


示例6: RefListAdapter

import org.eclipse.egit.github.core.Reference; //导入依赖的package包/类
public RefListAdapter(LayoutInflater inflater, Reference[] refs,
        int selected) {
    super(inflater, com.github.mobile.R.layout.ref_item);

    this.selected = selected;
    setItems(refs);
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:8,代码来源:RefDialogFragment.java


示例7: update

import org.eclipse.egit.github.core.Reference; //导入依赖的package包/类
@Override
protected void update(int position, Reference item) {
    if (RefUtils.isTag(item))
        setText(0, string.icon_tag);
    else
        setText(0, string.icon_fork);
    setText(1, RefUtils.getName(item));
    setChecked(2, selected == position);
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:10,代码来源:RefDialogFragment.java


示例8: load

import org.eclipse.egit.github.core.Reference; //导入依赖的package包/类
private void load(final Reference selectedRef) {
    new ProgressDialogTask<List<Reference>>(activity) {

        @Override
        public List<Reference> run(Account account) throws Exception {
            List<Reference> allRefs = service.getReferences(repository);
            Map<String, Reference> loadedRefs = new TreeMap<String, Reference>(
                    CASE_INSENSITIVE_ORDER);
            for (Reference ref : allRefs)
                if (RefUtils.isValid(ref))
                    loadedRefs.put(ref.getRef(), ref);
            refs = loadedRefs;
            return allRefs;
        }

        @Override
        protected void onSuccess(List<Reference> all) throws Exception {
            super.onSuccess(all);

            show(selectedRef);
        }

        @Override
        protected void onException(Exception e) throws RuntimeException {
            super.onException(e);

            Log.d(TAG, "Exception loading references", e);
            ToastUtils.show(activity, e, string.error_refs_load);
        }

        @Override
        public void execute() {
            showIndeterminate(string.loading_refs);

            super.execute();
        }
    }.execute();
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:39,代码来源:RefDialog.java


示例9: show

import org.eclipse.egit.github.core.Reference; //导入依赖的package包/类
/**
 * Show dialog with given reference selected
 *
 * @param selectedRef
 */
public void show(Reference selectedRef) {
    if (refs == null || refs.isEmpty()) {
        load(selectedRef);
        return;
    }

    final ArrayList<Reference> refList = new ArrayList<Reference>(
            refs.values());
    int checked = -1;
    if (selectedRef != null) {
        String ref = selectedRef.getRef();
        for (int i = 0; i < refList.size(); i++) {
            String candidate = refList.get(i).getRef();
            if (ref.equals(candidate)) {
                checked = i;
                break;
            } else if (ref.equals(RefUtils.getName(candidate))) {
                checked = i;
                break;
            }
        }
    }

    RefDialogFragment.show(activity, requestCode,
            activity.getString(string.select_ref), null, refList, checked);
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:32,代码来源:RefDialog.java


示例10: onOptionsItemSelected

import org.eclipse.egit.github.core.Reference; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case id.m_refresh:
        if (tree != null)
            refreshTree(new Reference().setRef(tree.reference.getRef()));
        else
            refreshTree(null);
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:14,代码来源:RepositoryCodeFragment.java


示例11: isBranch

import org.eclipse.egit.github.core.Reference; //导入依赖的package包/类
/**
 * Is reference a branch?
 *
 * @param ref
 * @return true if branch, false otherwise
 */
public static boolean isBranch(final Reference ref) {
    if (ref != null) {
        String name = ref.getRef();
        return !TextUtils.isEmpty(name) && name.startsWith(PREFIX_HEADS);
    } else
        return false;
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:14,代码来源:RefUtils.java


示例12: getPath

import org.eclipse.egit.github.core.Reference; //导入依赖的package包/类
/**
 * Get path of ref with leading 'refs/' segment removed if present
 *
 * @param ref
 * @return full path
 */
public static String getPath(final Reference ref) {
    if (ref == null)
        return null;
    String name = ref.getRef();
    if (!TextUtils.isEmpty(name) && name.startsWith(PREFIX_REFS))
        return name.substring(PREFIX_REFS.length());
    else
        return name;
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:16,代码来源:RefUtils.java


示例13: getName

import org.eclipse.egit.github.core.Reference; //导入依赖的package包/类
/**
 * Get short name for ref
 *
 * @param ref
 * @return short name
 */
public static String getName(final Reference ref) {
    if (ref != null)
        return getName(ref.getRef());
    else
        return null;
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:13,代码来源:RefUtils.java


示例14: RefreshTreeTask

import org.eclipse.egit.github.core.Reference; //导入依赖的package包/类
/**
 * Create task to refresh repository's tree
 *
 * @param repository
 * @param reference
 * @param context
 */
public RefreshTreeTask(final Repository repository,
        final Reference reference, final Context context) {
    super(context);

    this.repository = repository;
    this.reference = reference;
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:15,代码来源:RefreshTreeTask.java


示例15: run

import org.eclipse.egit.github.core.Reference; //导入依赖的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);
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:34,代码来源:RefreshTreeTask.java


示例16: FullTree

import org.eclipse.egit.github.core.Reference; //导入依赖的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);
}
 
开发者ID:huibinfeng0810,项目名称:github-v2,代码行数:18,代码来源:FullTree.java


示例17: getReferences

import org.eclipse.egit.github.core.Reference; //导入依赖的package包/类
/**
 * Get references for given repository
 *
 * @param repository
 * @return non-null but possibly empty list of references
 * @throws IOException
 */
public List<Reference> getReferences(IRepositoryIdProvider repository)
		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_REFS);
	PagedRequest<Reference> request = createPagedRequest();
	request.setType(new TypeToken<List<Reference>>() {
	}.getType());
	request.setUri(uri);
	return getAll(request);
}
 
开发者ID:tsangiotis,项目名称:JekyllForAndroid,代码行数:22,代码来源:DataService.java


示例18: editReference

import org.eclipse.egit.github.core.Reference; //导入依赖的package包/类
/**
 * Edit reference
 *
 * @param repository
 * @param reference
 * @param force
 * @return updated reference
 * @throws IOException
 */
public Reference editReference(IRepositoryIdProvider repository,
		Reference reference, boolean force) throws IOException {
	final String id = getId(repository);
	if (reference == null)
		throw new IllegalArgumentException("Reference cannot be null"); //$NON-NLS-1$
	TypedResource object = reference.getObject();
	if (object == null)
		throw new IllegalArgumentException("Object cannot be null"); //$NON-NLS-1$
	String ref = reference.getRef();
	if (ref == null)
		throw new IllegalArgumentException("Ref cannot be null"); //$NON-NLS-1$
	if (ref.length() == 0)
		throw new IllegalArgumentException("Ref cannot be empty"); //$NON-NLS-1$

	StringBuilder uri = new StringBuilder();
	uri.append(SEGMENT_REPOS);
	uri.append('/').append(id);
	uri.append(SEGMENT_GIT);
	if (!ref.startsWith("refs/")) //$NON-NLS-1$
		uri.append(SEGMENT_REFS);
	uri.append('/').append(ref);
	Map<String, Object> params = new HashMap<String, Object>();
	params.put("sha", object.getSha()); //$NON-NLS-1$
	if (force)
		params.put("force", true); //$NON-NLS-1$
	return client.post(uri.toString(), params, Reference.class);
}
 
开发者ID:tsangiotis,项目名称:JekyllForAndroid,代码行数:37,代码来源:DataService.java


示例19: createRepositoryBranch

import org.eclipse.egit.github.core.Reference; //导入依赖的package包/类
private void createRepositoryBranch(Repository repo,String refString,String accessToken) throws Exception
{
	DataService dService=new DataService();
	dService.getClient().setOAuth2Token(accessToken);
	List<Reference> refList=dService.getReferences(repo);
	Reference ref=refList.get(0);
	ref.setRef(refString);
	logger.info("Try to create branch {}",refString);
	dService.createReference(repo, ref);
}
 
开发者ID:GitHubPager,项目名称:GitHubPager,代码行数:11,代码来源:PageManager.java


示例20: commitFileToRepository

import org.eclipse.egit.github.core.Reference; //导入依赖的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);
}
 
开发者ID:GitHubPager,项目名称:GitHubPager,代码行数:30,代码来源:PageManager.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ColorMode类代码示例发布时间:2022-05-23
下一篇:
Java WeakCache类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap