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


Java RepositoryId类代码示例

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


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

示例1: getCollaborators_validRepoId_successful

import org.eclipse.egit.github.core.RepositoryId; //导入依赖的package包/类
@Test
public void getCollaborators_validRepoId_successful() throws IOException {
    MockServerClient mockServer = ClientAndServer.startClientAndServer(8888);
    String sampleCollaborators = TestUtils.readFileFromResource(this, "tests/CollaboratorsSample.json");

    mockServer.when(
            request()
                .withPath(TestUtils.API_PREFIX + "/repos/hubturbo/tests/collaborators")
    ).respond(response().withBody(sampleCollaborators));

    Type listOfUsers = new TypeToken<List<User>>() {}.getType();
    List<User> expectedCollaborators = new Gson().fromJson(sampleCollaborators, listOfUsers);
    List<User> actualCollaborators = service.getCollaborators(RepositoryId.createFromId("hubturbo/tests"));

    assertEquals(expectedCollaborators.size(), actualCollaborators.size());

    for (int i = 0; i < expectedCollaborators.size(); i++) {
        assertEquals(expectedCollaborators.get(i).getLogin(), actualCollaborators.get(i).getLogin());
        assertEquals(expectedCollaborators.get(i).getName(), actualCollaborators.get(i).getName());
        assertEquals(true, actualCollaborators.get(i).getName() != null);
    }

    mockServer.stop();
}
 
开发者ID:HubTurbo,项目名称:HubTurbo,代码行数:25,代码来源:CollaboratorServiceExTests.java

示例2: getCollaborators

import org.eclipse.egit.github.core.RepositoryId; //导入依赖的package包/类
public static List<String> getCollaborators(@Nonnull final Job<?,?> job) {
    ExtendedGitHubClient client = getGitHubClient(job);
    RepositoryId repository = getRepositoryId(job);
    CollaboratorService collaboratorService = new CollaboratorService(client);

    try {
        return collaboratorService.getCollaborators(repository)
                .stream()
                .map(User::getLogin)
                .collect(Collectors.toList());
    } catch (final IOException e) {
        LOG.debug("Received an exception while trying to retrieve the collaborators for the repository: {}",
                repository, e);
        return Collections.emptyList();
    }
}
 
开发者ID:aaronjwhiteside,项目名称:pipeline-github,代码行数:17,代码来源:GitHubHelper.java

示例3: PullRequestGroovyObject

import org.eclipse.egit.github.core.RepositoryId; //导入依赖的package包/类
public PullRequestGroovyObject(@Nonnull final CpsScript script) throws Exception {
    this.script = script;
    Run<?, ?> build = script.$build();
    if (build == null) {
        throw new IllegalStateException("No associated build");
    }
    Job job = build.getParent();

    this.pullRequestHead = GitHubHelper.getPullRequest(job);

    this.base = GitHubHelper.getRepositoryId(job);
    this.head = RepositoryId.create(pullRequestHead.getSourceOwner(), pullRequestHead.getSourceRepo());

    this.gitHubClient = GitHubHelper.getGitHubClient(job);
    this.pullRequestService = new ExtendedPullRequestService(gitHubClient);
    this.issueService = new ExtendedIssueService(gitHubClient);
    this.commitService = new ExtendedCommitService(gitHubClient);
    this.pullRequest = pullRequestService.getPullRequest(base, pullRequestHead.getNumber());
}
 
开发者ID:aaronjwhiteside,项目名称:pipeline-github,代码行数:20,代码来源:PullRequestGroovyObject.java

示例4: importCommits

import org.eclipse.egit.github.core.RepositoryId; //导入依赖的package包/类
public void importCommits(ProjectEvent projectEvent) throws IOException {
    Project project = projectService.getProject(projectEvent.getProjectId());
    Assert.notNull(project, "Could not find project with the provided id");

    // Get GitHub repository commits
    RepositoryId repositoryId = new RepositoryId(project.getOwner(), project.getName());
    List<RepositoryCommit> repositoryCommits = gitTemplate.commitService().getCommits(repositoryId);

    Flux<Commit> commits;

    commits = Flux.fromStream(repositoryCommits.stream()).map(c -> {
        try {
            log.info("Importing commit: " + repositoryId.getName() + " -> " + c.getSha());
            return gitTemplate.commitService().getCommit(repositoryId, c.getSha());
        } catch (IOException e) {
            throw new RuntimeException("Could not get commit", e);
        }
    }).filter(a -> a.getFiles() != null && a.getFiles().size() < 10)
            .map(a -> new Commit(a.getFiles().stream()
                    .map(f -> new File(f.getFilename())).collect(Collectors.toList()),
                    a.getCommit().getCommitter().getName(),
                    a.getCommit().getCommitter().getDate().getTime()))
            .sort(Comparator.comparing(Commit::getCommitDate));

    commits.subscribe(commit -> saveCommits(project, commit));
}
 
开发者ID:kbastani,项目名称:service-block-samples,代码行数:27,代码来源:CommitProcessor.java

示例5: createBlob

import org.eclipse.egit.github.core.RepositoryId; //导入依赖的package包/类
protected static String createBlob(DataService service, RepositoryId repository, String prefix, String path)
		throws Exception {
	File file = new File(prefix, path);
	final long length = file.length();
	final int size = length > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) length;
	ByteArrayOutputStream output = new ByteArrayOutputStream(size);
	FileInputStream stream = new FileInputStream(file);
	try {

		final byte[] buffer = new byte[8192];
		int read;
		while ((read = stream.read(buffer)) != -1)
			output.write(buffer, 0, read);
		Blob blob = new Blob().setEncoding(Blob.ENCODING_BASE64);
		String encoded = EncodingUtils.toBase64(output.toByteArray());
		blob.setContent(encoded);
		return service.createBlob(repository, blob);
	} finally {
		stream.close();
	}
}
 
开发者ID:OnPositive,项目名称:aml,代码行数:22,代码来源:PublishHelper.java

示例6: save

import org.eclipse.egit.github.core.RepositoryId; //导入依赖的package包/类
@SneakyThrows
public void save(PullRequestStatus commitStatus) {

	String repoId = commitStatus.getRepoId();
	String accessToken = commitStatus.getAccessToken();
	if (accessToken == null) {
		return;
	}

	PullRequestId pullRequestId = PullRequestId.of(RepositoryId.createFromId(repoId), commitStatus.getPullRequestId());

	boolean hasSignedCla = commitStatus.isSuccess();
	GitHubClient client = createClient(accessToken);

	String claUserLogin = getGitHubClaUserLogin();
	List<Comment> comments = getComments(pullRequestId, getIssueService());

	boolean obviousFix = isObviousFix(pullRequestId, comments, claUserLogin, commitStatus.getPullRequestBody());

	ContextCommitStatus status = createCommitStatusIfNecessary(pullRequestId, commitStatus, hasSignedCla, obviousFix, client);
	createOrUpdatePullRequestComment(pullRequestId, commitStatus, hasSignedCla, obviousFix, status, comments, claUserLogin);
}
 
开发者ID:pivotalsoftware,项目名称:pivotal-cla,代码行数:23,代码来源:MylynGitHubApi.java

示例7: getShaForPullRequest

import org.eclipse.egit.github.core.RepositoryId; //导入依赖的package包/类
@SneakyThrows
public String getShaForPullRequest(PullRequestStatus commitStatus) {
	String repositoryId = commitStatus.getRepoId();
	int pullRequestId = commitStatus.getPullRequestId();
	String currentUserGitHubLogin = commitStatus.getGitHubUsername();

	String accessToken = commitStatus.getAccessToken();
	if (accessToken == null) {
		return null;
	}
	GitHubClient client = createClient(accessToken);
	RepositoryId id = RepositoryId.createFromId(repositoryId);

	PullRequestService service = new PullRequestService(client);
	PullRequest pullRequest = service.getPullRequest(id, pullRequestId);
	String githubLoginForContributor = pullRequest.getUser().getLogin();
	if(commitStatus.isAdmin()) {
		commitStatus.setGitHubUsername(githubLoginForContributor);
	}else if (!githubLoginForContributor.equals(currentUserGitHubLogin)) {
		return null;
	}

	return pullRequest.getHead().getSha();
}
 
开发者ID:pivotalsoftware,项目名称:pivotal-cla,代码行数:25,代码来源:MylynGitHubApi.java

示例8: findAssociatedClaNames

import org.eclipse.egit.github.core.RepositoryId; //导入依赖的package包/类
@Override
@SneakyThrows
public Set<String> findAssociatedClaNames(String repoId, String accessToken) {

	GitHubClient client = createClient(accessToken);
	RepositoryService service = new RepositoryService(client);

	RepositoryId repositoryId = RepositoryId.createFromId(repoId);

	List<RepositoryHook> hooks = service.getHooks(repositoryId);
	Set<String> claNames = hooks.stream() //
			.filter(h -> StringUtils.hasText(h.getConfig().get("url"))) //
			.filter(RepositoryHook::isActive) //
			.map(h -> h.getConfig().get("url")) //
			.filter(PULL_REQUEST_CALLBACK_PATTERN.asPredicate()) //
			.map(url -> getClaName(url, PULL_REQUEST_CALLBACK_PATTERN)) //
			.collect(Collectors.toSet());

	return claNames;
}
 
开发者ID:pivotalsoftware,项目名称:pivotal-cla,代码行数:21,代码来源:MylynGitHubApi.java

示例9: findPullRequest

import org.eclipse.egit.github.core.RepositoryId; //导入依赖的package包/类
@Override
@SneakyThrows
public Optional<PullRequest> findPullRequest(String repoId, int pullRequestId, String accessToken) {

	GitHubClient client = createClient(accessToken);
	PullRequestService service = new PullRequestService(client);

	try {
		return Optional.ofNullable(service.getPullRequest(RepositoryId.createFromId(repoId), pullRequestId));
	}
	catch (RequestException e) {

		if(e.getStatus() == HttpStatus.NOT_FOUND.value()){
			return Optional.empty();
		}

		throw e;
	}
}
 
开发者ID:pivotalsoftware,项目名称:pivotal-cla,代码行数:20,代码来源:MylynGitHubApi.java

示例10: fork

import org.eclipse.egit.github.core.RepositoryId; //导入依赖的package包/类
/**
 * Forks provided repository into the {@link #ORGANIZATION}. The forked repository will be automatically destroyed
 * after test finished.
 *
 * @param lifetime validity of repository (when it should be clean up)
 * @param expirationDuration duration (expiration time), when can be removed the repository, even by some other test
 * (if cleaning of repository failed, this can be used by cleaning retry)
 */
public void fork(String owner, String repositoryOwner, String repositoryName, Lifetime lifetime, int expirationDuration)
{
    GitHubClient gitHubClient = getGitHubClient(owner);
    RepositoryService repositoryService = new RepositoryService(gitHubClient);

    try
    {
        Repository repository = repositoryService.forkRepository(RepositoryId.create(repositoryOwner, repositoryName),
                gitHubClient.getUser().equals(owner) ? null : owner);

        // wait until forked repository is prepared
        final Repository newRepository = waitTillRepositoryIsReady(repositoryService, repository);

        RepositoryContext repositoryContext = new RepositoryContext(owner, newRepository);
        repositoryByLifetime.get(lifetime).add(repositoryContext);
        repositoryBySlug.put(getSlug(owner, repositoryName), repositoryContext);
    }
    catch (IOException e)
    {
        throw new RuntimeException(e);
    }
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:31,代码来源:GitHubTestSupport.java

示例11: getFileDetails

import org.eclipse.egit.github.core.RepositoryId; //导入依赖的package包/类
@Override
public ChangesetFileDetailsEnvelope getFileDetails(Repository repository, Changeset changeset)
{
    CommitService commitService = githubClientProvider.getCommitService(repository);
    RepositoryId repositoryId = RepositoryId.create(repository.getOrgName(), repository.getSlug());

    // Workaround for BBC-455
    checkRequestRateLimit(commitService.getClient());
    try
    {
        RepositoryCommit commit = commitService.getCommit(repositoryId, changeset.getNode());

        return new ChangesetFileDetailsEnvelope(GithubChangesetFactory.transformToFileDetails(commit.getFiles()), commit.getFiles().size());
    }
    catch (IOException e)
    {
        throw new SourceControlException("could not get result", e);
    }
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:20,代码来源:GithubCommunicator.java

示例12: processPullRequestComments

import org.eclipse.egit.github.core.RepositoryId; //导入依赖的package包/类
/**
 * Processes comments of a Pull Request.
 */
private void processPullRequestComments(Repository repository, PullRequest remotePullRequest,
        RepositoryPullRequestMapping localPullRequest, Map<String, Participant> participantIndex)
{
    updateCommentsCount(remotePullRequest, localPullRequest);

    IssueService issueService = gitHubClientProvider.getIssueService(repository);
    RepositoryId repositoryId = RepositoryId.createFromUrl(repository.getRepositoryUrl());
    List<Comment> pullRequestComments;
    try
    {
        pullRequestComments = issueService.getComments(repositoryId, remotePullRequest.getNumber());
    }
    catch (IOException e)
    {
        throw new RuntimeException(e);
    }

    remotePullRequest.setComments(Math.max(remotePullRequest.getComments(), pullRequestComments.size()));

    for (Comment comment : pullRequestComments)
    {
        addParticipant(participantIndex, comment.getUser(), Participant.ROLE_PARTICIPANT);
    }
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:28,代码来源:GitHubPullRequestProcessor.java

示例13: processPullRequestReviewComments

import org.eclipse.egit.github.core.RepositoryId; //导入依赖的package包/类
/**
 * Processes review comments of a Pull Request.
 */
private void processPullRequestReviewComments(Repository repository, PullRequest remotePullRequest,
        RepositoryPullRequestMapping localPullRequest, Map<String, Participant> participantIndex)
{
    updateCommentsCount(remotePullRequest, localPullRequest);

    PullRequestService pullRequestService = gitHubClientProvider.getPullRequestService(repository);
    RepositoryId repositoryId = RepositoryId.createFromUrl(repository.getRepositoryUrl());
    List<CommitComment> pullRequestReviewComments;
    try
    {
        pullRequestReviewComments = pullRequestService.getComments(repositoryId, remotePullRequest.getNumber());
    }
    catch (IOException e)
    {
        throw new RuntimeException(e);
    }

    remotePullRequest.setReviewComments(Math.max(remotePullRequest.getReviewComments(), pullRequestReviewComments.size()));

    for (CommitComment comment : pullRequestReviewComments)
    {
        addParticipant(participantIndex, comment.getUser(), Participant.ROLE_PARTICIPANT);
    }
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:28,代码来源:GitHubPullRequestProcessor.java

示例14: getPreviousLoginDetails

import org.eclipse.egit.github.core.RepositoryId; //导入依赖的package包/类
public void getPreviousLoginDetails() {
    Optional<RepositoryId> lastViewedRepository = logic.prefs.getLastViewedRepository();
    TreeSet<String> storedRepos = new TreeSet<>(logic.getStoredRepos());
    if (lastViewedRepository.isPresent() &&
            storedRepos.contains(RepositoryId.create(
                    lastViewedRepository.get().getOwner(),
                    lastViewedRepository.get().getName()).generateId())) {
        owner = lastViewedRepository.get().getOwner();
        repo = lastViewedRepository.get().getName();
    } else if (!storedRepos.isEmpty()) {
        RepositoryId repositoryId = RepositoryId.createFromId(storedRepos.first());
        owner = repositoryId.getOwner();
        repo = repositoryId.getName();
    }
    username = logic.prefs.getLastLoginUsername();
    password = logic.prefs.getLastLoginPassword();
}
 
开发者ID:HubTurbo,项目名称:HubTurbo,代码行数:18,代码来源:LoginController.java

示例15: updateCollaborators_outdatedETag_collaboratorsCompleteDataRetrieved

import org.eclipse.egit.github.core.RepositoryId; //导入依赖的package包/类
@Test
public void updateCollaborators_outdatedETag_collaboratorsCompleteDataRetrieved() {
    GitHubClientEx gitHubClient = new GitHubClientEx("localhost", 8888, "http");
    UserUpdateService service = new UserUpdateService(gitHubClient, "9332ee96a4e41dfeebfd36845e861096");

    List<User> expected = new ArrayList<>();
    Type userType = new TypeToken<User>() {}.getType();
    expected.addAll(Arrays.asList(new Gson().fromJson(user1, userType),
                                  new Gson().fromJson(user2, userType),
                                  new Gson().fromJson(user3, userType)));
    List<User> actual = service.getUpdatedItems(RepositoryId.createFromId("HubTurbo/tests"));

    assertEquals(expected.size(), actual.size());
    for (int i = 0; i < expected.size(); i++) {
        assertEquals(expected.get(i).getLogin(), actual.get(i).getLogin());
        assertEquals(expected.get(i).getName(), actual.get(i).getName());
    }
}
 
开发者ID:HubTurbo,项目名称:HubTurbo,代码行数:19,代码来源:UserUpdateServiceTests.java


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