org.eclipse.egit.github.core.RepositoryContents Java Examples
The following examples show how to use
org.eclipse.egit.github.core.RepositoryContents.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GithubImporter.java From scava with Eclipse Public License 2.0 | 5 votes |
private String getReadmeContent(GitHubClient client, Repository rep) throws Exception { ContentsService contentService = new ContentsService(client); RepositoryContents content = contentService.getReadme(rep); // TODO handle exception String fileConent = content.getContent(); return new String(Base64.decodeBase64(fileConent.getBytes())); }
Example #2
Source File: GithubImporter.java From scava with Eclipse Public License 2.0 | 5 votes |
private List<String> getGradleDependencies(GitHubClient client, Repository rep, List<String> gradlePath) { List<String> result = new ArrayList<>(); ContentsService contentService = new ContentsService(client); for (String gradleFile : gradlePath) { List<RepositoryContents> test; try { test = contentService.getContents(rep, gradleFile); String valueDecoded = ""; for (RepositoryContents content : test) { String fileConent = content.getContent(); valueDecoded = new String(Base64.decodeBase64(fileConent.getBytes())); valueDecoded += System.getProperty("line.separator"); } AstBuilder builder = new AstBuilder(); List<ASTNode> nodes = builder.buildFromString(valueDecoded); DependencyVisitor visitor = new DependencyVisitor(); walkScript(visitor, nodes); List<String> partialResult = visitor.getDependencies(); if (partialResult != null) result.addAll(partialResult); } catch (Exception e) { logger.error(e.getMessage()); } } return result; }
Example #3
Source File: BookmarkItemAdapter.java From Bitocle with Apache License 2.0 | 5 votes |
@Override public View getView( int position, View convertView, ViewGroup viewGroup ) { Holder holder; View view = convertView; if (view == null) { LayoutInflater inflater = ((Activity) context).getLayoutInflater(); view = inflater.inflate(layoutResId, viewGroup, false); holder = new Holder(); holder.icon = (ImageView) view.findViewById(R.id.bookmark_item_icon); holder.title = (TextView) view.findViewById(R.id.bookmark_item_title); holder.date = (TextView) view.findViewById(R.id.bookmark_item_date); holder.content = (TextView) view.findViewById(R.id.bookmark_item_content); holder.owner = (TextView) view.findViewById(R.id.bookmark_item_owner); view.setTag(holder); } else { holder = (Holder) view.getTag(); } if (bookmarkItemList.size() > 0) { BookmarkItem anItem = bookmarkItemList.get(position); holder.icon.setImageDrawable(anItem.getIcon()); holder.title.setText(anItem.getTitle()); holder.date.setText(anItem.getDate()); String str = anItem.getRepoName() + context.getString(R.string.repo_path_root) + anItem.getRepoPath(); if (anItem.getType().equals(RepositoryContents.TYPE_DIR)) { str = str + context.getString(R.string.repo_path_root); } holder.content.setText(str); holder.owner.setText(anItem.getRepoOwner()); } return view; }
Example #4
Source File: ContentItemAdapter.java From Bitocle with Apache License 2.0 | 5 votes |
@Override public View getView( int position, View convertView, ViewGroup viewGroup ) { Holder holder; View view = convertView; if (view == null) { LayoutInflater inflater = ((Activity) context).getLayoutInflater(); view = inflater.inflate(layoutResId, viewGroup, false); holder = new Holder(); holder.icon = (ImageView) view.findViewById(R.id.content_item_icon); holder.title = (TextView) view.findViewById(R.id.content_item_title); holder.info = (TextView) view.findViewById(R.id.content_item_info); view.setTag(holder); } else { holder = (Holder) view.getTag(); } ContentItem anItem = contentItemList.get(position); holder.icon.setImageDrawable(anItem.getIcon()); holder.title.setText(anItem.getTitle()); if (anItem.getType().equals(RepositoryContents.TYPE_DIR)) { holder.info.setText(context.getString(R.string.content_item_info_sharp)); } else { double r = round(anItem.getSize() / 1024); String size = r + " " + context.getString(R.string.content_item_info_kb); holder.info.setText(size); } return view; }
Example #5
Source File: GitHubRepositoryCreationTest.java From tool.accelerate.core with Apache License 2.0 | 4 votes |
private void checkFileExists(ContentsService contentsService, Repository repository, String path) throws IOException { List<RepositoryContents> file = contentsService.getContents(repository, path); assertThat(file, hasSize(1)); assertThat(file.get(0).getSize(), greaterThan(0L)); }
Example #6
Source File: BookmarkTask.java From Bitocle with Apache License 2.0 | 4 votes |
@Override protected Boolean doInBackground(Void... params) { BAction bAction = new BAction(context); try { bAction.openDatabase(true); } catch (SQLException s) { bAction.closeDatabase(); return false; } bookmarkItemList.clear(); List<Bookmark> bookmarkList = bAction.listBookmarks(); for (Bookmark b: bookmarkList) { if (b.getType().equals(RepositoryContents.TYPE_DIR)) { bookmarkItemList.add( new BookmarkItem( context.getResources().getDrawable(R.drawable.ic_type_folder), b.getTitle(), b.getDate(), b.getType(), b.getRepoOwner(), b.getRepoName(), b.getRepoPath(), b.getSha(), b.getKey() ) ); } else { bookmarkItemList.add( new BookmarkItem( context.getResources().getDrawable(R.drawable.ic_type_file), b.getTitle(), b.getDate(), b.getType(), b.getRepoOwner(), b.getRepoName(), b.getRepoPath(), b.getSha(), b.getKey() ) ); } } Collections.sort(bookmarkItemList); bAction.closeDatabase(); return true; }
Example #7
Source File: ContentTask.java From Bitocle with Apache License 2.0 | 4 votes |
@Override protected Boolean doInBackground(Void... params) { if (!repoPath.equals(context.getString(R.string.repo_path_root))) { try { repoPath = URLEncoder.encode(repoPath, context.getString(R.string.content_text_encode)); } catch (UnsupportedEncodingException u) { return false; } } List<RepositoryContents> repositoryContentsList; try { repositoryContentsList = contentsService.getContents(repositoryId, repoPath); } catch (IOException i) { return false; } if (isCancelled()) { return false; } contentItemList.clear(); for (RepositoryContents contents : repositoryContentsList) { if (contents.getType().equals(RepositoryContents.TYPE_DIR)) { contentItemList.add( new ContentItem( context.getResources().getDrawable(R.drawable.ic_type_folder), contents.getName(), contents.getType(), 0, contents.getPath(), contents.getSha() ) ); } else { contentItemList.add( new ContentItem( context.getResources().getDrawable(R.drawable.ic_type_file), contents.getName(), contents.getType(), contents.getSize(), contents.getPath(), contents.getSha() ) ); } } Collections.sort(contentItemList); if (isCancelled()) { return false; } return true; }