当前位置: 首页>>代码示例>>Java>>正文


Java GHContent类代码示例

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


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

示例1: testGetGHContents

import org.kohsuke.github.GHContent; //导入依赖的package包/类
@Test
public void testGetGHContents() throws Exception {
    DockerfileGitHubUtil dockerfileGitHubUtil = mock(DockerfileGitHubUtil.class);

    Parent parent = new Parent();

    GHContent content1 = mock(GHContent.class);
    GHContent content2 = mock(GHContent.class);
    GHContent content3 = mock(GHContent.class);

    PagedSearchIterable<GHContent> contentsWithImage = mock(PagedSearchIterable.class);
    Mockito.when(contentsWithImage.getTotalCount()).thenReturn(3);

    PagedIterator<GHContent> contentsWithImageIterator = mock(PagedIterator.class);
    Mockito.when(contentsWithImageIterator.hasNext()).thenReturn(true, true, true, false);
    Mockito.when(contentsWithImageIterator.next()).thenReturn(content1, content2, content3, null);
    Mockito.when(contentsWithImage.iterator()).thenReturn(contentsWithImageIterator);

    Mockito.when(dockerfileGitHubUtil.findFilesWithImage(anyString(), eq("org"))).thenReturn(contentsWithImage);

    parent.loadDockerfileGithubUtil(dockerfileGitHubUtil);

    assertEquals(parent.getGHContents("org", "image"), contentsWithImage);
}
 
开发者ID:salesforce,项目名称:dockerfile-image-update,代码行数:25,代码来源:ParentTest.java

示例2: readFileContent

import org.kohsuke.github.GHContent; //导入依赖的package包/类
protected String readFileContent(GHContent match, String htmlUrl, String repo) throws IOException {
    final InputStream stream;
    try {
        //noinspection resource
        stream = match.read();
    } catch (IOException e) {
        System.out.println("Could not read content of " + htmlUrl + " of repo " + repo + ": " + e);
        return null;
    }

    String str = IOUtils.toString(stream, "UTF-8");

    // filter out some unwanted matches
    str = str.replaceAll(getExcludeRegex(), "");

    // skip this if the group-tag is not found any more now
    if(!str.contains(GROUP)) {
        //System.out.println("Did not find " + GROUP + " in content of repo " + repo + " at " + htmlUrl);
        return null;
    }
    return str;
}
 
开发者ID:centic9,项目名称:github-version-statistics,代码行数:23,代码来源:BaseSearch.java

示例3: setUp

import org.kohsuke.github.GHContent; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    DebugUtils.setDebug(true);
    DebugUtils.debug("");

    files = new HashMap<>();
    expectedResults = new HashMap<>();
    expectedCoverageTypes = new HashMap<>();

    props = new PropertyReader("host", "username", "password");
    props.setMinCodeCoverage(87.5, false);
    props.setMinCodeCoverage(60.0, true);

    GHContent ghContent = createGHContentMock("");

    repo = mock(GHRepository.class);
    when(repo.getFileContent(anyString())).thenReturn(ghContent);

    whiteList = new WhiteList();

    analyzer = new CodeCoverageAnalyzer(files, props, repo, whiteList);
}
 
开发者ID:hazelcast,项目名称:hazelcast-qa,代码行数:23,代码来源:CodeCoverageAnalyzerTest.java

示例4: getRepoDirectory

import org.kohsuke.github.GHContent; //导入依赖的package包/类
/**
 * �ݹ麯��. ����github����ijһ��Ŀ¼��������Դ������·��
 * @param content github����ijһ��Ŀ¼����
 * @param strPath ����·��
 * @return void
 */
private void getRepoDirectory(GHContent content, String strRemotePath, String strLocalPath){
	try {
		PagedIterable<GHContent> pi = content.listDirectoryContent();
		Iterator<GHContent> it = pi.iterator();
		while(it.hasNext()){
			GHContent content1 = it.next();
			if(content1.isDirectory())
				getRepoDirectory(content1, strRemotePath, strLocalPath);
			else{
				int nPathStartPos = strRemotePath.length()==0 || strRemotePath.charAt(strRemotePath.length()-1)=='/' ? strRemotePath.length() : strRemotePath.length()+1;
				String strFileName = strLocalPath + content1.getPath().substring(nPathStartPos);
				if(content1.getDownloadUrl() != null && content1.getSize() < 1024 * 1024){
					writeFile(content1.read(), strFileName);
				}
				else if(content1.getGitUrl() != null){
					writeFileFromGitUrl(content1.getGitUrl(), strFileName);
				}
			}
		}
	} catch (Exception e) {
		// TODO Auto-generated catch block
		errHandle(e.getMessage());
	}
}
 
开发者ID:appbank2020,项目名称:GitRobot,代码行数:31,代码来源:GitRobot.java

示例5: deleteContentsDir

import org.kohsuke.github.GHContent; //导入依赖的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

示例6: testGHContentsNoOutput

import org.kohsuke.github.GHContent; //导入依赖的package包/类
@Test
public void testGHContentsNoOutput() throws Exception {
    Parent parent = new Parent();

    PagedSearchIterable<GHContent> contentsWithImage = mock(PagedSearchIterable.class);
    Mockito.when(contentsWithImage.getTotalCount()).thenReturn(0);

    DockerfileGitHubUtil dockerfileGitHubUtil = mock(DockerfileGitHubUtil.class);
    Mockito.when(dockerfileGitHubUtil.findFilesWithImage(anyString(), eq("org"))).thenReturn(contentsWithImage);
    parent.loadDockerfileGithubUtil(dockerfileGitHubUtil);

    assertNull(parent.getGHContents("org", "image"));
}
 
开发者ID:salesforce,项目名称:dockerfile-image-update,代码行数:14,代码来源:ParentTest.java

示例7: testForkRepositoriesFound

import org.kohsuke.github.GHContent; //导入依赖的package包/类
@Test
public void testForkRepositoriesFound() throws Exception {
    DockerfileGitHubUtil dockerfileGitHubUtil = mock(DockerfileGitHubUtil.class);

    GHRepository contentRepo1 = mock(GHRepository.class);
    GHRepository contentRepo2 = mock(GHRepository.class);
    GHRepository contentRepo3 = mock(GHRepository.class);

    GHContent content1 = mock(GHContent.class);
    Mockito.when(content1.getOwner()).thenReturn(contentRepo1);
    GHContent content2 = mock(GHContent.class);
    Mockito.when(content2.getOwner()).thenReturn(contentRepo2);
    GHContent content3 = mock(GHContent.class);
    Mockito.when(content3.getOwner()).thenReturn(contentRepo3);

    PagedSearchIterable<GHContent> contentsWithImage = mock(PagedSearchIterable.class);

    PagedIterator<GHContent> contentsWithImageIterator = mock(PagedIterator.class);
    Mockito.when(contentsWithImageIterator.hasNext()).thenReturn(true, true, true, false);
    Mockito.when(contentsWithImageIterator.next()).thenReturn(content1, content2, content3, null);
    Mockito.when(contentsWithImage.iterator()).thenReturn(contentsWithImageIterator);

    Parent parent = new Parent();
    parent.loadDockerfileGithubUtil(dockerfileGitHubUtil);
    parent.forkRepositoriesFound(new HashMap<>(), contentsWithImage);

    Mockito.verify(dockerfileGitHubUtil, times(3)).checkFromParentAndFork(any());
}
 
开发者ID:salesforce,项目名称:dockerfile-image-update,代码行数:29,代码来源:ParentTest.java

示例8: commit

import org.kohsuke.github.GHContent; //导入依赖的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

示例9: search

import org.kohsuke.github.GHContent; //导入依赖的package包/类
@Override
protected void search(GitHub github, Multimap<String, String> versions) throws IOException {
    // start search
    final PagedSearchIterable<GHContent> list = github.searchContent().filename("build.gradle").in("file").language("gradle").q(GROUP_REGEX).list();
    System.out.println("Had: " + list.getTotalCount() + " total results");

    // paginate through results, filtering out interesting files
    processResults(github, versions, list);
}
 
开发者ID:centic9,项目名称:github-version-statistics,代码行数:10,代码来源:GradleBuildSearch.java

示例10: search

import org.kohsuke.github.GHContent; //导入依赖的package包/类
@Override
protected void search(GitHub github, Multimap<String, String> versions) throws IOException {
    // start search
    final PagedSearchIterable<GHContent> list = github.searchContent().filename("pom.xml").in("file").language("maven").q(GROUP_REGEX).list();
    System.out.println("Had: " + list.getTotalCount() + " total results");

    // paginate through results, filtering out interesting files
    processResults(github, versions, list);
}
 
开发者ID:centic9,项目名称:github-version-statistics,代码行数:10,代码来源:MavenPomSearch.java

示例11: processResults

import org.kohsuke.github.GHContent; //导入依赖的package包/类
protected void processResults(GitHub github, Multimap<String, String> versions, Iterable<GHContent> list) throws IOException {
    // try up to three times to cater for some connection issues that
    // we see from time to time
    int retries = 3;
    while(true) {
        try {
            for(GHContent match : list) {
                final String htmlUrl = match.getHtmlUrl();
                String repo = getNonForkRepository(github, htmlUrl);
                if (repo == null) {
                    continue;
                }

                String str = readFileContent(match, htmlUrl, repo);
                if (str == null) {
                    continue;
                }

                parseVersion(versions, htmlUrl, repo, str);
            }

            //noinspection BreakStatement
            break;
        } catch (HttpException e) {
            retries--;

            if(retries <= 0) {
                throw e;
            }

            // retry once more
            System.out.println("Retry " + retries + " after failing to talk to Github");
            e.printStackTrace(System.out);
        }
    }
}
 
开发者ID:centic9,项目名称:github-version-statistics,代码行数:37,代码来源:BaseSearch.java

示例12: addFileFromGitHub

import org.kohsuke.github.GHContent; //导入依赖的package包/类
private void addFileFromGitHub(String fileName) throws Exception {
    URL resource = getClass().getResource(fileName);
    Path path = Paths.get(resource.toURI());
    String fileContent = new String(Files.readAllBytes(path));
    GHContent ghContent = createGHContentMock(fileContent);
    when(repo.getFileContent(HZ_PREFIX + fileName)).thenReturn(ghContent);
}
 
开发者ID:hazelcast,项目名称:hazelcast-qa,代码行数:8,代码来源:CodeCoverageAnalyzerTest.java

示例13: createGHContentMock

import org.kohsuke.github.GHContent; //导入依赖的package包/类
private static GHContent createGHContentMock(String content) throws IOException {
    InputStream stream = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8));

    GHContent ghContent = mock(GHContent.class);
    when(ghContent.read()).thenReturn(stream);
    return ghContent;
}
 
开发者ID:hazelcast,项目名称:hazelcast-qa,代码行数:8,代码来源:CodeCoverageAnalyzerTest.java

示例14: getContents

import org.kohsuke.github.GHContent; //导入依赖的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

示例15: deleteContents

import org.kohsuke.github.GHContent; //导入依赖的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


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