本文整理汇总了Java中org.eclipse.egit.github.core.client.GitHubClient类的典型用法代码示例。如果您正苦于以下问题:Java GitHubClient类的具体用法?Java GitHubClient怎么用?Java GitHubClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GitHubClient类属于org.eclipse.egit.github.core.client包,在下文中一共展示了GitHubClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findRepositoryNamesWithAdminPermission
import org.eclipse.egit.github.core.client.GitHubClient; //导入依赖的package包/类
@Override
@SneakyThrows
public List<String> findRepositoryNamesWithAdminPermission(String accessToken) {
GitHubClient client = createClient(accessToken);
WithPermissionsRepositoryService service = new WithPermissionsRepositoryService(client);
List<WithPermissionsRepository> repositories = service.getPermissionRepositories();
List<String> repoSlugs = new ArrayList<>();
for (WithPermissionsRepository r : repositories) {
if(!r.getPermissions().isAdmin()) {
continue;
}
org.eclipse.egit.github.core.User owner = r.getOwner();
repoSlugs.add(owner.getLogin() + "/" + r.getName());
}
return repoSlugs;
}
示例2: save
import org.eclipse.egit.github.core.client.GitHubClient; //导入依赖的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);
}
示例3: getShaForPullRequest
import org.eclipse.egit.github.core.client.GitHubClient; //导入依赖的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();
}
示例4: findAssociatedClaNames
import org.eclipse.egit.github.core.client.GitHubClient; //导入依赖的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;
}
示例5: findPullRequest
import org.eclipse.egit.github.core.client.GitHubClient; //导入依赖的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;
}
}
示例6: createTestRepository
import org.eclipse.egit.github.core.client.GitHubClient; //导入依赖的package包/类
private static void createTestRepository(User user) throws Exception {
GitHubClient client = createClient(user.getGitHubAccessToken());
RepositoryService repository = new RepositoryService(client);
Repository toCreate = new Repository();
toCreate.setName("cla-test");
RestTemplate rest = new RestTemplate();
try {
rest.delete("https://api.github.com/repos/{owner}/{repo}?access_token={token}", user.getGitHubUsername(), toCreate.getName(), user.getGitHubAccessToken());
}catch(Throwable t) {
t.printStackTrace();
}
repository.createRepository(toCreate);
Thread.sleep(TimeUnit.SECONDS.toMillis(1L));
// we need content to allow forking
Map<String,String> content = new HashMap<>();
content.put("message", "Initial");
content.put("content", "bXkgbmV3IGZpbGUgY29udGVudHM=");
rest.put("https://api.github.com/repos/{owner}/{repo}/contents/README.adoc?access_token={token}", content, user.getGitHubUsername(), toCreate.getName(), user.getGitHubAccessToken());
}
示例7: fork
import org.eclipse.egit.github.core.client.GitHubClient; //导入依赖的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);
}
}
示例8: createRepository
import org.eclipse.egit.github.core.client.GitHubClient; //导入依赖的package包/类
/**
* Creates repository for provided name and appropriate owner.
*
* @param owner of repository
* @param name of repository
* @return created repository
*/
private Repository createRepository(String owner, String name)
{
GitHubClient gitHubClient = getGitHubClient(owner);
RepositoryService repositoryService = new RepositoryService(gitHubClient);
try
{
final Repository createdRepository = createRepositoryForUserOrOrg(owner, name, gitHubClient, repositoryService);
return waitTillRepositoryIsReady(repositoryService, createdRepository);
}
catch (IOException e)
{
throw new RuntimeException(e);
}
}
示例9: build
import org.eclipse.egit.github.core.client.GitHubClient; //导入依赖的package包/类
@Override
public GitHubGovernorClient build(
GitHubGovernorConfiguration governorConfiguration) throws Exception {
Validate.notNull(governorConfiguration, "GitHub governor configuration has to be set.");
this.gitHubGovernorConfiguration = governorConfiguration;
final GitHubClient gitHubClient = new GitHubClient();
if (this.gitHubGovernorConfiguration.getUsername() != null && this.gitHubGovernorConfiguration.getUsername().length() > 0 && this.gitHubGovernorConfiguration.getPassword() != null && this.gitHubGovernorConfiguration.getPassword().length() > 0) {
gitHubClient.setCredentials(this.gitHubGovernorConfiguration.getUsername(), this.gitHubGovernorConfiguration.getPassword());
}
if (this.gitHubGovernorConfiguration.getToken() != null && this.gitHubGovernorConfiguration.getToken().length() > 0) {
gitHubClient.setOAuth2Token(gitHubGovernorConfiguration.getToken());
}
final GitHubGovernorClient gitHubGovernorClient = new GitHubGovernorClient(gitHubClient, gitHubGovernorConfiguration);
gitHubGovernorClient.setGovernorStrategy(new GitHubGovernorStrategy(this.gitHubGovernorConfiguration));
return gitHubGovernorClient;
}
示例10: onPreExecute
import org.eclipse.egit.github.core.client.GitHubClient; //导入依赖的package包/类
@Override
protected void onPreExecute() {
context = fragment.getContentView().getContext();
flag = fragment.getFlag();
adapter = fragment.getRepoItemAdapter();
list = fragment.getRepoItemList();
GitHubClient client = fragment.getClient();
service = new RepositoryService(client);
if (flag == Flag.REPO_FIRST) {
fragment.setContentEmpty(false);
fragment.setContentShown(false);
}
}
示例11: onPreExecute
import org.eclipse.egit.github.core.client.GitHubClient; //导入依赖的package包/类
@Override
protected void onPreExecute() {
context = fragment.getContentView().getContext();
flag = fragment.getFlag();
adapter = fragment.getContentItemAdapter();
list = fragment.getContentItemList();
bookmark = fragment.getBookmark();
GitHubClient client = fragment.getClient();
dataService = new DataService(client);
owner = fragment.getOwner();
name = fragment.getName();
root = fragment.getRoot();
entry = fragment.getEntry();
if (flag == Flag.STAR_CONTENT_FIRST || flag == Flag.STAR_CONTENT_REFRESH) {
fragment.setContentEmpty(false);
fragment.setContentShown(false);
bookmark.setVisible(false);
}
}
示例12: onPreExecute
import org.eclipse.egit.github.core.client.GitHubClient; //导入依赖的package包/类
@Override
protected void onPreExecute() {
context = fragment.getContentView().getContext();
flag = fragment.getFlag();
adapter = fragment.getContentItemAdapter();
list = fragment.getContentItemList();
bookmark = fragment.getBookmark();
GitHubClient client = fragment.getClient();
dataService = new DataService(client);
owner = fragment.getOwner();
name = fragment.getName();
root = fragment.getRoot();
entry = fragment.getEntry();
if (flag == Flag.REPO_CONTENT_FIRST || flag == Flag.REPO_CONTENT_REFRESH) {
fragment.setContentEmpty(false);
fragment.setContentShown(false);
bookmark.setVisible(false);
}
}
示例13: onPreExecute
import org.eclipse.egit.github.core.client.GitHubClient; //导入依赖的package包/类
@Override
protected void onPreExecute() {
mainFragment.setRefreshStatus(true);
context = mainFragment.getContentView().getContext();
refreshType = mainFragment.getRefreshType();
GitHubClient gitHubClient = mainFragment.getGitHubClient();
repositoryService = new RepositoryService(gitHubClient);
repoItemAdapter = mainFragment.getRepoItemAdapter();
repoItemList = mainFragment.getRepoItemList();
if (refreshType == RefreshType.REPO_FIRST) {
mainFragment.setContentShown(false);
}
}
示例14: onPreExecute
import org.eclipse.egit.github.core.client.GitHubClient; //导入依赖的package包/类
@Override
protected void onPreExecute() {
mainFragment.setRefreshStatus(true);
context = mainFragment.getContentView().getContext();
refreshType = mainFragment.getRefreshType();
GitHubClient gitHubClient = mainFragment.getGitHubClient();
contentsService = new ContentsService(gitHubClient);
String repoOwner = mainFragment.getRepoOwner();
String repoName = mainFragment.getRepoName();
repositoryId = RepositoryId.create(repoOwner, repoName);
repoPath = mainFragment.getRepoPath();
contentItemAdapter = mainFragment.getContentItemAdapter();
contentItemList = mainFragment.getContentItemList();
contentItemListBuffer = mainFragment.getContentItemListBuffer();
mainFragment.setContentShown(false);
}
示例15: getRepositories
import org.eclipse.egit.github.core.client.GitHubClient; //导入依赖的package包/类
@Override
public List<String> getRepositories() {
// Logging
logger.debug("[github] Getting repository list");
// Getting a client
GitHubClient client = createGitHubClient();
// Service
RepositoryService repositoryService = new RepositoryService(client);
// Gets the repository names
try {
return repositoryService.getRepositories().stream()
.map(Repository::getName)
.collect(Collectors.toList());
} catch (IOException e) {
throw new OntrackGitHubClientException(e);
}
}