Merge "Rewrite GWT UI to use project name in addition to numeric change ID"
This commit is contained in:
@@ -9,6 +9,7 @@ import com.google.gerrit.extensions.api.changes.Changes;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
@@ -45,7 +46,8 @@ class DirectChangeByCommit extends HttpServlet {
|
||||
if (results.size() == 1) {
|
||||
// If exactly one change matches, link to that change.
|
||||
// TODO Link to a specific patch set, if one matched.
|
||||
token = PageLinks.toChange(new Change.Id(results.iterator().next()._number));
|
||||
ChangeInfo ci = results.iterator().next();
|
||||
token = PageLinks.toChange(new Project.NameKey(ci.project), new Change.Id(ci._number));
|
||||
} else {
|
||||
// Otherwise, link to the query page.
|
||||
token = PageLinks.toChangeQuery(query);
|
||||
|
||||
@@ -178,7 +178,10 @@ class UrlModule extends ServletModule {
|
||||
idString = idString.substring(0, idString.length() - 1);
|
||||
}
|
||||
Change.Id id = Change.Id.parse(idString);
|
||||
toGerrit(PageLinks.toChange(id), req, rsp);
|
||||
// User accessed Gerrit with /1234, so we have no project yet.
|
||||
// TODO(hiesel) Replace with a preflight request to obtain project before we deprecate
|
||||
// the numeric change id.
|
||||
toGerrit(PageLinks.toChange(null, id), req, rsp);
|
||||
} catch (IllegalArgumentException err) {
|
||||
rsp.sendError(HttpServletResponse.SC_NOT_FOUND);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user