Skip to content
This repository has been archived by the owner on Apr 5, 2022. It is now read-only.

Feature: Added operation to get all user's repositories #31

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
.DS_Store
build
**/build
target
**/target
**/src/test/java/exploration
.gradle
spring-social-core/src/test/java/exploration
Expand Down
1 change: 1 addition & 0 deletions README
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
1
============================= Spring Social GitHub ============================
To check out the project and build from source, do the following:

Expand Down
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ configure(allprojects) {

ext {
springSocialVersion = '1.1.4.RELEASE'
jacksonVersion = '2.3.0'
junitVersion = '4.11'
mockitoVersion = '1.9.5'
servletApiVersion = '3.0.1'
springVersion = '4.0.2.RELEASE'
jacksonVersion = '2.6.5'
junitVersion = '4.12'
mockitoVersion = '1.10.19'
servletApiVersion = '3.1.0'
springVersion = '4.2.5.RELEASE'
}

[compileJava, compileTestJava]*.options*.compilerArgs = ['-Xlint:none']
Expand Down
102 changes: 102 additions & 0 deletions spring-social-github/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-github</artifactId>
<name>Spring Social GitHub</name>
<version>1.0.0.CONTRIB</version>

<description>Spring Social extension with connection support and an API binding for GitHub</description>

<properties>
<spring.social.version>1.1.4.RELEASE</spring.social.version>
<jackson.version>2.6.5</jackson.version>
<spring.version>4.2.5.RELEASE</spring.version>
<mockito.version>1.10.19</mockito.version>
</properties>

<repositories>
<repository>
<id>org.springframework.maven.release</id>
<name>Spring Maven Release Repository</name>
<url>http://maven.springframework.org/release</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>org.springframework.maven.milestone</id>
<name>Spring Maven Milestone Repository</name>
<url>http://maven.springframework.org/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-core</artifactId>
<version>${spring.social.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-config</artifactId>
<version>${spring.social.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-security</artifactId>
<version>${spring.social.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.springframework.social.github.api;

import java.io.Serializable;

/**
* A GitHub repo branch.
*
* @author Boris Yakovito
*/
public class GitHubBranch implements Serializable {

private String name;

public GitHubBranch(String name) {
this.name = name;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,16 @@ public interface RepoOperations {
* @return repo
*/
GitHubRepo getRepo(String user, String repo);


/**
* Public operation to return a list of branches for the given repository.
*
* @param user GitHub user
* @param repo GitHub repository
* @return list of collaborators
*/
List<GitHubBranch> getBranches(String user, String repo);

/**
* Public operation to return a list of collaborators for the given repository.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,13 @@ public interface UserOperations {
* @return list of users the given user is following
*/
List<GitHubUser> getFollowing(String user);


/**
* Public operation to return the user's repositories
*
* @param user GitHub user
* @return list of repositories
*/
List<GitHubRepo> getRepos(String user);
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@

import java.util.List;

import org.springframework.social.github.api.GitHubCommit;
import org.springframework.social.github.api.GitHubDownload;
import org.springframework.social.github.api.GitHubHook;
import org.springframework.social.github.api.GitHubIssue;
import org.springframework.social.github.api.GitHubRepo;
import org.springframework.social.github.api.GitHubUser;
import org.springframework.social.github.api.RepoOperations;
import org.springframework.social.github.api.*;
import org.springframework.web.client.RestTemplate;

/**
Expand All @@ -52,7 +46,12 @@ public RepoTemplate(RestTemplate restTemplate, boolean isAuthorizedForUser) {
public GitHubRepo getRepo(String user, String repo) {
return restTemplate.getForObject(buildRepoUri(""), GitHubRepo.class, user, repo);
}


@Override
public List<GitHubBranch> getBranches(String user, String repo) {
return asList(restTemplate.getForObject(buildRepoUri("/branches"), GitHubBranch[].class, user, repo));
}

public List<GitHubUser> getCollaborators(String user, String repo) {
return asList(restTemplate.getForObject(buildRepoUri("/collaborators"), GitHubUser[].class, user, repo));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import org.springframework.social.github.api.GitHubRepo;
import org.springframework.social.github.api.GitHubUser;
import org.springframework.social.github.api.GitHubUserProfile;
import org.springframework.social.github.api.UserOperations;
Expand Down Expand Up @@ -71,7 +71,10 @@ public String getProfileUrl() {
return "https://github.com/" + getUserProfile().getLogin();
}


@Override
public List<GitHubRepo> getRepos(String user) {
return asList(restTemplate.getForObject(buildUserUri("/repos"), GitHubRepo[].class, user));
}

private String buildUserUri(String path) {
return buildUri("users/{user}" + path);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.springframework.social.github.api.impl.json;

import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.social.github.api.GitHubBranch;

/**
* Annotated mixin to add annotations to {@link GitHubBranch}
*
* @author Boris Yakovito
*/
public class GitHubBranchMixin extends GitHubObjectMixin {

GitHubBranchMixin(@JsonProperty("name") String name) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package org.springframework.social.github.api.impl.json;

import com.fasterxml.jackson.databind.Module;
import com.fasterxml.jackson.databind.module.SimpleModule;
import org.springframework.social.github.api.*;

Expand All @@ -40,6 +39,7 @@ public void setupModule(SetupContext context) {
context.setMixInAnnotations(GitHubHook.class, GitHubHookMixin.class);
context.setMixInAnnotations(GitHubIssue.class, GitHubIssueMixin.class);
context.setMixInAnnotations(GitHubRepo.class, GitHubRepoMixin.class);
context.setMixInAnnotations(GitHubBranch.class, GitHubBranchMixin.class);
context.setMixInAnnotations(GitHubUser.class, GitHubUserMixin.class);
context.setMixInAnnotations(GitHubUserProfile.class, GitHubUserProfileMixin.class);
}
Expand Down