Make ReceiveCommits non-public

Callers used to have access to both the AsyncReceiveCommits and the
underlying ReceiveCommits. This was confusing at best, and in the
presence of multiple threads (or, eventually, retrying) broken at worst.
Try to simplify the package interface by forcing all callers to go
through AsyncReceiveCommits. It's still somewhat non-obvious, but at
least there is only one choice.

To support tests that want to assert over specific error message
strings, factor out a public ReceiveConstants class.

Change-Id: I1760faed4c2d4d508c38ec8a698f3e5c2aae2c35
This commit is contained in:
Dave Borowitz
2017-08-03 13:15:26 -04:00
parent fe84eaa819
commit 769d159701
8 changed files with 81 additions and 43 deletions

View File

@@ -295,9 +295,9 @@ public class GitOverHttpServlet extends GitServlet {
}
AsyncReceiveCommits arc = factory.create(pc, db);
arc.getReceiveCommits().init();
arc.init();
ReceivePack rp = arc.getReceiveCommits().getReceivePack();
ReceivePack rp = arc.getReceivePack();
req.setAttribute(ATT_ARC, arc);
return rp;
}
@@ -325,7 +325,7 @@ public class GitOverHttpServlet extends GitServlet {
boolean isGet = "GET".equalsIgnoreCase(((HttpServletRequest) request).getMethod());
AsyncReceiveCommits arc = (AsyncReceiveCommits) request.getAttribute(ATT_ARC);
ReceivePack rp = arc.getReceiveCommits().getReceivePack();
ReceivePack rp = arc.getReceivePack();
rp.getAdvertiseRefsHook().advertiseRefs(rp);
ProjectControl pc = (ProjectControl) request.getAttribute(ATT_CONTROL);
Project.NameKey projectName = pc.getProject().getNameKey();