use of org.kohsuke.github.GHRepository in project nextprot-api by calipho-sib.
the class GitHubServiceImpl method getNews.
@Override
@Cacheable(value = "github-news")
public List<NextProtNews> getNews() {
List<NextProtNews> news = new ArrayList<>();
try {
GitHub github = getGitHubConnection();
GHRepository repo = github.getRepository("calipho-sib/nextprot-docs");
GHTree tree = repo.getTreeRecursive(githubDocBranch, 1);
newsFileNames.clear();
for (GHTreeEntry te : tree.getTree()) {
if (te.getPath().startsWith("news")) {
// Add only file on news
if (te.getType().equalsIgnoreCase("blob")) {
// file
String fileName = te.getPath().replaceAll("news/", "");
NextProtNews n = parseGitHubNewsFilePath(fileName);
if (n != null) {
news.add(n);
String fileEncoded = URLEncoder.encode(fileName.replace(".md", ""), "UTF-8").replace("+", "%20");
newsFileNames.put(n.getUrl(), fileEncoded);
}
}
}
}
} catch (IOException e) {
e.printStackTrace();
throw new NextProtException("News not available, sorry for the inconvenience");
}
Collections.sort(news);
return news;
}
use of org.kohsuke.github.GHRepository in project repairnator by Spirals-Team.
the class CheckIfIdsHaveABranch method main.
public static void main(String[] args) throws IOException {
List<String> allIds = Files.readAllLines(new File(args[0]).toPath());
String ghLogin = args[1];
String ghToken = args[2];
GitHub gitHub = GitHubBuilder.fromEnvironment().withOAuthToken(ghToken, ghLogin).build();
GHRepository repo = gitHub.getRepository("surli/bugs-collection");
Set<String> branchNames = repo.getBranches().keySet();
Map<String, String> branchById = new HashMap<>();
for (String branchName : branchNames) {
String[] splitted = branchName.split("-");
if (splitted.length > 1) {
String key = "";
for (int i = 0; i < splitted.length - 2; i++) {
key += splitted[i];
if (i < splitted.length - 3) {
key += "-";
}
}
branchById.put(key, branchName);
}
}
List<String> branchToDelete = new ArrayList<>();
String slug = null;
for (String line : allIds) {
if (line.startsWith("Project")) {
String[] splitted = line.split(" ");
slug = splitted[1];
} else {
String key = slug + "-" + line.trim();
if (branchById.containsKey(key)) {
System.out.println(key + " -> " + branchById.get(key));
branchToDelete.add(branchById.get(key));
}
}
}
}
use of org.kohsuke.github.GHRepository in project sts4 by spring-projects.
the class DefaultGithubInfoProvider method getOwners.
@Override
public Collection<String> getOwners() throws Exception {
if (connectionError != null) {
throw connectionError;
}
if (github != null) {
if (owners == null) {
ImmutableSet.Builder<String> owners = ImmutableSet.builder();
for (GHRepository repo : github.getMyself().listRepositories()) {
owners.add(repo.getOwnerName());
}
this.owners = owners.build();
}
return owners;
}
return ImmutableList.of();
}
use of org.kohsuke.github.GHRepository in project zaproxy by zaproxy.
the class CreateGitHubRelease method createRelease.
@TaskAction
public void createRelease() throws IOException {
if (bodyFile.isPresent() && body.isPresent()) {
throw new InvalidUserDataException("Only one type of body property must be set.");
}
if (checksumAlgorithm.get().isEmpty()) {
throw new IllegalArgumentException("The checksum algorithm must not be empty.");
}
GitHubUser ghUser = getUser().get();
GHRepository ghRepo = GitHub.connect(ghUser.getName(), ghUser.getAuthToken()).getRepository(repo.get());
validateTagExists(ghRepo, tag.get());
validateReleaseDoesNotExist(ghRepo, tag.get());
StringBuilder releaseBody = new StringBuilder(250);
releaseBody.append(bodyFile.isPresent() ? readContents(bodyFile.getAsFile().get().toPath()) : body.getOrElse(""));
if (addChecksums.get()) {
if (releaseBody.length() != 0) {
releaseBody.append("\n\n---\n");
}
appendChecksumsTable(releaseBody);
}
GHRelease release = ghRepo.createRelease(tag.get()).name(title.get()).body(releaseBody.toString()).prerelease(prerelease.get()).draft(true).create();
for (Asset asset : assets) {
release.uploadAsset(asset.getFile().getAsFile().get(), asset.getContentType().get());
}
if (!draft.get()) {
release.update().draft(false).update();
}
}
use of org.kohsuke.github.GHRepository in project che by eclipse.
the class GitHubDTOFactory method createRepositoriesList.
/**
* Create DTO object of GitHub repositories collection from given repositories list
* @param ghRepositoriesList collection of repositories from kohsuke GitHub library
* @return DTO object
* @throws IOException
*/
public GitHubRepositoryList createRepositoriesList(PagedIterable<GHRepository> ghRepositoriesList) throws ApiException, IOException {
GitHubRepositoryList dtoRepositoriesList = DtoFactory.getInstance().createDto(GitHubRepositoryList.class);
List<GitHubRepository> dtoRepositories = new ArrayList<>();
for (GHRepository ghRepository : ghRepositoriesList) {
dtoRepositories.add(createRepository(ghRepository));
}
dtoRepositoriesList.setRepositories(dtoRepositories);
return dtoRepositoriesList;
}
Aggregations