本文整理汇总了Java中org.eclipse.egit.github.core.service.RepositoryService类的典型用法代码示例。如果您正苦于以下问题:Java RepositoryService类的具体用法?Java RepositoryService怎么用?Java RepositoryService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RepositoryService类属于org.eclipse.egit.github.core.service包,在下文中一共展示了RepositoryService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findAssociatedClaNames
import org.eclipse.egit.github.core.service.RepositoryService; //导入依赖的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;
}
示例2: createTestRepository
import org.eclipse.egit.github.core.service.RepositoryService; //导入依赖的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());
}
示例3: fork
import org.eclipse.egit.github.core.service.RepositoryService; //导入依赖的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);
}
}
示例4: createRepository
import org.eclipse.egit.github.core.service.RepositoryService; //导入依赖的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);
}
}
示例5: testCreateOrUpdateItem
import org.eclipse.egit.github.core.service.RepositoryService; //导入依赖的package包/类
public void testCreateOrUpdateItem(@Mocked ClientResponse clientResponse, @Mocked StorageEngine store,
@Mocked Repository repoMock, @Mocked RepositoryService service, @Mocked IssueService issueServiceMock,
@Mocked ODocument workItem) throws Exception {
new Expectations() {
{
settings.hasJiraProperties();
result = true;
clientResponse.getStatus();
result = Status.OK.getStatusCode();
service.getRepository(anyString, anyString);
result = repoMock;
}
};
JiraExporter jiraExporter = JiraExporter.INSTANCE;
jiraExporter.initialize(settings, store);
jiraExporter.createOrUpdateItem(workItem);
new Verifications() {
{
}
};
}
示例6: getRepos
import org.eclipse.egit.github.core.service.RepositoryService; //导入依赖的package包/类
/**
* Gets all repositories for a given organization/user.
*
* @param orgName
* @return List of repositories
* @throws KaramelException
*/
public synchronized static List<RepoItem> getRepos(String orgName) throws KaramelException {
if (cachedRepos.get(orgName) != null) {
return cachedRepos.get(orgName);
}
try {
RepositoryService rs = new RepositoryService(client);
List<Repository> repos;
// If we are looking for the repositories for the current user
if (GithubApi.getUser().equalsIgnoreCase(orgName)) {
repos = rs.getRepositories(orgName);
} else { // If we are looking for the repositories for a given organization
repos = rs.getOrgRepositories(orgName);
}
List<RepoItem> repoItems = new ArrayList<>();
for (Repository r : repos) {
repoItems.add(new RepoItem(r.getName(), r.getDescription(), r.getSshUrl()));
}
cachedRepos.put(orgName, repoItems);
return repoItems;
} catch (IOException ex) {
throw new KaramelException("Problem listing GitHub repositories: " + ex.getMessage());
}
}
示例7: createRepoForOrg
import org.eclipse.egit.github.core.service.RepositoryService; //导入依赖的package包/类
/**
* Create a repository for a given organization with a description
*
* @param org
* @param repoName
* @param description
* @return RepoItem bean/json object
* @throws KaramelException
*/
public synchronized static RepoItem createRepoForOrg(String org, String repoName, String description) throws
KaramelException {
try {
OrganizationService os = new OrganizationService(client);
RepositoryService rs = new RepositoryService(client);
Repository r = new Repository();
r.setName(repoName);
r.setOwner(os.getOrganization(org));
r.setDescription(description);
rs.createRepository(org, r);
cloneRepo(org, repoName);
cachedRepos.remove(org);
return new RepoItem(repoName, description, r.getSshUrl());
} catch (IOException ex) {
throw new KaramelException("Problem creating the repository " + repoName + " for organization " + org
+ " : " + ex.getMessage());
}
}
示例8: createRepoForUser
import org.eclipse.egit.github.core.service.RepositoryService; //导入依赖的package包/类
/**
* Create a repository in a given github user's local account.
*
* @param repoName
* @param description
* @throws KaramelException
*/
public synchronized static void createRepoForUser(String repoName, String description) throws KaramelException {
try {
UserService us = new UserService(client);
RepositoryService rs = new RepositoryService(client);
Repository r = new Repository();
r.setName(repoName);
r.setOwner(us.getUser());
r.setDescription(description);
rs.createRepository(r);
cloneRepo(getUser(), repoName);
cachedRepos.remove(GithubApi.getUser());
} catch (IOException ex) {
throw new KaramelException("Problem creating " + repoName + " for user " + ex.getMessage());
}
}
示例9: createGitRepository
import org.eclipse.egit.github.core.service.RepositoryService; //导入依赖的package包/类
/**
* Creates a repository on GitHub and in a local temporary directory. This is a one time operation as
* once it is created on GitHub and locally it cannot be recreated.
*/
public File createGitRepository(String repositoryName) throws IOException {
RepositoryService service = new RepositoryService();
service.getClient().setOAuth2Token(oAuthToken);
Repository repository = new Repository();
repository.setName(repositoryName);
repository = service.createRepository(repository);
repositoryLocation = repository.getHtmlUrl();
CloneCommand cloneCommand = Git.cloneRepository()
.setURI(repository.getCloneUrl())
.setDirectory(localGitDirectory);
addAuth(cloneCommand);
try {
localRepository = cloneCommand.call();
} catch (GitAPIException e) {
throw new IOException("Error cloning to local file system", e);
}
return localGitDirectory;
}
示例10: onPreExecute
import org.eclipse.egit.github.core.service.RepositoryService; //导入依赖的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.service.RepositoryService; //导入依赖的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);
}
}
示例12: getRepositories
import org.eclipse.egit.github.core.service.RepositoryService; //导入依赖的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);
}
}
示例13: GFMMassConverter
import org.eclipse.egit.github.core.service.RepositoryService; //导入依赖的package包/类
public GFMMassConverter() throws IOException {
gFMMassConverterConfiguration = new GFMMassConverterConfiguration();
//GitHub client with optional authentication token
gitHubClient = new GitHubClient();
final String authenticationToken = gFMMassConverterConfiguration.getGFMAuthenticationToken();
if( null != authenticationToken && ! authenticationToken.isEmpty() ) {
gitHubClient.setOAuth2Token( authenticationToken );
}
final String gitHubUser = gFMMassConverterConfiguration.getGFMGitHubUser();
final String gitHubProjet = gFMMassConverterConfiguration.getGFMGitHubRepository();
//Get the optional repository configured
if( null != gitHubUser && ! gitHubUser.isEmpty() && null != gitHubProjet && ! gitHubProjet.isEmpty() ) {
final RepositoryService repositoryService = new RepositoryService( gitHubClient );
gitHubProjectRepository = repositoryService.getRepository( gitHubUser, gitHubProjet );
}
else {
gitHubProjectRepository = null;
}
markdownService = new MarkdownService( gitHubClient );
}
示例14: getCommitsFromGitHub
import org.eclipse.egit.github.core.service.RepositoryService; //导入依赖的package包/类
/**
* Fetches list of commits form GitHub repository.
*
* @param auth
* @param owner
* @param name
* @param branch
* @return list of commits
* @throws IOException
*/
private List<RepositoryCommit> getCommitsFromGitHub(final String auth, final String owner, final String name,
final String branch) throws IOException {
GitHubClient client = new GitHubClient();
if (auth != null && !auth.isEmpty()) {
client.setOAuth2Token(auth);
} else {
log.warn("OAuth2Token not set");
}
CommitService cs = new CommitService(client);
RepositoryService rs = new RepositoryService(client);
final Repository repository = rs.getRepository(owner, name);
return cs.getCommits(repository, branch, null);
}
示例15: IssueToEGitHub
import org.eclipse.egit.github.core.service.RepositoryService; //导入依赖的package包/类
/**
* Class to convert the issue and transfers it
*
* @param data
* @throws IOException
*/
public IssueToEGitHub( final ConnectionData data )
throws IOException {
this.repositoryParam = data.getRepository();
this.userParam = data.getUser();
this.mantisbturlParam = data.getMantisurl();
GitHubClient client = new GitHubClient();
client.setOAuth2Token( data.getToken() );
RepositoryService repositoryService = new RepositoryService( client );
MilestoneService milestoneService = new MilestoneService( client );
IssueService issueService = new IssueService( client );
Repository repository = repositoryService.getRepository( this.userParam, this.repositoryParam );
TransferService transferService = new TransferService( milestoneMap, issueService, milestoneService, userParam,
repositoryParam, repository );
this.transferService = transferService;
readMilestones( milestoneService );
}