Java Code Examples for org.eclipse.egit.github.core.Repository#getSshUrl()

The following examples show how to use org.eclipse.egit.github.core.Repository#getSshUrl() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GithubApi.java    From karamel with Apache License 2.0 6 votes vote down vote up
/**
 * 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());
  }
}
 
Example 2
Source File: RepositoryInfo.java    From jbpm-work-items with Apache License 2.0 5 votes vote down vote up
public RepositoryInfo(Repository repository) {
    if (repository != null) {
        this.id = repository.getId();
        this.name = repository.getName();
        this.gitURL = repository.getGitUrl();
        this.htmlURL = repository.getHtmlUrl();
        this.description = repository.getDescription();
        this.masterBranch = repository.getMasterBranch();
        this.openIssues = repository.getOpenIssues();
        this.sshURL = repository.getSshUrl();
        this.watchers = repository.getWatchers();
    }
}
 
Example 3
Source File: GithubApi.java    From karamel with Apache License 2.0 5 votes vote down vote up
/**
 * Clone an existing github repo.
 *
 * @param owner
 * @param repoName
 * @throws se.kth.karamel.common.exception.KaramelException
 */
public synchronized static void cloneRepo(String owner, String repoName) throws KaramelException {
  Git result = null;
  try {
    RepositoryService rs = new RepositoryService(client);
    Repository r = rs.getRepository(owner, repoName);

    String cloneURL = r.getSshUrl();
    // prepare a new folder for the cloned repository
    File localPath = new File(Settings.COOKBOOKS_PATH + File.separator + repoName);
    if (localPath.isDirectory() == false) {
      localPath.mkdirs();
    } else {
      throw new KaramelException("Local directory already exists. Delete it first: " + localPath);
    }

    logger.debug("Cloning from " + cloneURL + " to " + localPath);
    result = Git.cloneRepository()
        .setURI(cloneURL)
        .setDirectory(localPath)
        .call();
    // Note: the call() returns an opened repository already which needs to be closed to avoid file handle leaks!
    logger.debug("Cloned repository: " + result.getRepository().getDirectory());
  } catch (IOException | GitAPIException ex) {
    throw new KaramelException("Problem cloning repo: " + ex.getMessage());
  } finally {
    if (result != null) {
      result.close();
    }
  }

}