當前位置: 首頁>>代碼示例>>Java>>正文


Java GHRepository.getDirectoryContent方法代碼示例

本文整理匯總了Java中org.kohsuke.github.GHRepository.getDirectoryContent方法的典型用法代碼示例。如果您正苦於以下問題:Java GHRepository.getDirectoryContent方法的具體用法?Java GHRepository.getDirectoryContent怎麽用?Java GHRepository.getDirectoryContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.kohsuke.github.GHRepository的用法示例。


在下文中一共展示了GHRepository.getDirectoryContent方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: deleteContentsDir

import org.kohsuke.github.GHRepository; //導入方法依賴的package包/類
/**
 * �ݹ麯��. ɾ��github����ָ�����ļ���
 * @param repo github�����
 * @param strDirectory github������ļ���·��
 * @return void
 */
private void deleteContentsDir(GHRepository repo, String strDirectory){
	try {
		List<GHContent> lContents = repo.getDirectoryContent(strDirectory);
		Iterator<GHContent> it = lContents.iterator();
		while(it.hasNext()){
			GHContent content = it.next();
			if(content.isDirectory())
				deleteContentsDir(repo, content.getPath());
			else{
				content.delete("delete dir");
				System.out.println("Deleted!\t" + content.getPath());
			}
		}
	} catch (IOException e) {
		// TODO Auto-generated catch block
		//e.printStackTrace();
		errHandle(e.getMessage());
	}
}
 
開發者ID:appbank2020,項目名稱:GitRobot,代碼行數:26,代碼來源:GitRobot.java

示例2: commit

import org.kohsuke.github.GHRepository; //導入方法依賴的package包/類
public static void commit(String rep,String content,String commitmsg,String path,boolean isAdd){
	try{
	GitHub github = GitHub.connectUsingPassword("[email protected]", "xiaomin0322#####");
	GHRepository repo =github.getRepository(rep);
	
	GHContent contentObj = null;
	if(isAdd){
		List<GHContent> contents = repo.getDirectoryContent("/");
		if(CollectionUtils.isNotEmpty(contents)){
			for(GHContent c:contents){
				String name = c.getName();
				System.out.println("name==="+name);
				if(path.equals(name)){
					System.out.println("找到目標文件");
					contentObj = c;
				}
			}
		}
	}
	if(contentObj==null){
		System.out.println("創建文件>>>>>>>>>>>>>>>>>>>>>");
		repo.createContent(content,commitmsg, path);
		//contentObj = repo.getFileContent(path);
	}
	if(isAdd){
          StringBuilder builder = new StringBuilder();
		String str = IOUtils.toString(contentObj.read());
		System.out.println("獲取遠程內容為:"+str);
		builder.append(str).append("\r\n");
		builder.append(content);
		contentObj.update(builder.toString(), commitmsg);
	}
	
	System.out.println("提交成功>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
	}catch(Exception e){
		System.out.println("提交出現異常>>>>>>>>>>>>>>>>>>>>>>>>>");
		e.printStackTrace();
	}
	
}
 
開發者ID:xiaomin0322,項目名稱:alimama,代碼行數:41,代碼來源:GitHubUtils.java

示例3: getContents

import org.kohsuke.github.GHRepository; //導入方法依賴的package包/類
/**
 * �Ӹ�repository����������Դ
 * @param strRepoName github����
 * @param strLocalPath �����ļ���·��
 * @return void
 */
public void getContents(String strRepoName, String strRemotePath, String strLocalPath){
	GitHub github;
	GHRepository repo;
	try {
		if(strLocalPath.charAt(strLocalPath.length()-1) != '\\')
			strLocalPath += "\\";
		System.out.println("Download started!\t"+strRepoName + "/" + strRemotePath+" => " + strLocalPath);
		github = GitHub.connectToEnterprise(getApiUrl(), getUserId(), getPassword());
		
		repo = github.getRepository( strRepoName);
		List<GHContent> contents = repo.getDirectoryContent(strRemotePath);
		Iterator it = contents.iterator();
		while(it.hasNext()){
			GHContent content = (GHContent)it.next();
			if(content.isDirectory()){
				getRepoDirectory(content, strRemotePath, strLocalPath);
			}
			else {
				String strFileName = strLocalPath + content.getName();
			
				if(content.getDownloadUrl() != null && content.getSize() < 1024 * 1024){
					writeFile(content.read(), strFileName);
				}
				else if(content.getGitUrl() != null){
					writeFileFromGitUrl(content.getGitUrl(), strFileName);
				}
			}
		}
		System.out.println("Download finished!");

	} catch(FileNotFoundException e1){
		System.out.println("Error:"+e1.getCause().getMessage()+"��Դ������");
		System.exit(0);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		errHandle(e.getMessage());
	}
	bFinished = true;
}
 
開發者ID:appbank2020,項目名稱:GitRobot,代碼行數:46,代碼來源:GitRobot.java

示例4: deleteContents

import org.kohsuke.github.GHRepository; //導入方法依賴的package包/類
/**
 * ��ָ����repo����ɾ��ָ�����ļ���
 * @param strRepoName github����
 * @param strDirectory Ҫɾ�����ļ���
 * @return void
 */
public void deleteContents(String strRepoName, String strDirectory){
	GitHub github;
	GHRepository repo;
	try {
		System.out.println("Delete started!\t"+strRepoName+"/" + strDirectory);
		github = GitHub.connectToEnterprise(getApiUrl(), getUserId(), getPassword());
		
		repo = github.getRepository(strRepoName);
		List<GHContent> lContents = null;
		try{
			lContents = repo.getDirectoryContent(strDirectory);
			Iterator<GHContent> it = lContents.iterator();
			while(it.hasNext()){
				GHContent content = it.next();
				if(content.isDirectory()){
					deleteContentsDir(repo, content.getPath());
					//content.delete("delete dir");
				}
				else{
					System.out.println("Deleted!\t" + content.getPath());
					content.delete("delete dir");
				}
			}
		}
		catch(FileNotFoundException ex){
			System.out.println(strDirectory + " does not exists.");
		}
		System.out.println("Delete finished!");
	} catch (Exception e) {
		// TODO Auto-generated catch block
		errHandle(e.getMessage());
	}
	bFinished = true;
}
 
開發者ID:appbank2020,項目名稱:GitRobot,代碼行數:41,代碼來源:GitRobot.java

示例5: getReferences

import org.kohsuke.github.GHRepository; //導入方法依賴的package包/類
private List<String> getReferences(GHRepository repository) throws IOException {
  ArrayList<String> references = new ArrayList<String>();
  List<GHContent> directoryContent = repository.getDirectoryContent("Reference");
  for (GHContent content : directoryContent) {
    String name = content.getName();
    String type = content.getType();
    if ("file".equals(type) && name.matches("[A-C]\\.[1-9][0-9]*\\.[0-9]+.bpmn")) {
      references.add(name.replace(".bpmn", ""));
    }
  }
  LOGGER.info("References: " + references);
  return references;
}
 
開發者ID:bpmn-miwg,項目名稱:bpmn-miwg-tools,代碼行數:14,代碼來源:RepoScanner.java

示例6: getSubmissionsFromRootDir

import org.kohsuke.github.GHRepository; //導入方法依賴的package包/類
private JSONObject getSubmissionsFromRootDir(GHRepository repository) throws IOException {
  LOGGER.info("Scanning: " + repository.getName());
  JSONObject submissions = new JSONObject();
  List<GHContent> directoryContent = repository.getDirectoryContent("/");
  for (GHContent content : directoryContent) {
    String name = content.getName();
    String type = content.getType();
    if ("dir".equals(type) && !"Reference".equals(name) && !"Work in Progress".equals(name)) {
      getSubmissionsFromToolDir(submissions, repository, content.getPath());
    }
  }
  return submissions;
}
 
開發者ID:bpmn-miwg,項目名稱:bpmn-miwg-tools,代碼行數:14,代碼來源:RepoScanner.java

示例7: getSubmissionsFromToolDir

import org.kohsuke.github.GHRepository; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private void getSubmissionsFromToolDir(JSONObject submissions, GHRepository repository,
    String tool) throws IOException {
  LOGGER.info("Scanning: " + repository.getName() + "/" + tool);
  int count = 0;
  int countA = 0;
  int countB = 0;
  int countC = 0;
  JSONArray files = new JSONArray();
  List<GHContent> directoryContent = repository.getDirectoryContent(tool.replace(" ", "%20"));
  for (GHContent content : directoryContent) {
    String name = content.getName();
    String type = content.getType();
    for (String testCase : testCases) {
      if ("file".equals(type)) {
        if (name.matches(testCase + "-(import.png|roundtrip.bpmn|export.png|export.bpmn)")) {
          count++;
          if (name.startsWith("A")) countA++;
          if (name.startsWith("B")) countB++;
          if (name.startsWith("C")) countC++;
          files.add(name);
          break;
        } else if (name.startsWith(testCase)) {
          LOGGER.warning("[" + tool + "] File '" + name + "' does not match the naming conventions.");
        }
      }
    }
  }
  JSONObject submission = new JSONObject();
  submission.put("count", count);
  submission.put("countA", countA);
  submission.put("countB", countB);
  submission.put("countC", countC);
  submission.put("files", files);
  submissions.put(tool, submission);
}
 
開發者ID:bpmn-miwg,項目名稱:bpmn-miwg-tools,代碼行數:37,代碼來源:RepoScanner.java

示例8: getSingleContent

import org.kohsuke.github.GHRepository; //導入方法依賴的package包/類
/**
 * ���ص����ļ�
 * @param strRepoName �ֿ���
 * @param strRemoteFilePathWithName Զ�̿������Դ·��������src/test.txt)
 * @param strLocalFilePath Ҫ���ص��ı���·������Ҫ�����ļ���
 * @return void
 */
public void getSingleContent(String strRepoName, String strRemoteFilePathWithName, String strLocalFilePath){
	GitHub github;
	GHRepository repo;
	try {
		if(strLocalFilePath.charAt(strLocalFilePath.length()-1) != '\\')
			strLocalFilePath += "\\";
		System.out.println("Download started!\t"+strRepoName+"/"+strRemoteFilePathWithName+" => " + strLocalFilePath);
		github = GitHub.connectToEnterprise(getApiUrl(), getUserId(), getPassword());
		
		int nLastSlashPos = strRemoteFilePathWithName.lastIndexOf('/');
		String strRemotePath = nLastSlashPos <= 0 ? "" : strRemoteFilePathWithName.substring(0, nLastSlashPos);
		String strRemoteFileName = nLastSlashPos == -1 ? strRemoteFilePathWithName : strRemoteFilePathWithName.substring(nLastSlashPos+1);
		repo = github.getRepository(strRepoName);
		List<GHContent> contents = repo.getDirectoryContent(strRemotePath);
		Iterator it = contents.iterator();
		boolean bDownloaded = false;
		while(it.hasNext()){
			GHContent content = (GHContent)it.next();
			if(content.getName().equalsIgnoreCase(strRemoteFileName)){
				if(content.isDirectory()){
					errHandle("This is a directory.");
					return;
				}
				else{
					String strFileName = strLocalFilePath + content.getName();
					if(content.getDownloadUrl() != null && content.getSize() < 1024 * 1024){
						writeFile(content.read(), strFileName);
						bDownloaded = true;
					}
					else if(content.getGitUrl() != null){
						writeFileFromGitUrl(content.getGitUrl(), strFileName);
						bDownloaded = true;
					}
				}
			}
		}
		if(bDownloaded)
			System.out.println("Download finished!");
		else
			errHandle("��Ŀ¼");
	} catch(FileNotFoundException e1){
		System.out.println("Error:"+e1.getCause().getMessage()+"��Դ������");
		System.exit(0);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		errHandle(e.getMessage());
	}
	bFinished = true;
}
 
開發者ID:appbank2020,項目名稱:GitRobot,代碼行數:57,代碼來源:GitRobot.java


注:本文中的org.kohsuke.github.GHRepository.getDirectoryContent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。