com.jcabi.github.Repo Java Examples

The following examples show how to use com.jcabi.github.Repo. 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: StarRepoTestCase.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * StarRepo did not star the repository due to an IOException. 
 * StarRepo.perform() should return true anyway because it's not a critical operation and we
 * shouldn't fail the whole process just because of this.
 * 
 * This test expects an RuntimeException (we mock the logger in such a way) because it's the easiest way
 * to find out if the flow entered the catch block.
 * @throws IOException If something goes wrong.
 */
@Test(expected = RuntimeException.class)
public void repoStarringFails() throws IOException {
    Logger logger = Mockito.mock(Logger.class);
    Mockito.doNothing().when(logger).info(Mockito.anyString());
    Mockito.doThrow(new RuntimeException("Excpected excetion; all is ok!")).when(logger).error(
        Mockito.anyString(), Mockito.any(IOException.class)
    );
    
    Repo repo = Mockito.mock(Repo.class);
    Stars stars = Mockito.mock(Stars.class);
    Mockito.when(stars.starred()).thenReturn(false);
    Mockito.doThrow(new IOException()).when(stars).star();
    Mockito.when(repo.stars()).thenReturn(stars);
    Command com = Mockito.mock(Command.class);
    Issue issue = Mockito.mock(Issue.class);
    Mockito.when(issue.repo()).thenReturn(repo);
    Mockito.when(com.issue()).thenReturn(issue);
    
    StarRepo sr = new StarRepo(Mockito.mock(Step.class));
    sr.perform(com, logger);
}
 
Example #2
Source File: InitializrSpringCloudInfoServiceTests.java    From spring-cloud-release-tools with Apache License 2.0 6 votes vote down vote up
@Test
public void getMilestonesTest() throws Exception {
	RestTemplate rest = mock(RestTemplate.class);
	Github github = mock(Github.class);
	GithubPomReader githubPomReader = mock(GithubPomReader.class);
	Repos repos = mock(Repos.class);
	Repo repo = mock(Repo.class);
	Milestones milestones = mock(Milestones.class);
	Iterable iterable = buildMilestonesIterable();
	doReturn(iterable).when(milestones).iterate(any(Map.class));
	doReturn(milestones).when(repo).milestones();
	doReturn(repo).when(repos).get(any(Coordinates.class));
	doReturn(repos).when(github).repos();
	InitializrSpringCloudInfoService service = spy(
			new InitializrSpringCloudInfoService(rest, github, githubPomReader));
	assertThat(service.getMilestones(), Matchers.equalTo(milestoneStrings.keySet()));

}
 
Example #3
Source File: CachingGithubTests.java    From spring-cloud-release-tools with Apache License 2.0 6 votes vote down vote up
@Test
void should_not_cache_calls_for_different_milestones_for_repo() {
	Repo repo1 = mock(Repo.class);
	given(repo1.milestones()).willReturn(BDDMockito.mock(Milestones.class));
	Repo repo2 = mock(Repo.class);
	given(repo2.milestones()).willReturn(BDDMockito.mock(Milestones.class));
	Repo repo3 = mock(Repo.class);
	given(repo3.milestones()).willReturn(BDDMockito.mock(Milestones.class));

	new CachingRepo(repo1).milestones();
	new CachingRepo(repo2).milestones();
	new CachingRepo(repo3).milestones();

	verify(repo1).milestones();
	verify(repo2).milestones();
	verify(repo3).milestones();
}
 
Example #4
Source File: StarRepo.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void perform(Command command, Logger logger) throws IOException {
    try {
        logger.info("Starring repository...");
        Repo repo = command.issue().repo();
        if(!repo.stars().starred()) {
            repo.stars().star();
        }
        logger.info("Repository starred!");
    } catch (IOException e) {
        logger.error("Error when starring repository: " + e.getMessage(), e);
        //We do not rethrow it here since starring the repo is not
        //a critical matter
    }
    this.next().perform(command, logger);
}
 
Example #5
Source File: CachingGithubTests.java    From spring-cloud-release-tools with Apache License 2.0 6 votes vote down vote up
@Test
void should_not_cache_calls_for_different_issues_for_repo() {
	Repo repo1 = mock(Repo.class);
	given(repo1.issues()).willReturn(BDDMockito.mock(Issues.class));
	Repo repo2 = mock(Repo.class);
	given(repo2.issues()).willReturn(BDDMockito.mock(Issues.class));
	Repo repo3 = mock(Repo.class);
	given(repo3.issues()).willReturn(BDDMockito.mock(Issues.class));

	new CachingRepo(repo1).issues();
	new CachingRepo(repo2).issues();
	new CachingRepo(repo3).issues();

	verify(repo1).issues();
	verify(repo2).issues();
	verify(repo3).issues();
}
 
Example #6
Source File: CachingGithubTests.java    From spring-cloud-release-tools with Apache License 2.0 6 votes vote down vote up
@Test
void should_not_cache_calls_for_different_releases_for_repo() {
	Repo repo1 = mock(Repo.class);
	given(repo1.releases()).willReturn(BDDMockito.mock(Releases.class));
	Repo repo2 = mock(Repo.class);
	given(repo2.releases()).willReturn(BDDMockito.mock(Releases.class));
	Repo repo3 = mock(Repo.class);
	given(repo3.releases()).willReturn(BDDMockito.mock(Releases.class));

	new CachingRepo(repo1).releases();
	new CachingRepo(repo2).releases();
	new CachingRepo(repo3).releases();

	verify(repo1).releases();
	verify(repo2).releases();
	verify(repo3).releases();
}
 
Example #7
Source File: CachingGithubTests.java    From spring-cloud-release-tools with Apache License 2.0 6 votes vote down vote up
@Test
void should_not_cache_calls_for_different_coordinates_for_repo() {
	Repo repo1 = mock(Repo.class);
	given(repo1.coordinates()).willReturn(new Coordinates.Simple("foo", "bar"));
	Repo repo2 = mock(Repo.class);
	given(repo2.coordinates()).willReturn(new Coordinates.Simple("foo", "bar"));
	Repo repo3 = mock(Repo.class);
	given(repo3.coordinates()).willReturn(new Coordinates.Simple("foo", "bar"));

	new CachingRepo(repo1).coordinates();
	new CachingRepo(repo2).coordinates();
	new CachingRepo(repo3).coordinates();

	verify(repo1).coordinates();
	verify(repo2).coordinates();
	verify(repo3).coordinates();
}
 
Example #8
Source File: StarRepoTestCase.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * StarRepo can successfully star a given repository.
 * @throws Exception If something goes wrong.
 */
@Test
public void starsRepo() throws Exception {
    Logger logger = Mockito.mock(Logger.class);
    Mockito.doNothing().when(logger).info(Mockito.anyString());
    Mockito.doThrow(new IllegalStateException("Unexpected error; test failed")).when(logger).error(Mockito.anyString());
    
    Github gh = new MkGithub("amihaiemil");
    Repo repo =  gh.repos().create(
        new RepoCreate("amihaiemil.github.io", false)
    );
    Command com = Mockito.mock(Command.class);
    Issue issue = Mockito.mock(Issue.class);
    Mockito.when(issue.repo()).thenReturn(repo);
    Mockito.when(com.issue()).thenReturn(issue);
    
    Step sr = new StarRepo(Mockito.mock(Step.class));
    assertFalse(com.issue().repo().stars().starred());
    sr.perform(com, logger);
    assertTrue(com.issue().repo().stars().starred());
}
 
Example #9
Source File: StarRepoTestCase.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * StarRepo tries to star a repo twice.
 * @throws Exception If something goes wrong.
 */
@Test
public void starsRepoTwice() throws Exception {
    Logger logger = Mockito.mock(Logger.class);
    Mockito.doNothing().when(logger).info(Mockito.anyString());
    Mockito.doThrow(new IllegalStateException("Unexpected error; test failed")).when(logger).error(Mockito.anyString());

    Github gh = new MkGithub("amihaiemil");
    Repo repo =  gh.repos().create(
        new RepoCreate("amihaiemil.github.io", false)
    );
    Command com = Mockito.mock(Command.class);
    Issue issue = Mockito.mock(Issue.class);
    Mockito.when(issue.repo()).thenReturn(repo);
    Mockito.when(com.issue()).thenReturn(issue);

    Step sr = new StarRepo(Mockito.mock(Step.class));
    assertFalse(com.issue().repo().stars().starred());
    sr.perform(com, logger);
    sr.perform(com, logger);
    assertTrue(com.issue().repo().stars().starred());
}
 
Example #10
Source File: LastCommentTestCase.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Agent already replied once to the last comment.
 * @throws Exception if something goes wrong.
 */
@Test
public void agentRepliedAlreadyToTheLastComment() throws Exception {
    final MkStorage storage = new MkStorage.Synced(new MkStorage.InFile());
    final Repo repoMihai = new MkGithub(storage, "amihaiemil").repos().create( new RepoCreate("amihaiemil.github.io", false));
    final Issue issue = repoMihai.issues().create("test issue", "body");
    issue.comments().post("@charlesmike hello!");
    
    final Github charlesmike = new MkGithub(storage, "charlesmike");
    Issue issueCharlesmike = charlesmike.repos().get(repoMihai.coordinates()).issues().get(issue.number());
    issueCharlesmike.comments().post("@amihaiemil hi there, I can help you index... ");

    issue.comments().post("@someoneelse, please check that...");
    
    LastComment lastComment = new LastComment(issueCharlesmike);
    JsonObject jsonComment = lastComment.json();
    JsonObject emptyMentionComment = Json.createObjectBuilder().add("id", "-1").add("body", "").build();
    assertTrue(emptyMentionComment.equals(jsonComment)); 
}
 
Example #11
Source File: LastCommentTestCase.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * There is more than 1 mention of the agent in the issue and it has already 
 * replied to others, but the last one is not replied to yet.
 * @throws Exception if something goes wrong.
 */
@Test
public void agentRepliedToPreviousMention() throws Exception {
    final MkStorage storage = new MkStorage.Synced(new MkStorage.InFile());
    final Repo repoMihai = new MkGithub(storage, "amihaiemil").repos().create( new RepoCreate("amihaiemil.github.io", false));
    final Issue issue = repoMihai.issues().create("test issue", "body");
    issue.comments().post("@charlesmike hello!");//first mention
    
    final Github charlesmike = new MkGithub(storage, "charlesmike");
    Issue issueCharlesmike = charlesmike.repos().get(repoMihai.coordinates()).issues().get(issue.number());
    issueCharlesmike.comments().post("@amihaiemil hi there, I can help you index... "); //first reply

    Comment lastMention = issue.comments().post("@charlesmike hello again!!");//second mention
    issue.comments().post("@someoneelse, please check that..."); //some other comment that is the last on the ticket.
    
    LastComment lastComment = new LastComment(issueCharlesmike);
    JsonObject jsonComment = lastComment.json();
    assertTrue(lastMention.json().equals(jsonComment)); 
}
 
Example #12
Source File: CachedRepoTestCase.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * CommandedRepo can tell when the repo has a gh-pages branch.
 * @throws Exception If something goes wrong.
 */
@Test
public void repoHasGhPagesBranch() throws Exception {
    int port = this.port();
    MkContainer server = new MkGrizzlyContainer()
        .next(new MkAnswer.Simple(HttpURLConnection.HTTP_OK))
        .start(port);
    try {
        CachedRepo crepo = Mockito.spy(
            new CachedRepo(Mockito.mock(Repo.class))
        );
        Mockito.when(crepo.json()).thenReturn(Json
            .createObjectBuilder()
            .add(
                "branches_url",
                "http://localhost:" + port + "/branches{/branch}"
            ).build()
        );
        assertTrue(
            "Expected a gh-pages branch!",
            crepo.hasGhPagesBranch()
        );
    } finally {
        server.stop();
    }
}
 
Example #13
Source File: CachedRepoTestCase.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * CommandedRepo can tell when the repo doesn't
 * have a gh-pages branch.
 * @throws Exception If something goes wrong.
 */
@Test
public void repoHasNoGhPagesBranch() throws Exception {
    int port = this.port();
    MkContainer server = new MkGrizzlyContainer()
        .next(new MkAnswer.Simple(HttpURLConnection.HTTP_NOT_FOUND))
        .start(port);
    try {
        CachedRepo crepo = Mockito.spy(
            new CachedRepo(Mockito.mock(Repo.class))
        );
        Mockito.when(crepo.json()).thenReturn(Json
            .createObjectBuilder()
            .add(
                "branches_url",
                "http://localhost:" + port + "/branches{/branch}"
            ).build()
        );
        assertFalse(
            "Unexpected gh-pages branch!",
            crepo.hasGhPagesBranch()
        );
    } finally {
        server.stop();
    }
}
 
Example #14
Source File: GithubIssueFiler.java    From spring-cloud-release-tools with Apache License 2.0 6 votes vote down vote up
private boolean issueAlreadyFiled(Repo springGuides, String issueTitle) {
	Map<String, String> map = new HashMap<>();
	map.put("state", "open");
	int counter = 0;
	int maxIssues = 10;
	for (Issue issue : springGuides.issues().iterate(map)) {
		if (counter >= maxIssues) {
			return false;
		}
		Issue.Smart smartIssue = new Issue.Smart(issue);
		try {
			if (issueTitle.equals(smartIssue.title())) {
				return true;
			}
		}
		catch (IOException e) {
			return false;
		}
		counter = counter + 1;
	}
	return false;
}
 
Example #15
Source File: GithubIssueFiler.java    From spring-cloud-release-tools with Apache License 2.0 6 votes vote down vote up
private void fileAGithubIssue(String user, String repo, String issueTitle,
		String issueText) {
	Repo ghRepo = this.github.repos().get(new Coordinates.Simple(user, repo));
	// check if the issue is not already there
	boolean issueAlreadyFiled = issueAlreadyFiled(ghRepo, issueTitle);
	if (issueAlreadyFiled) {
		log.info("Issue already filed, will not do that again");
		return;
	}
	try {
		int number = ghRepo.issues().create(issueTitle, issueText).number();
		log.info(
				"Successfully created an issue with "
						+ "title [{}] for the [{}/{}] GitHub repository" + number,
				issueTitle, user, repo);
	}
	catch (IOException e) {
		log.error("Exception occurred while trying to create the issue in guides", e);
	}
}
 
Example #16
Source File: ValidCommandTestCase.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void getsAuthorEmail() throws Exception {
    MkStorage storage = new MkStorage.Synced(new MkStorage.InFile());
    
    MkGithub authorGh = new MkGithub(storage, "amihaiemil");
    authorGh.users().self().emails().add(Arrays.asList("[email protected]"));
    Repo authorRepo = authorGh.randomRepo();
    Comment com = authorRepo.issues().create("", "").comments().post("@charlesmike do something");

    Github agentGh = new MkGithub(storage, "charlesmike");
    Issue issue = agentGh.repos().get(authorRepo.coordinates()).issues().get(com.issue().number());
    Command comm = Mockito.mock(Command.class);
    
    JsonObject authorInfo = Json.createObjectBuilder().add("login", "amihaiemil").build();
    JsonObject json = Json.createObjectBuilder()
        .add("user", authorInfo)
        .add("body", com.json().getString("body"))
        .add("id", 2)
        .build();
    Mockito.when(comm.json()).thenReturn(json);
    Mockito.when(comm.issue()).thenReturn(issue);

    ValidCommand vc = new ValidCommand(comm);
    assertTrue(vc.authorEmail().equals("[email protected]"));
}
 
Example #17
Source File: InitializrSpringCloudInfoServiceTests.java    From spring-cloud-release-tools with Apache License 2.0 6 votes vote down vote up
@Test
public void getMilestoneDueDateTest() throws Exception {
	RestTemplate rest = mock(RestTemplate.class);
	Github github = mock(Github.class);
	GithubPomReader githubPomReader = mock(GithubPomReader.class);
	Repos repos = mock(Repos.class);
	Repo repo = mock(Repo.class);
	Milestones milestones = mock(Milestones.class);
	Iterable iterable = buildMilestonesIterable();
	doReturn(iterable).when(milestones).iterate(any(Map.class));
	doReturn(milestones).when(repo).milestones();
	doReturn(repo).when(repos).get(any(Coordinates.class));
	doReturn(repos).when(github).repos();
	InitializrSpringCloudInfoService service = spy(
			new InitializrSpringCloudInfoService(rest, github, githubPomReader));
	assertThat(service.getMilestoneDueDate("Finchley.SR4"),
			Matchers.equalTo(new SpringCloudInfoService.Milestone("No Due Date")));
	assertThat(service.getMilestoneDueDate("Hoxton.RELEASE"),
			Matchers.equalTo(new SpringCloudInfoService.Milestone("2019-07-31")));
}
 
Example #18
Source File: FollowTestCase.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Mock a command, add issue, repo and github mocks into it.
 * @return Command.
 */
private Command mockCommand() {
    final Command com = Mockito.mock(Command.class);
    Mockito.when(com.authorLogin()).thenReturn("amihaiemil");
    
    final Issue issue = Mockito.mock(Issue.class);
    final Repo repo = Mockito.mock(Repo.class);
    Mockito.when(repo.github()).thenReturn(Mockito.mock(Github.class));
    Mockito.when(issue.repo()).thenReturn(repo);
    
    Mockito.when(com.issue()).thenReturn(issue);
    
    return com;
}
 
Example #19
Source File: CachedRepoTestCase.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * CachedRepo can return the .charles.yml which is in the repo.
 * @throws Exception If something goes wrong.
 */
@Test
public void getsExistingCharlesYml() throws Exception {
    final MkGithub gh = new MkGithub("amihaiemil");
    final Repo repo = gh.repos().create(new RepoCreate("charlesrepo", false));
    repo.contents()
        .create(
            Json.createObjectBuilder()
                .add("path", ".charles.yml")
                .add("message", "just a test")
                .add(
                    "content",
                    Base64.encodeBase64String(
                        Yaml.createYamlMappingBuilder()
                            .add("tweet", "true")
                            .add(
                                "commanders",
                                Yaml.createYamlSequenceBuilder()
                                    .add("johndoe")
                                    .add("amihaiemil")
                                    .add("queeney")
                                    .build()
                            ).build().toString().getBytes()
                    )
                ).build()
        );
    final CharlesYml yml = new CachedRepo(repo).charlesYml();
    MatcherAssert.assertThat(yml.commanders(), Matchers.hasSize(3));
    MatcherAssert.assertThat(yml.commanders().get(0), Matchers.equalTo("amihaiemil"));//YAML orders them alphabetically
    MatcherAssert.assertThat(yml.commanders().get(1), Matchers.equalTo("johndoe"));
    MatcherAssert.assertThat(yml.commanders().get(2), Matchers.equalTo("queeney"));
    MatcherAssert.assertThat(yml.tweet(), Matchers.is(true));
}
 
Example #20
Source File: CachingGithubTests.java    From spring-cloud-release-tools with Apache License 2.0 5 votes vote down vote up
@Test
void should_call_milestones_only_once_for_same_repo() {
	Repo repo = mock(Repo.class);
	given(repo.milestones()).willReturn(BDDMockito.mock(Milestones.class));
	CachingRepo cachingRepo = new CachingRepo(repo);

	cachingRepo.milestones();
	cachingRepo.milestones();
	cachingRepo.milestones();

	verify(repo, only()).milestones();
}
 
Example #21
Source File: CachedRepoTestCase.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * CommandedRepo throws IOException if the http response
 * status is not appropriate.
 * @throws Exception If something goes wrong.
 */
@Test
public void unexpectedHttpStatusFromBranchesAPI() throws Exception {
    int port = this.port();
    MkContainer server = new MkGrizzlyContainer()
        .next(new MkAnswer.Simple(HttpURLConnection.HTTP_BAD_REQUEST))
        .start(port);
    try {
        CachedRepo crepo = Mockito.spy(
            new CachedRepo(Mockito.mock(Repo.class))
        );
        Mockito.when(crepo.json()).thenReturn(Json
            .createObjectBuilder()
            .add(
                "branches_url",
                "http://localhost:" + port + "/branches{/branch}"
            ).build()
        );
        crepo.hasGhPagesBranch();
        fail("Expected an IOException here");
    } catch (IOException ex) {
        assertTrue(
            ex.getMessage()
                .equals("Unexpected HTTP status response.")
        );
    } finally {
        server.stop();
    }
}
 
Example #22
Source File: CachedRepoTestCase.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * CommandedRepo can represent itself in json format.
 * @throws Exception If something goes wrong.
 */
@Test
public void getsJson() throws Exception {
    MkGithub gh = new MkGithub("amihaiemil");
    Repo rep = gh.repos().create(new RepoCreate("charlesrepo", false));
    CachedRepo crepo = new CachedRepo(rep);
    JsonObject repoJson = crepo.json();
    assertTrue(crepo.name().equals("charlesrepo"));
    assertTrue(repoJson.getString("private").equals("false"));

    JsonObject repoFromCache = crepo.json();
    assertTrue(repoJson == repoFromCache);
}
 
Example #23
Source File: CachedRepoTestCase.java    From charles-rest with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * CachedRepo can return a default ChalesYml if the repo does not have it.
 * @throws Exception If something goes worng.
 */
@Test
public void getsDefaultCharlesYml() throws Exception {
    MkGithub gh = new MkGithub("amihaiemil");
    Repo rep = gh.repos().create(new RepoCreate("charlesrepo", false));
    CharlesYml yml = new CachedRepo(rep).charlesYml();
    MatcherAssert.assertThat(yml.commanders(), Matchers.emptyIterable());
    MatcherAssert.assertThat(yml.tweet(), Matchers.is(false));
}
 
Example #24
Source File: CachingGithubTests.java    From spring-cloud-release-tools with Apache License 2.0 5 votes vote down vote up
@Test
void should_call_releases_only_once_for_same_repo() {
	Repo repo = mock(Repo.class);
	given(repo.releases()).willReturn(BDDMockito.mock(Releases.class));
	CachingRepo cachingRepo = new CachingRepo(repo);

	cachingRepo.releases();
	cachingRepo.releases();
	cachingRepo.releases();

	verify(repo, only()).releases();
}
 
Example #25
Source File: CachingGithubTests.java    From spring-cloud-release-tools with Apache License 2.0 5 votes vote down vote up
@Test
void should_issues_only_once_for_same_repo() {
	Repo repo = mock(Repo.class);
	given(repo.issues()).willReturn(BDDMockito.mock(Issues.class));
	CachingRepo cachingRepo = new CachingRepo(repo);

	cachingRepo.issues();
	cachingRepo.issues();
	cachingRepo.issues();

	verify(repo, only()).issues();
}
 
Example #26
Source File: CachingGithubTests.java    From spring-cloud-release-tools with Apache License 2.0 5 votes vote down vote up
@Test
void should_coordinates_only_once_for_same_repo() {
	Repo repo = mock(Repo.class);
	given(repo.coordinates()).willReturn(new Coordinates.Simple("foo", "bar"));
	CachingRepo cachingRepo = new CachingRepo(repo);

	cachingRepo.coordinates();
	cachingRepo.coordinates();
	cachingRepo.coordinates();

	verify(repo, only()).coordinates();
}
 
Example #27
Source File: GithubFacadeBuilder.java    From sputnik with Apache License 2.0 5 votes vote down vote up
@NotNull
public GithubFacade build(Configuration configuration) {

    Patchset patchset = PatchsetBuilder.build(configuration);

    String oAuthKey = configuration.getProperty(GeneralOption.GITHUB_API_KEY);
    Github github = new RtGithub(
            new RtGithub(oAuthKey)
                    .entry()
                    .through(RetryWire.class)
    );

    Repo repo = github.repos().get(new Coordinates.Simple(patchset.getProjectPath()));
    return new GithubFacade(repo, patchset);
}
 
Example #28
Source File: GenerateReleaseNotesTask.java    From spring-cloud-release-tools with Apache License 2.0 5 votes vote down vote up
/**
 * Extract at-mentions of contributors, given a list of commits (will fetch
 * contributor login from github). The list is deduplicated and sorted in
 * case-insensitive alphabetical order.
 */
List<String> extractContributorMentions(Repo repo, List<SimpleCommit> revCommits) {
	RepoCommits commitsClient = repo.commits();
	return revCommits.stream().map(c -> commitToGithubMention(commitsClient, c))
			.filter(Objects::nonNull).distinct().sorted(String.CASE_INSENSITIVE_ORDER)
			.collect(Collectors.toList());
}
 
Example #29
Source File: Status.java    From sputnik with Apache License 2.0 5 votes vote down vote up
private String createIssueLink(Optional<Integer> issueId) {
    final Repo repo = pull.repo();
    if (issueId.isPresent()) {
        return String.format("https://github.com/%s/%s/issues/%d",
                repo.coordinates().user(), repo.coordinates().repo(), issueId.get());
    } else {
        return String.format("https://github.com/%s/%s/issues",
                repo.coordinates().user(), repo.coordinates().repo());
    }
}
 
Example #30
Source File: GithubMilestonesTests.java    From spring-cloud-release-tools with Apache License 2.0 4 votes vote down vote up
private Repo createSleuthRepo(MkGithub github) throws IOException {
	return github.repos().create(new Repos.RepoCreate("spring-cloud-sleuth", false));
}