Add REST endpoint to get content of a file from HEAD of a branch
By GET on /projects/<project-name>/branches/<branch>/files/<file>/content it is now possible to retrieve the content of a file from the HEAD revision of a certain branch. The file content is returned as base64 encoded string. This endpoint is useful for integrating tools that need access to certain files, e.g. a tool may need to get the pom.xml from every project. In this case it would be too much overhead to clone each repository just to get this one file from it. Change-Id: I70f294fbcc8a4cc88cd3c1265653cc9870b6433e Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
@@ -18,6 +18,7 @@ import static com.google.gerrit.server.project.BranchResource.BRANCH_KIND;
|
||||
import static com.google.gerrit.server.project.ChildProjectResource.CHILD_PROJECT_KIND;
|
||||
import static com.google.gerrit.server.project.DashboardResource.DASHBOARD_KIND;
|
||||
import static com.google.gerrit.server.project.ProjectResource.PROJECT_KIND;
|
||||
import static com.google.gerrit.server.project.FileResource.FILE_KIND;
|
||||
|
||||
import com.google.gerrit.extensions.registration.DynamicMap;
|
||||
import com.google.gerrit.extensions.restapi.RestApiModule;
|
||||
@@ -33,6 +34,7 @@ public class Module extends RestApiModule {
|
||||
DynamicMap.mapOf(binder(), CHILD_PROJECT_KIND);
|
||||
DynamicMap.mapOf(binder(), BRANCH_KIND);
|
||||
DynamicMap.mapOf(binder(), DASHBOARD_KIND);
|
||||
DynamicMap.mapOf(binder(), FILE_KIND);
|
||||
|
||||
put(PROJECT_KIND).to(PutProject.class);
|
||||
get(PROJECT_KIND).to(GetProject.class);
|
||||
@@ -57,6 +59,8 @@ public class Module extends RestApiModule {
|
||||
get(BRANCH_KIND).to(GetBranch.class);
|
||||
delete(BRANCH_KIND).to(DeleteBranch.class);
|
||||
install(new FactoryModuleBuilder().build(CreateBranch.Factory.class));
|
||||
child(BRANCH_KIND, "files").to(FilesCollection.class);
|
||||
get(FILE_KIND, "content").to(GetContent.class);
|
||||
|
||||
child(PROJECT_KIND, "dashboards").to(DashboardsCollection.class);
|
||||
get(DASHBOARD_KIND).to(GetDashboard.class);
|
||||
|
||||
Reference in New Issue
Block a user