summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthallgren2011-09-25 00:14:41 (EDT)
committerKevin Sawicki2011-09-25 00:14:41 (EDT)
commitfd244b33d7ac8db13a1e876b96b8c05083244862 (patch)
treed7107bb0fb9ffe8c30e78bf4f038a95901a977ed
parent8061f4a940f143d26285112a7a6df43241423520 (diff)
downloadegit-github-fd244b33d7ac8db13a1e876b96b8c05083244862.zip
egit-github-fd244b33d7ac8db13a1e876b96b8c05083244862.tar.gz
egit-github-fd244b33d7ac8db13a1e876b96b8c05083244862.tar.bz2
Add service support for editing a repositoryrefs/changes/88/4288/4
Change-Id: Ib69f15094d568d015ab36706f553d337a73c984c Signed-off-by: Thomas Hallgren <thomas@tada.se> Signed-off-by: Kevin Sawicki <kevin@github.com>
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/RepositoryServiceTest.java24
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/service/RepositoryService.java17
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 41dd9af..0107e27 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 ca3dff8..31934c0 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.
*