diff options
| author | thallgren | 2011-09-25 04:14:41 +0000 |
|---|---|---|
| committer | Kevin Sawicki | 2011-09-25 04:14:41 +0000 |
| commit | fd244b33d7ac8db13a1e876b96b8c05083244862 (patch) | |
| tree | d7107bb0fb9ffe8c30e78bf4f038a95901a977ed | |
| parent | 8061f4a940f143d26285112a7a6df43241423520 (diff) | |
| download | egit-github-fd244b33d7ac8db13a1e876b96b8c05083244862.tar.gz egit-github-fd244b33d7ac8db13a1e876b96b8c05083244862.tar.xz egit-github-fd244b33d7ac8db13a1e876b96b8c05083244862.zip | |
Add service support for editing a repository
Change-Id: Ib69f15094d568d015ab36706f553d337a73c984c
Signed-off-by: Thomas Hallgren <thomas@tada.se>
Signed-off-by: Kevin Sawicki <kevin@github.com>
2 files changed, 41 insertions, 0 deletions
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/RepositoryServiceTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/RepositoryServiceTest.java index 41dd9afa..0107e273 100644 --- a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/RepositoryServiceTest.java +++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/RepositoryServiceTest.java @@ -92,6 +92,30 @@ public class RepositoryServiceTest { } /** + * Edit repository with null repository + * + * @throws IOException + */ + @Test(expected = IllegalArgumentException.class) + public void editRepositoryNullRepository() throws IOException { + service.editRepository(null); + } + + /** + * Edit repository + * + * @throws IOException + */ + @Test + public void editRepository() throws IOException { + Repository repo = new Repository(); + repo.setName("n"); + repo.setOwner(new User().setLogin("o")); + service.editRepository(repo); + verify(client).post("/repos/o/n", repo, Repository.class); + } + + /** * Create repository with null organization name * * @throws IOException diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/RepositoryService.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/RepositoryService.java index ca3dff80..31934c07 100644 --- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/RepositoryService.java +++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/RepositoryService.java @@ -455,6 +455,23 @@ public class RepositoryService extends GitHubService { } /** + * Edit given repository + * + * @param repository + * @return edited repository + * @throws IOException + */ + public Repository editRepository(Repository repository) throws IOException { + if (repository == null) + throw new IllegalArgumentException("Repository cannot be null"); //$NON-NLS-1$ + + final String repoId = getId(repository); + StringBuilder uri = new StringBuilder(SEGMENT_REPOS); + uri.append('/').append(repoId); + return client.post(uri.toString(), repository, Repository.class); + } + + /** * Fork given repository into new repository under the currently * authenticated user. * |
