Tree currentTree = ref != null ? service.getCommit(repository, ref.getObject().getSha()).getTree() : null; String baseTree = null; if (currentTree != null) commit.setTree(tree); Commit created = service.createCommit(repository, commit); TypedResource object = new TypedResource(); object.setType(TypedResource.TYPE_COMMIT).setSha(created.getSha()); if (ref != null) {
/** * Create reference * * @param repository * @param reference * @return created reference * @throws IOException */ public Reference createReference(IRepositoryIdProvider repository, Reference reference) throws IOException { final String id = getId(repository); if (reference == null) throw new IllegalArgumentException("Reference cannot be null"); //$NON-NLS-1$ TypedResource object = reference.getObject(); if (object == null) throw new IllegalArgumentException( "Reference object cannot be null"); //$NON-NLS-1$ StringBuilder uri = new StringBuilder(); uri.append(SEGMENT_REPOS); uri.append('/').append(id); uri.append(SEGMENT_GIT); uri.append(SEGMENT_REFS); Map<String, String> params = new HashMap<String, String>(); params.put("sha", object.getSha()); //$NON-NLS-1$ params.put("ref", reference.getRef()); //$NON-NLS-1$ return client.post(uri.toString(), params, Reference.class); }
if (ref != null && !TYPE_COMMIT.equals(ref.getObject().getType())) throw new MojoExecutionException( MessageFormat .format("Existing ref {0} points to a {1} ({2}) instead of a commmit", ref.getRef(), ref.getObject().getType(), ref.getObject().getSha())); if (merge && ref != null) { Tree currentTree = service.getCommit(repository, ref.getObject().getSha()).getTree(); if (currentTree != null) baseTree = currentTree.getSha(); .getObject().getSha()))); TypedResource object = new TypedResource(); object.setType(TYPE_COMMIT).setSha(created.getSha()); if (ref != null) {
uri.append('/').append(ref); Map<String, Object> params = new HashMap<String, Object>(); params.put("sha", object.getSha()); //$NON-NLS-1$ if (force) params.put("force", true); //$NON-NLS-1$
if (ref != null && !TYPE_COMMIT.equals(ref.getObject().getType())) throw new MojoExecutionException( MessageFormat .format("Existing ref {0} points to a {1} ({2}) instead of a commmit", ref.getRef(), ref.getObject().getType(), ref.getObject().getSha())); if (merge && ref != null) { Tree currentTree = service.getCommit(repository, ref.getObject().getSha()).getTree(); if (currentTree != null) baseTree = currentTree.getSha(); .getObject().getSha()))); TypedResource object = new TypedResource(); object.setType(TYPE_COMMIT).setSha(created.getSha()); if (ref != null) {
/** * @see io.apicurio.hub.api.github.IGitHubSourceConnector#getBranches(java.lang.String, java.lang.String) */ @Override public Collection<SourceCodeBranch> getBranches(String org, String repo) throws GitHubException, SourceConnectorException { logger.debug("Getting the branches from {} / {}", org, repo); Collection<SourceCodeBranch> rval = new HashSet<>(); try { GitHubClient client = githubClient(); RepositoryService repoService = new RepositoryService(client); Repository repository = repoService.getRepository(org, repo); List<RepositoryBranch> branches = repoService.getBranches(repository); for (RepositoryBranch branch : branches) { SourceCodeBranch ghBranch = new SourceCodeBranch(); ghBranch.setName(branch.getName()); ghBranch.setCommitId(branch.getCommit().getSha()); rval.add(ghBranch); } } catch (IOException e) { logger.error("Error getting GitHub branches.", e); throw new GitHubException("Error getting GitHub branches.", e); } return rval; }